Monday, 7 October 2013

Server Packets: Graphical User Interface for Containers


These packets are used to manage the Graphical User Interface for Containers (eg Inventory, Furnace, Crafting table, etc) – opening/closing, inserting/removing items, etc.  The packets all come from EntityPlayerMP, and are handled by calls to EntityClientPlayerMP.



Typical server origin
NetClientHandler (Client processing)
Called by Client during processing
Packet100OpenWindow
Open a GUI window (eg chest, furnace)
EntityPlayerMP
.displayGUIxxxxxx
.handleOpenWindow()
Various including chest, workbench, furnace, etc
EntityClientPlayerMP
.displayGUIxxxxxx
Packet101CloseWindow
Closes the current GUI (chest etc)
EntityPlayerMP
.handleCloseWindow()
EntityClientPlayerMP
Packet103SetSlot
Put an item into the specified inventory or hotbar slot
EntityPlayerMP
.handleSetSlot()
EntityClientPlayerMP
Packet104WindowItems
Fill the inventory with a list of items.
EntityPlayerMP
.handleWindowItems()

EntityClientPlayerMP
Packet105UpdateProgressbar
Update the progress bar eg for furnace, repair, enchantment, etc
EntityPlayerMP
.handleUpdateProgressbar()
EntityClientPlayerMP
Packet106Transaction
This packet works together with Packet102 to ensure that the container contents remain properly synchronised on client and server.
NetServerHandler
.handleWindowClick
.handleTransaction()


Packet133TileEditorOpen
Displays the GUI for editing a sign at a given [x,y,z]
EntityPlayerMP
.handleTileEditorOpen()
EntityClientPlayerMP
.displayGUIEditSign

There is also an FMLPacket used to open Graphical User Interfaces:

Typical Server origin
FMLClientHandler (Client processing)
Called by Client during processing
OpenGuiPacket
FMLNetworkHandler
.openGui
NetworkRegistry
.openRemoteGui
.showGuiScreen()



NetworkRegistry.openRemoteGui
or
NetworkRegistry.openLocalGui