001 package net.minecraft.network.packet; 002 003 import java.io.DataInputStream; 004 import java.io.DataOutputStream; 005 import java.io.IOException; 006 import net.minecraft.item.ItemStack; 007 008 public class Packet103SetSlot extends Packet 009 { 010 /** The window which is being updated. 0 for player inventory */ 011 public int windowId; 012 013 /** Slot that should be updated */ 014 public int itemSlot; 015 016 /** Item stack */ 017 public ItemStack myItemStack; 018 019 public Packet103SetSlot() {} 020 021 public Packet103SetSlot(int par1, int par2, ItemStack par3ItemStack) 022 { 023 this.windowId = par1; 024 this.itemSlot = par2; 025 this.myItemStack = par3ItemStack == null ? par3ItemStack : par3ItemStack.copy(); 026 } 027 028 /** 029 * Passes this Packet on to the NetHandler for processing. 030 */ 031 public void processPacket(NetHandler par1NetHandler) 032 { 033 par1NetHandler.handleSetSlot(this); 034 } 035 036 /** 037 * Abstract. Reads the raw packet data from the data stream. 038 */ 039 public void readPacketData(DataInputStream par1DataInputStream) throws IOException 040 { 041 this.windowId = par1DataInputStream.readByte(); 042 this.itemSlot = par1DataInputStream.readShort(); 043 this.myItemStack = readItemStack(par1DataInputStream); 044 } 045 046 /** 047 * Abstract. Writes the raw packet data to the data stream. 048 */ 049 public void writePacketData(DataOutputStream par1DataOutputStream) throws IOException 050 { 051 par1DataOutputStream.writeByte(this.windowId); 052 par1DataOutputStream.writeShort(this.itemSlot); 053 writeItemStack(this.myItemStack, par1DataOutputStream); 054 } 055 056 /** 057 * Abstract. Return the size of the packet (not counting the header). 058 */ 059 public int getPacketSize() 060 { 061 return 8; 062 } 063 }