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