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 int itemID; 030 031 /** The number of items. */ 032 public int count; 033 034 /** The health of the item. */ 035 public int itemDamage; 036 037 public Packet21PickupSpawn() {} 038 039 public Packet21PickupSpawn(EntityItem par1EntityItem) 040 { 041 this.entityId = par1EntityItem.entityId; 042 this.itemID = par1EntityItem.item.itemID; 043 this.count = par1EntityItem.item.stackSize; 044 this.itemDamage = par1EntityItem.item.getItemDamage(); 045 this.xPosition = MathHelper.floor_double(par1EntityItem.posX * 32.0D); 046 this.yPosition = MathHelper.floor_double(par1EntityItem.posY * 32.0D); 047 this.zPosition = MathHelper.floor_double(par1EntityItem.posZ * 32.0D); 048 this.rotation = (byte)((int)(par1EntityItem.motionX * 128.0D)); 049 this.pitch = (byte)((int)(par1EntityItem.motionY * 128.0D)); 050 this.roll = (byte)((int)(par1EntityItem.motionZ * 128.0D)); 051 } 052 053 /** 054 * Abstract. Reads the raw packet data from the data stream. 055 */ 056 public void readPacketData(DataInputStream par1DataInputStream) throws IOException 057 { 058 this.entityId = par1DataInputStream.readInt(); 059 this.itemID = par1DataInputStream.readShort(); 060 this.count = par1DataInputStream.readByte(); 061 this.itemDamage = par1DataInputStream.readShort(); 062 this.xPosition = par1DataInputStream.readInt(); 063 this.yPosition = par1DataInputStream.readInt(); 064 this.zPosition = par1DataInputStream.readInt(); 065 this.rotation = par1DataInputStream.readByte(); 066 this.pitch = par1DataInputStream.readByte(); 067 this.roll = par1DataInputStream.readByte(); 068 } 069 070 /** 071 * Abstract. Writes the raw packet data to the data stream. 072 */ 073 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 074 { 075 par1DataOutputStream.writeInt(this.entityId); 076 par1DataOutputStream.writeShort(this.itemID); 077 par1DataOutputStream.writeByte(this.count); 078 par1DataOutputStream.writeShort(this.itemDamage); 079 par1DataOutputStream.writeInt(this.xPosition); 080 par1DataOutputStream.writeInt(this.yPosition); 081 par1DataOutputStream.writeInt(this.zPosition); 082 par1DataOutputStream.writeByte(this.rotation); 083 par1DataOutputStream.writeByte(this.pitch); 084 par1DataOutputStream.writeByte(this.roll); 085 } 086 087 /** 088 * Passes this Packet on to the NetHandler for processing. 089 */ 090 public void processPacket(NetHandler par1NetHandler) 091 { 092 par1NetHandler.handlePickupSpawn(this); 093 } 094 095 /** 096 * Abstract. Return the size of the packet (not counting the header). 097 */ 098 public int getPacketSize() 099 { 100 return 24; 101 } 102 }