    001    package net.minecraft.network.packet;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.io.DataInputStream;
    006    import java.io.DataOutputStream;
    007    import java.io.IOException;
    008
    009    public class Packet55BlockDestroy extends Packet
    010    {
    011        /** Entity breaking the block */
    012        private int entityId;
    013
    014        /** X posiiton of the block */
    015        private int posX;
    016
    017        /** Y position of the block */
    018        private int posY;
    019
    020        /** Z position of the block */
    021        private int posZ;
    022
    023        /** How far destroyed this block is */
    024        private int destroyedStage;
    025
    026        public Packet55BlockDestroy() {}
    027
    028        public Packet55BlockDestroy(int par1, int par2, int par3, int par4, int par5)
    029        {
    030            this.entityId = par1;
    031            this.posX = par2;
    032            this.posY = par3;
    033            this.posZ = par4;
    034            this.destroyedStage = par5;
    035        }
    036
    037        /**
    038         * Abstract. Reads the raw packet data from the data stream.
    039         */
    040        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
    041        {
    042            this.entityId = par1DataInputStream.readInt();
    043            this.posX = par1DataInputStream.readInt();
    044            this.posY = par1DataInputStream.readInt();
    045            this.posZ = par1DataInputStream.readInt();
    046            this.destroyedStage = par1DataInputStream.read();
    047        }
    048
    049        /**
    050         * Abstract. Writes the raw packet data to the data stream.
    051         */
    052        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
    053        {
    054            par1DataOutputStream.writeInt(this.entityId);
    055            par1DataOutputStream.writeInt(this.posX);
    056            par1DataOutputStream.writeInt(this.posY);
    057            par1DataOutputStream.writeInt(this.posZ);
    058            par1DataOutputStream.write(this.destroyedStage);
    059        }
    060
    061        /**
    062         * Passes this Packet on to the NetHandler for processing.
    063         */
    064        public void processPacket(NetHandler par1NetHandler)
    065        {
    066            par1NetHandler.handleBlockDestroy(this);
    067        }
    068
    069        /**
    070         * Abstract. Return the size of the packet (not counting the header).
    071         */
    072        public int getPacketSize()
    073        {
    074            return 13;
    075        }
    076
    077        @SideOnly(Side.CLIENT)
    078
    079        /**
    080         * Gets the ID of the entity breaking the block
    081         */
    082        public int getEntityId()
    083        {
    084            return this.entityId;
    085        }
    086
    087        @SideOnly(Side.CLIENT)
    088
    089        /**
    090         * Gets the X position of the block
    091         */
    092        public int getPosX()
    093        {
    094            return this.posX;
    095        }
    096
    097        @SideOnly(Side.CLIENT)
    098
    099        /**
    100         * Gets the Y position of the block
    101         */
    102        public int getPosY()
    103        {
    104            return this.posY;
    105        }
    106
    107        @SideOnly(Side.CLIENT)
    108
    109        /**
    110         * Gets the Z position of the block
    111         */
    112        public int getPosZ()
    113        {
    114            return this.posZ;
    115        }
    116
    117        @SideOnly(Side.CLIENT)
    118
    119        /**
    120         * Gets how far destroyed this block is
    121         */
    122        public int getDestroyedStage()
    123        {
    124            return this.destroyedStage;
    125        }
    126
    127        /**
    128         * only false for the abstract Packet class, all real packets return true
    129         */
    130        public boolean isRealPacket()
    131        {
    132            return true;
    133        }
    134
    135        /**
    136         * eg return packet30entity.entityId == entityId; WARNING : will throw if you compare a packet to a different packet
    137         * class
    138         */
    139        public boolean containsSameEntityIDAs(Packet par1Packet)
    140        {
    141            Packet55BlockDestroy var2 = (Packet55BlockDestroy)par1Packet;
    142            return var2.entityId == this.entityId;
    143        }
    144    }