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 Packet102WindowClick extends Packet
010 {
011 /** The id of the window which was clicked. 0 for player inventory. */
012 public int window_Id;
013
014 /** The clicked slot (-999 is outside of inventory) */
015 public int inventorySlot;
016
017 /** 1 when right-clicking and otherwise 0 */
018 public int mouseClick;
019
020 /** A unique number for the action, used for transaction handling */
021 public short action;
022
023 /** Item stack for inventory */
024 public ItemStack itemStack;
025 public int holdingShift;
026
027 public Packet102WindowClick() {}
028
029 @SideOnly(Side.CLIENT)
030 public Packet102WindowClick(int par1, int par2, int par3, int par4, ItemStack par5ItemStack, short par6)
031 {
032 this.window_Id = par1;
033 this.inventorySlot = par2;
034 this.mouseClick = par3;
035 this.itemStack = par5ItemStack;
036 this.action = par6;
037 this.holdingShift = par4;
038 }
039
040 /**
041 * Passes this Packet on to the NetHandler for processing.
042 */
043 public void processPacket(NetHandler par1NetHandler)
044 {
045 par1NetHandler.handleWindowClick(this);
046 }
047
048 /**
049 * Abstract. Reads the raw packet data from the data stream.
050 */
051 public void readPacketData(DataInputStream par1DataInputStream) throws IOException
052 {
053 this.window_Id = par1DataInputStream.readByte();
054 this.inventorySlot = par1DataInputStream.readShort();
055 this.mouseClick = par1DataInputStream.readByte();
056 this.action = par1DataInputStream.readShort();
057 this.holdingShift = par1DataInputStream.readByte();
058 this.itemStack = readItemStack(par1DataInputStream);
059 }
060
061 /**
062 * Abstract. Writes the raw packet data to the data stream.
063 */
064 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException
065 {
066 par1DataOutputStream.writeByte(this.window_Id);
067 par1DataOutputStream.writeShort(this.inventorySlot);
068 par1DataOutputStream.writeByte(this.mouseClick);
069 par1DataOutputStream.writeShort(this.action);
070 par1DataOutputStream.writeByte(this.holdingShift);
071 writeItemStack(this.itemStack, par1DataOutputStream);
072 }
073
074 /**
075 * Abstract. Return the size of the packet (not counting the header).
076 */
077 public int getPacketSize()
078 {
079 return 11;
080 }
081 }