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 Packet21PickupSpawn extends Packet
008 {
009 /** Unique entity ID. */
010 public int entityId;
011
012 /** The item X position. */
013 public int xPosition;
014
015 /** The item Y position. */
016 public int yPosition;
017
018 /** The item Z position. */
019 public int zPosition;
020
021 /** The item rotation. */
022 public byte rotation;
023
024 /** The item pitch. */
025 public byte pitch;
026
027 /** The item roll. */
028 public byte roll;
029 public ItemStack itemID;
030
031 public Packet21PickupSpawn() {}
032
033 public Packet21PickupSpawn(EntityItem par1EntityItem)
034 {
035 this.entityId = par1EntityItem.entityId;
036 this.itemID = par1EntityItem.item.copy();
037 this.xPosition = MathHelper.floor_double(par1EntityItem.posX * 32.0D);
038 this.yPosition = MathHelper.floor_double(par1EntityItem.posY * 32.0D);
039 this.zPosition = MathHelper.floor_double(par1EntityItem.posZ * 32.0D);
040 this.rotation = (byte)((int)(par1EntityItem.motionX * 128.0D));
041 this.pitch = (byte)((int)(par1EntityItem.motionY * 128.0D));
042 this.roll = (byte)((int)(par1EntityItem.motionZ * 128.0D));
043 }
044
045 /**
046 * Abstract. Reads the raw packet data from the data stream.
047 */
048 public void readPacketData(DataInputStream par1DataInputStream) throws IOException
049 {
050 this.entityId = par1DataInputStream.readInt();
051 this.itemID = readItemStack(par1DataInputStream);
052 this.xPosition = par1DataInputStream.readInt();
053 this.yPosition = par1DataInputStream.readInt();
054 this.zPosition = par1DataInputStream.readInt();
055 this.rotation = par1DataInputStream.readByte();
056 this.pitch = par1DataInputStream.readByte();
057 this.roll = par1DataInputStream.readByte();
058 }
059
060 /**
061 * Abstract. Writes the raw packet data to the data stream.
062 */
063 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
064 {
065 par1DataOutputStream.writeInt(this.entityId);
066 writeItemStack(this.itemID, par1DataOutputStream);
067 par1DataOutputStream.writeInt(this.xPosition);
068 par1DataOutputStream.writeInt(this.yPosition);
069 par1DataOutputStream.writeInt(this.zPosition);
070 par1DataOutputStream.writeByte(this.rotation);
071 par1DataOutputStream.writeByte(this.pitch);
072 par1DataOutputStream.writeByte(this.roll);
073 }
074
075 /**
076 * Passes this Packet on to the NetHandler for processing.
077 */
078 public void processPacket(NetHandler par1NetHandler)
079 {
080 par1NetHandler.handlePickupSpawn(this);
081 }
082
083 /**
084 * Abstract. Return the size of the packet (not counting the header).
085 */
086 public int getPacketSize()
087 {
088 return 24;
089 }
090 }