Sunday, 18 January 2015

Vanilla Client<-->Server Communication

Vanilla communication between the Client and Server sides takes place through Packets, which are sent back and forth using NetHandlerPlayClient and NetHandlerPlayServer.  The basic steps are shown in the diagram below.  There are a large number of different packets used:
* Packets from Client to Server
* Packets from Server to Client
o   Changes to Entities
o   Changes to the World /blocks
o   Managing Graphical User Interface for Containers
o   Miscellaneous

Key points to note

  • Packets sent from Client to Server start with C, for example C07PacketPlayerDigging.
  • Packets sent from Server to Client start with S, for example S06PacketUpdateHealth
  • It is possible to create vanilla packets and send them using the NetHandler, however it's almost never necessary.  If you call the correct vanilla methods, they will send the packets for you.  (for example ServerConfigurationManager.sendChatMsg() instead of S02PacketChat).
  • In order to send your own custom messages between Client and Server, use the SimpleNetworkWrapper instead of Packets.

No comments:

Post a Comment