From a548c3ee40e6002efa07478b5a4ba8fb0e83e75b Mon Sep 17 00:00:00 2001 From: Snowiiii Date: Fri, 2 Aug 2024 11:09:33 +0200 Subject: [PATCH] protocol doc: miss how to register packets --- pumpkin-protocol/README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pumpkin-protocol/README.md b/pumpkin-protocol/README.md index aa57731b4..523242fb8 100644 --- a/pumpkin-protocol/README.md +++ b/pumpkin-protocol/README.md @@ -1,12 +1,11 @@ ### Pumpkin Protocol Contains all Serverbound(Client->Server) and Clientbound(Server->Client) Packets. -The packets are sorted by their folder architecture you find: -Serverbound Packets under: - `server` -Clientbound Packets under: - `client` -Than they both have folders for packets for all their diffrent states: +Packets in the Pumpkin protocol are organized by functionality and state. + +`server`: Contains definitions for serverbound packets. + +`client`: Contains definitions for clientbound packets. ### States: **Handshake**: Always the first packet being send from the Client. This begins also determins the next state, usally to indicate if the player thans perform a Status Request, Join the Server or wants to be transfered. @@ -25,8 +24,11 @@ You also can see all the information the Packets has which we can either Write o #### Adding a Serverbound Packet Serverbound Packets do use the trait `ServerPacket` which has an packet id (use hex) and can read incoming Client packets. https://wiki.vg/Protocol gives you the Packet structure which you can than read. Feel free to orientate on already existing Packets. -Please use a name structure like `SPacketName` for the struct, The 'S' representing its Serverbound +Please use a name structure like `SPacketName` for the struct, The 'S' representing its Serverbound. +Registering: Don't forget to register the Packet. All Packets before the Player is created so before the Play state. Are using the `ClientPacketProcessor` which calls the packet at `Client::handle_packet` (both in the pumpkin crate) #### Adding a Clientbound Packet Clientbound Packets do use the trait `ClientPacket` which has an packet id (use hex) and can write outgoining Server packets. https://wiki.vg/Protocol gives you the Packet structure which you can than write. Feel free to orientate on already existing Packets. -Please use a name structure like `CPacketName` for the struct, The 'C' representing its Clientbound \ No newline at end of file +Please use a name structure like `CPacketName` for the struct, The 'C' representing its Clientbound. +You don't need to register the Packet anywhere, You should just be able now to send it via `Client::send_packet` this will get a result. You should kick the client when an important Packet could't been send. Otherwise +just log an warn. \ No newline at end of file