001    package net.minecraft.src;
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 Packet15Place extends Packet
010    {
011        private int xPosition;
012        private int yPosition;
013        private int zPosition;
014    
015        /** The offset to use for block/item placement. */
016        private int direction;
017        private ItemStack itemStack;
018    
019        /** The offset from xPosition where the actual click took place */
020        private float xOffset;
021    
022        /** The offset from yPosition where the actual click took place */
023        private float yOffset;
024    
025        /** The offset from zPosition where the actual click took place */
026        private float zOffset;
027    
028        public Packet15Place() {}
029    
030        @SideOnly(Side.CLIENT)
031        public Packet15Place(int par1, int par2, int par3, int par4, ItemStack par5ItemStack, float par6, float par7, float par8)
032        {
033            this.xPosition = par1;
034            this.yPosition = par2;
035            this.zPosition = par3;
036            this.direction = par4;
037            this.itemStack = par5ItemStack;
038            this.xOffset = par6;
039            this.yOffset = par7;
040            this.zOffset = par8;
041        }
042    
043        /**
044         * Abstract. Reads the raw packet data from the data stream.
045         */
046        public void readPacketData(DataInputStream par1DataInputStream) throws IOException
047        {
048            this.xPosition = par1DataInputStream.readInt();
049            this.yPosition = par1DataInputStream.read();
050            this.zPosition = par1DataInputStream.readInt();
051            this.direction = par1DataInputStream.read();
052            this.itemStack = readItemStack(par1DataInputStream);
053            this.xOffset = (float)par1DataInputStream.read() / 16.0F;
054            this.yOffset = (float)par1DataInputStream.read() / 16.0F;
055            this.zOffset = (float)par1DataInputStream.read() / 16.0F;
056        }
057    
058        /**
059         * Abstract. Writes the raw packet data to the data stream.
060         */
061        public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
062        {
063            par1DataOutputStream.writeInt(this.xPosition);
064            par1DataOutputStream.write(this.yPosition);
065            par1DataOutputStream.writeInt(this.zPosition);
066            par1DataOutputStream.write(this.direction);
067            writeItemStack(this.itemStack, par1DataOutputStream);
068            par1DataOutputStream.write((int)(this.xOffset * 16.0F));
069            par1DataOutputStream.write((int)(this.yOffset * 16.0F));
070            par1DataOutputStream.write((int)(this.zOffset * 16.0F));
071        }
072    
073        /**
074         * Passes this Packet on to the NetHandler for processing.
075         */
076        public void processPacket(NetHandler par1NetHandler)
077        {
078            par1NetHandler.handlePlace(this);
079        }
080    
081        /**
082         * Abstract. Return the size of the packet (not counting the header).
083         */
084        public int getPacketSize()
085        {
086            return 19;
087        }
088    
089        public int getXPosition()
090        {
091            return this.xPosition;
092        }
093    
094        public int getYPosition()
095        {
096            return this.yPosition;
097        }
098    
099        public int getZPosition()
100        {
101            return this.zPosition;
102        }
103    
104        public int getDirection()
105        {
106            return this.direction;
107        }
108    
109        public ItemStack getItemStack()
110        {
111            return this.itemStack;
112        }
113    
114        /**
115         * Returns the offset from xPosition where the actual click took place
116         */
117        public float getXOffset()
118        {
119            return this.xOffset;
120        }
121    
122        /**
123         * Returns the offset from yPosition where the actual click took place
124         */
125        public float getYOffset()
126        {
127            return this.yOffset;
128        }
129    
130        /**
131         * Returns the offset from zPosition where the actual click took place
132         */
133        public float getZOffset()
134        {
135            return this.zOffset;
136        }
137    }