001 package net.minecraft.src; 002 003 import java.io.DataInputStream; 004 import java.io.DataOutputStream; 005 import java.io.IOException; 006 007 public class Packet53BlockChange extends Packet 008 { 009 /** Block X position. */ 010 public int xPosition; 011 012 /** Block Y position. */ 013 public int yPosition; 014 015 /** Block Z position. */ 016 public int zPosition; 017 018 /** The new block type for the block. */ 019 public int type; 020 021 /** Metadata of the block. */ 022 public int metadata; 023 024 public Packet53BlockChange() 025 { 026 this.isChunkDataPacket = true; 027 } 028 029 public Packet53BlockChange(int par1, int par2, int par3, World par4World) 030 { 031 this.isChunkDataPacket = true; 032 this.xPosition = par1; 033 this.yPosition = par2; 034 this.zPosition = par3; 035 this.type = par4World.getBlockId(par1, par2, par3); 036 this.metadata = par4World.getBlockMetadata(par1, par2, par3); 037 } 038 039 /** 040 * Abstract. Reads the raw packet data from the data stream. 041 */ 042 public void readPacketData(DataInputStream par1DataInputStream) throws IOException 043 { 044 this.xPosition = par1DataInputStream.readInt(); 045 this.yPosition = par1DataInputStream.read(); 046 this.zPosition = par1DataInputStream.readInt(); 047 this.type = par1DataInputStream.readShort(); 048 this.metadata = par1DataInputStream.read(); 049 } 050 051 /** 052 * Abstract. Writes the raw packet data to the data stream. 053 */ 054 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 055 { 056 par1DataOutputStream.writeInt(this.xPosition); 057 par1DataOutputStream.write(this.yPosition); 058 par1DataOutputStream.writeInt(this.zPosition); 059 par1DataOutputStream.writeShort(this.type); 060 par1DataOutputStream.write(this.metadata); 061 } 062 063 /** 064 * Passes this Packet on to the NetHandler for processing. 065 */ 066 public void processPacket(NetHandler par1NetHandler) 067 { 068 par1NetHandler.handleBlockChange(this); 069 } 070 071 /** 072 * Abstract. Return the size of the packet (not counting the header). 073 */ 074 public int getPacketSize() 075 { 076 return 11; 077 } 078 }