| 1 | package net.minecraft.network.play.client;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import net.minecraft.item.ItemStack;
|
| 5 | import net.minecraft.network.Packet;
|
| 6 | import net.minecraft.network.PacketBuffer;
|
| 7 | import net.minecraft.network.play.INetHandlerPlayServer;
|
| 8 |
|
| 9 | public class C0EPacketClickWindow implements Packet<INetHandlerPlayServer>
|
| 10 | {
|
| 11 | /** The id of the window which was clicked. 0 for player inventory. */
|
| 12 | private int windowId;
|
| 13 |
|
| 14 | /** Id of the clicked slot */
|
| 15 | private int slotId;
|
| 16 |
|
| 17 | /** Button used */
|
| 18 | private int usedButton;
|
| 19 |
|
| 20 | /** A unique number for the action, used for transaction handling */
|
| 21 | private short actionNumber;
|
| 22 |
|
| 23 | /** The item stack present in the slot */
|
| 24 | private ItemStack clickedItem;
|
| 25 |
|
| 26 | /** Inventory operation mode */
|
| 27 | private int mode;
|
| 28 |
|
| 29 | public C0EPacketClickWindow()
|
| 30 | {
|
| 31 | }
|
| 32 |
|
| 33 | public C0EPacketClickWindow(int windowId, int slotId, int usedButton, int mode, ItemStack clickedItem, short actionNumber)
|
| 34 | {
|
| 35 | this.windowId = windowId;
|
| 36 | this.slotId = slotId;
|
| 37 | this.usedButton = usedButton;
|
| 38 | this.clickedItem = clickedItem != null ? clickedItem.copy() : null;
|
| 39 | this.actionNumber = actionNumber;
|
| 40 | this.mode = mode;
|
| 41 | }
|
| 42 |
|
| 43 | /**
|
| 44 | * Passes this Packet on to the NetHandler for processing.
|
| 45 | */
|
| 46 | public void processPacket(INetHandlerPlayServer handler)
|
| 47 | {
|
| 48 | handler.processClickWindow(this);
|
| 49 | }
|
| 50 |
|
| 51 | /**
|
| 52 | * Reads the raw packet data from the data stream.
|
| 53 | */
|
| 54 | public void readPacketData(PacketBuffer buf) throws IOException
|
| 55 | {
|
| 56 | this.windowId = buf.readByte();
|
| 57 | this.slotId = buf.readShort();
|
| 58 | this.usedButton = buf.readByte();
|
| 59 | this.actionNumber = buf.readShort();
|
| 60 | this.mode = buf.readByte();
|
| 61 | this.clickedItem = buf.readItemStackFromBuffer();
|
| 62 | }
|
| 63 |
|
| 64 | /**
|
| 65 | * Writes the raw packet data to the data stream.
|
| 66 | */
|
| 67 | public void writePacketData(PacketBuffer buf) throws IOException
|
| 68 | {
|
| 69 | buf.writeByte(this.windowId);
|
| 70 | buf.writeShort(this.slotId);
|
| 71 | buf.writeByte(this.usedButton);
|
| 72 | buf.writeShort(this.actionNumber);
|
| 73 | buf.writeByte(this.mode);
|
| 74 | buf.writeItemStackToBuffer(this.clickedItem);
|
| 75 | }
|
| 76 |
|
| 77 | public int getWindowId()
|
| 78 | {
|
| 79 | return this.windowId;
|
| 80 | }
|
| 81 |
|
| 82 | public int getSlotId()
|
| 83 | {
|
| 84 | return this.slotId;
|
| 85 | }
|
| 86 |
|
| 87 | public int getUsedButton()
|
| 88 | {
|
| 89 | return this.usedButton;
|
| 90 | }
|
| 91 |
|
| 92 | public short getActionNumber()
|
| 93 | {
|
| 94 | return this.actionNumber;
|
| 95 | }
|
| 96 |
|
| 97 | public ItemStack getClickedItem()
|
| 98 | {
|
| 99 | return this.clickedItem;
|
| 100 | }
|
| 101 |
|
| 102 | public int getMode()
|
| 103 | {
|
| 104 | return this.mode;
|
| 105 | }
|
| 106 | }
|
| 107 |
|