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 Packet131MapData extends Packet
008 {
009 public short itemID;
010
011 /**
012 * Contains a unique ID for the item that this packet will be populating.
013 */
014 public short uniqueID;
015
016 /**
017 * Contains a buffer of arbitrary data with which to populate an individual item in the world.
018 */
019 public byte[] itemData;
020
021 public Packet131MapData()
022 {
023 this.isChunkDataPacket = true;
024 }
025
026 public Packet131MapData(short par1, short par2, byte[] par3ArrayOfByte)
027 {
028 this.isChunkDataPacket = true;
029 this.itemID = par1;
030 this.uniqueID = par2;
031 this.itemData = par3ArrayOfByte;
032 }
033
034 /**
035 * Abstract. Reads the raw packet data from the data stream.
036 */
037 public void readPacketData(DataInputStream par1DataInputStream) throws IOException
038 {
039 this.itemID = par1DataInputStream.readShort();
040 this.uniqueID = par1DataInputStream.readShort();
041 this.itemData = new byte[par1DataInputStream.readByte() & 255];
042 par1DataInputStream.readFully(this.itemData);
043 }
044
045 /**
046 * Abstract. Writes the raw packet data to the data stream.
047 */
048 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
049 {
050 par1DataOutputStream.writeShort(this.itemID);
051 par1DataOutputStream.writeShort(this.uniqueID);
052 par1DataOutputStream.writeByte(this.itemData.length);
053 par1DataOutputStream.write(this.itemData);
054 }
055
056 /**
057 * Passes this Packet on to the NetHandler for processing.
058 */
059 public void processPacket(NetHandler par1NetHandler)
060 {
061 par1NetHandler.handleMapData(this);
062 }
063
064 /**
065 * Abstract. Return the size of the packet (not counting the header).
066 */
067 public int getPacketSize()
068 {
069 return 4 + this.itemData.length;
070 }
071 }