Overview
The Ember Client Server API uses a packet-based communication system to exchange data between your Minecraft server and players using Ember Client. Packets are lightweight, serialized messages that travel over Minecraft’s plugin messaging channels.What Are Packets?
Packets are structured data containers that encapsulate specific types of information. Each packet has:- A unique numeric ID for identification
- A direction (inbound from client or outbound to client)
- Serialization/deserialization logic
- Optional handling logic when received
Packet Base Class
All packets extend the abstractPacket class located at com.emberclient.serverapi.packet.Packet:
Packet.java
Key Methods
Serializes packet data into a
ByteBufWrapper for transmission. Override this method in outbound packets to write your data.Deserializes packet data from a
ByteBufWrapper after reception. Override this method in inbound packets to read data sent by the client.Processes the packet after it has been read. This is where you trigger events or execute custom logic. Takes the
Player who sent the packet as a parameter.PacketManager
ThePacketManager class (com.emberclient.serverapi.packet.PacketManager) manages packet registration and routing:
PacketManager.java
Packet Registration
Packets are registered in the constructor with a bidirectional mapping between packet IDs and packet classes. This allows the manager to:- Serialize outbound packets - Find the ID for a packet class when sending
- Deserialize inbound packets - Instantiate the correct packet class from an ID when receiving
Packet ID Convention
Outbound packets (server to client) use IDs 1-999, while inbound packets (client to server) use IDs 1000+.
Inbound vs Outbound Packets
Outbound Packets
Outbound packets are sent from the server to the client. They implement thewrite() method to serialize data.
Example: OutAttestationSign sends verification bytes to the client:
OutAttestationSign.java
Inbound Packets
Inbound packets are sent from the client to the server. They implement bothread() and handle() methods.
Example: InAttestationSign receives signed data from the client:
InAttestationSign.java
ByteBufWrapper Serialization
TheByteBufWrapper class provides utility methods for reading and writing various data types efficiently. It wraps Netty’s ByteBuf with convenient serialization methods.
Common Methods
Advanced Features
TheByteBufWrapper also supports:
- Optional values -
writeOptional()andreadOptional() - Maps -
writeMap()andreadMap() - Custom size limits - Most read methods accept maximum size parameters for security
com.emberclient.serverapi.ByteBufWrapper for all available methods.
Available Packet Types
The Server API currently includes these packet types:Attestation Registration
OutAttestationRegister
ID: 1 (Outbound)Requests the client to register a new attestation key. Has no data payload.
InAttestationRegister
ID: 1001 (Inbound)Returns the registration result and public key (if successful) to the server.Data:
AttestationRegisterResultstatusX509EncodedKeySpecpublicKey (if SUCCESS)
Attestation Signing
OutAttestationSign
ID: 2 (Outbound)Requests the client to sign verification bytes with their attestation key.Data:
byte[]verificationBytes (Base64 encoded)
InAttestationSign
ID: 1002 (Inbound)Returns the signing result and signed data (if successful) to the server.Data:
AttestationSignResultstatusbyte[]signedData (if SUCCESS, Base64 encoded)
Next Steps
Events
Learn about the event system and how to listen to packet responses
Attestation Guide
Implement attestation authentication in your plugin