| 1 | package net.minecraft.network.play.server;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import net.minecraft.network.Packet;
|
| 5 | import net.minecraft.network.PacketBuffer;
|
| 6 | import net.minecraft.network.play.INetHandlerPlayClient;
|
| 7 | import net.minecraft.util.IChatComponent;
|
| 8 |
|
| 9 | public class S2DPacketOpenWindow implements Packet<INetHandlerPlayClient>
|
| 10 | {
|
| 11 | private int windowId;
|
| 12 | private String inventoryType;
|
| 13 | private IChatComponent windowTitle;
|
| 14 | private int slotCount;
|
| 15 | private int entityId;
|
| 16 |
|
| 17 | public S2DPacketOpenWindow()
|
| 18 | {
|
| 19 | }
|
| 20 |
|
| 21 | public S2DPacketOpenWindow(int incomingWindowId, String incomingWindowTitle, IChatComponent windowTitleIn)
|
| 22 | {
|
| 23 | this(incomingWindowId, incomingWindowTitle, windowTitleIn, 0);
|
| 24 | }
|
| 25 |
|
| 26 | public S2DPacketOpenWindow(int windowIdIn, String guiId, IChatComponent windowTitleIn, int slotCountIn)
|
| 27 | {
|
| 28 | this.windowId = windowIdIn;
|
| 29 | this.inventoryType = guiId;
|
| 30 | this.windowTitle = windowTitleIn;
|
| 31 | this.slotCount = slotCountIn;
|
| 32 | }
|
| 33 |
|
| 34 | public S2DPacketOpenWindow(int windowIdIn, String guiId, IChatComponent windowTitleIn, int slotCountIn, int incomingEntityId)
|
| 35 | {
|
| 36 | this(windowIdIn, guiId, windowTitleIn, slotCountIn);
|
| 37 | this.entityId = incomingEntityId;
|
| 38 | }
|
| 39 |
|
| 40 | /**
|
| 41 | * Passes this Packet on to the NetHandler for processing.
|
| 42 | */
|
| 43 | public void processPacket(INetHandlerPlayClient handler)
|
| 44 | {
|
| 45 | handler.handleOpenWindow(this);
|
| 46 | }
|
| 47 |
|
| 48 | /**
|
| 49 | * Reads the raw packet data from the data stream.
|
| 50 | */
|
| 51 | public void readPacketData(PacketBuffer buf) throws IOException
|
| 52 | {
|
| 53 | this.windowId = buf.readUnsignedByte();
|
| 54 | this.inventoryType = buf.readStringFromBuffer(32);
|
| 55 | this.windowTitle = buf.readChatComponent();
|
| 56 | this.slotCount = buf.readUnsignedByte();
|
| 57 |
|
| 58 | if (this.inventoryType.equals("EntityHorse"))
|
| 59 | {
|
| 60 | this.entityId = buf.readInt();
|
| 61 | }
|
| 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.writeString(this.inventoryType);
|
| 71 | buf.writeChatComponent(this.windowTitle);
|
| 72 | buf.writeByte(this.slotCount);
|
| 73 |
|
| 74 | if (this.inventoryType.equals("EntityHorse"))
|
| 75 | {
|
| 76 | buf.writeInt(this.entityId);
|
| 77 | }
|
| 78 | }
|
| 79 |
|
| 80 | public int getWindowId()
|
| 81 | {
|
| 82 | return this.windowId;
|
| 83 | }
|
| 84 |
|
| 85 | public String getGuiId()
|
| 86 | {
|
| 87 | return this.inventoryType;
|
| 88 | }
|
| 89 |
|
| 90 | public IChatComponent getWindowTitle()
|
| 91 | {
|
| 92 | return this.windowTitle;
|
| 93 | }
|
| 94 |
|
| 95 | public int getSlotCount()
|
| 96 | {
|
| 97 | return this.slotCount;
|
| 98 | }
|
| 99 |
|
| 100 | public int getEntityId()
|
| 101 | {
|
| 102 | return this.entityId;
|
| 103 | }
|
| 104 |
|
| 105 | public boolean hasSlots()
|
| 106 | {
|
| 107 | return this.slotCount > 0;
|
| 108 | }
|
| 109 | }
|
| 110 |
|