Sunday 22 March 2020

Vanilla Client<-->Server Communication [1.14.4+]

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 CPlayerDiggingPacket.
  • Packets sent from Server to Client start with S, for example SUpdateHealthPacket
  • 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 PlayerList.sendMessage() instead of SChatPacket).
  • In order to send your own custom messages between Client and Server, use the SimpleChannel instead of Packets.

No comments:

Post a Comment