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