2020-06-19 17:18:18 +02:00
|
|
|
# Network Protocol
|
|
|
|
|
|
|
|
**Note:** All packets are sent using TCP only.
|
|
|
|
|
|
|
|
## Integer types
|
|
|
|
|
|
|
|
Integer types are represented with `s8`/`s16`/`s32`/`s64` and `u8`/`u16`/`u32`/`u64`.
|
|
|
|
|
|
|
|
The `s`/`u` means `signed`/`unsigned` and the number is the size of the type in bits.
|
|
|
|
|
|
|
|
## Login
|
|
|
|
|
|
|
|
### Clientbound
|
|
|
|
|
|
|
|
#### ClientOk
|
|
|
|
|
|
|
|
Packet sent from a server to accept a connection.
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ---------- | ---------------------------------------------------- |
|
|
|
|
| Client ID | u16 | ID assigned by the server for this client |
|
|
|
|
| Singleplayer? | bool | Whether or not the server runs a singleplayer game |
|
|
|
|
|
|
|
|
#### ClientRefused
|
|
|
|
|
|
|
|
Packet sent from a server to refuse a connection.
|
|
|
|
|
|
|
|
_This packet has no field._
|
|
|
|
|
|
|
|
### Serverbound
|
|
|
|
|
|
|
|
#### ClientConnect
|
|
|
|
|
|
|
|
Packet sent from a client attempting to connect.
|
|
|
|
|
2020-06-26 01:31:41 +02:00
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Username | std::string | Name of the player attempting to connect |
|
2020-06-19 17:18:18 +02:00
|
|
|
|
|
|
|
#### ClientDisconnect
|
|
|
|
|
|
|
|
Packet sent from a client attempting to disconnect.
|
|
|
|
|
|
|
|
_This packet has no field._
|
|
|
|
|
|
|
|
## Game
|
|
|
|
|
|
|
|
### Clientbound
|
|
|
|
|
2020-07-17 01:37:29 +02:00
|
|
|
#### ServerTick
|
|
|
|
|
|
|
|
Packet sent at the beginning of every server tick.
|
|
|
|
|
2020-07-17 02:26:37 +02:00
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Current time | u64 | Current time in the server |
|
2020-07-17 01:37:29 +02:00
|
|
|
|
2020-06-19 17:18:18 +02:00
|
|
|
#### ServerClosed
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Message | std::string | Why the server has been closed |
|
|
|
|
|
|
|
|
#### ChunkData
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Chunk X | s32 | Chunk X coordinate |
|
|
|
|
| Chunk Y | s32 | Chunk Y coordinate |
|
|
|
|
| Chunk Z | s32 | Chunk Z coordinate |
|
|
|
|
| Array | | |
|
|
|
|
| - Block data | u32 | Block ID and data |
|
|
|
|
| - Light value | u8 | Sunlight and torchlight values |
|
|
|
|
|
2021-05-16 16:37:25 +02:00
|
|
|
#### ChunkUnload
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Chunk X | s32 | Chunk X coordinate |
|
|
|
|
| Chunk Y | s32 | Chunk Y coordinate |
|
|
|
|
| Chunk Z | s32 | Chunk Z coordinate |
|
|
|
|
|
2020-06-19 17:18:18 +02:00
|
|
|
#### PlayerInvUpdate (clientbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| ID | u16 | Player ID |
|
|
|
|
| Inventory | Inventory | Player inventory |
|
2020-07-17 23:32:50 +02:00
|
|
|
| Current slot | s8 | Player held item slot |
|
2020-06-19 17:18:18 +02:00
|
|
|
|
|
|
|
#### PlayerPosUpdate (clientbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| -------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| ID | u16 | Player ID |
|
|
|
|
| Player X | double | Player X coordinate |
|
|
|
|
| Player Y | double | Player Y coordinate |
|
|
|
|
| Player Z | double | Player Z coordinate |
|
|
|
|
| Teleportation? | bool | Whether or not this update is a teleportation |
|
|
|
|
|
|
|
|
#### PlayerSpawn
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| -------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| ID | u16 | Player ID |
|
|
|
|
| Player X | double | Player X coordinate |
|
|
|
|
| Player Y | double | Player Y coordinate |
|
|
|
|
| Player Z | double | Player Z coordinate |
|
2020-06-26 01:31:41 +02:00
|
|
|
| Dimension | u16 | Dimension ID |
|
|
|
|
| Username | std::string | Name of the player |
|
2020-06-26 04:52:04 +02:00
|
|
|
| Camera Yaw | float | Horizontal camera view angle |
|
|
|
|
| Camera Pitch | float | Vertical camera view angle |
|
2020-06-19 17:18:18 +02:00
|
|
|
|
|
|
|
#### PlayerChangeDimension
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| ID | u16 | Player ID |
|
|
|
|
| Spawn X | s32 | Spawn X coordinate in the new dimension |
|
|
|
|
| Spawn Y | s32 | Spawn Y coordinate in the new dimension |
|
|
|
|
| Spawn Z | s32 | Spawn Z coordinate in the new dimension |
|
|
|
|
| Dimension | u16 | New dimension ID |
|
|
|
|
|
|
|
|
#### BlockUpdate
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Block X | s32 | Block X coordinate |
|
|
|
|
| Block Y | s32 | Block Y coordinate |
|
|
|
|
| Block Z | s32 | Block Z coordinate |
|
|
|
|
| Block ID | u32 | Block ID and data |
|
|
|
|
|
|
|
|
#### BlockGUIData
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Width | u16 | Width of the GUI |
|
|
|
|
| Height | u16 | Height of the GUI |
|
|
|
|
| Centered? | bool | Whether or not the GUI is centered on the screen |
|
|
|
|
| Widget defs | Array | List of widget definitions (see LuaGUI::show) |
|
|
|
|
|
|
|
|
#### BlockInvUpdate (clientbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Block X | s32 | Block X coordinate |
|
|
|
|
| Block Y | s32 | Block Y coordinate |
|
|
|
|
| Block Z | s32 | Block Z coordinate |
|
|
|
|
| Inventory | Inventory | Block inventory |
|
|
|
|
|
|
|
|
#### BlockDataUpdate
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| -------------- | ------------- | ----------------------------------------------------- |
|
|
|
|
| Block X | s32 | Block X coordinate |
|
|
|
|
| Block Y | s32 | Block Y coordinate |
|
|
|
|
| Block Z | s32 | Block Z coordinate |
|
|
|
|
| Metadata | BlockMetadata | Block metadata |
|
|
|
|
| Use alt tiles? | bool | Whether or not the block should use alternative tiles |
|
|
|
|
|
|
|
|
#### RegistryData
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| -------------- | ------------- | ----------------------------------------------------- |
|
|
|
|
| Registry | Registry | Registry |
|
|
|
|
|
|
|
|
#### ChatMessage (clientbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| ID | u16 | Player ID (`0` means it's a server message) |
|
|
|
|
| Message | std::string | Message sent by the client |
|
|
|
|
|
|
|
|
#### EntitySpawn
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ------------ | ---------------------------------------------------- |
|
|
|
|
| ID | entt::entity | Entity ID |
|
|
|
|
|
|
|
|
#### EntityDespawn
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ------------ | ---------------------------------------------------- |
|
|
|
|
| ID | entt::entity | Entity ID |
|
|
|
|
|
|
|
|
#### EntityPosition
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ------------ | ---------------------------------------------------- |
|
|
|
|
| ID | entt::entity | Entity ID |
|
|
|
|
| Entity X | double | Entity X coordinate |
|
|
|
|
| Entity Y | double | Entity Y coordinate |
|
|
|
|
| Entity Z | double | Entity Z coordinate |
|
|
|
|
|
|
|
|
#### EntityRotation
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| --------------- | ------------ | ---------------------------------------------------- |
|
|
|
|
| ID | entt::entity | Entity ID |
|
|
|
|
| Rotation | glm::quat4 | Entity rotation quaternion |
|
|
|
|
|
|
|
|
#### EntityAnimation
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ------------------ | ---------------------------------------------------- |
|
|
|
|
| ID | entt::entity | Entity ID |
|
|
|
|
| Animation | AnimationComponent | Entity animation data |
|
|
|
|
|
|
|
|
#### EntityDrawableDef
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ------------------ | ---------------------------------------------------- |
|
|
|
|
| ID | entt::entity | Entity ID |
|
|
|
|
| Drawable def | DrawableDef | Entity drawable component definition |
|
|
|
|
|
|
|
|
### Serverbound
|
|
|
|
|
|
|
|
#### ChunkRequest
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Chunk X | s32 | Chunk X coordinate |
|
|
|
|
| Chunk Y | s32 | Chunk Y coordinate |
|
|
|
|
| Chunk Z | s32 | Chunk Z coordinate |
|
|
|
|
|
|
|
|
#### PlayerPlaceBlock
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Block X | s32 | Block X coordinate |
|
|
|
|
| Block Y | s32 | Block Y coordinate |
|
|
|
|
| Block Z | s32 | Block Z coordinate |
|
|
|
|
| Block ID | u32 | Block ID and data |
|
|
|
|
|
|
|
|
#### PlayerDigBlock
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Block X | s32 | Block X coordinate |
|
|
|
|
| Block Y | s32 | Block Y coordinate |
|
|
|
|
| Block Z | s32 | Block Z coordinate |
|
|
|
|
|
|
|
|
#### PlayerInvUpdate (serverbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Inventory | Inventory | Player inventory |
|
|
|
|
|
|
|
|
#### PlayerPosUpdate (serverbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Player X | double | Player X coordinate |
|
|
|
|
| Player Y | double | Player Y coordinate |
|
|
|
|
| Player Z | double | Player Z coordinate |
|
|
|
|
|
|
|
|
#### PlayerRotUpdate
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Camera Yaw | float | Horizontal camera view angle |
|
|
|
|
| Camera Pitch | float | Vertical camera view angle |
|
|
|
|
|
|
|
|
#### PlayerHeldItemChanged
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Hotbar slot | u8 | ID of the current hotbar slot |
|
|
|
|
| Item ID | u16 | Current item ID (to check match with server) |
|
|
|
|
|
2020-12-29 05:38:06 +01:00
|
|
|
#### PlayerReady
|
|
|
|
|
|
|
|
Packet sent from a client when it is ready to receive chunks.
|
|
|
|
|
|
|
|
_This packet has no field._
|
|
|
|
|
2021-05-16 19:02:50 +02:00
|
|
|
#### PlayerChunkPosUpdate
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Chunk X | s32 | Chunk X coordinate |
|
|
|
|
| Chunk Y | s32 | Chunk Y coordinate |
|
|
|
|
| Chunk Z | s32 | Chunk Z coordinate |
|
|
|
|
|
2020-06-19 17:18:18 +02:00
|
|
|
#### BlockActivated
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Block X | s32 | Block X coordinate |
|
|
|
|
| Block Y | s32 | Block Y coordinate |
|
|
|
|
| Block Z | s32 | Block Z coordinate |
|
|
|
|
| Screen width | u16 | Client screen width |
|
|
|
|
| Screen height | u16 | Client screen height |
|
|
|
|
| GUI scale | u8 | Client GUI scale |
|
|
|
|
|
|
|
|
#### BlockInvUpdate (serverbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Block X | s32 | Block X coordinate |
|
|
|
|
| Block Y | s32 | Block Y coordinate |
|
|
|
|
| Block Z | s32 | Block Z coordinate |
|
|
|
|
| Inventory | Inventory | Block inventory |
|
|
|
|
|
2020-07-05 20:55:23 +02:00
|
|
|
#### ItemActivated
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Block X | s32 | Selected block X coordinate |
|
|
|
|
| Block Y | s32 | Selected block Y coordinate |
|
|
|
|
| Block Z | s32 | Selected block Z coordinate |
|
|
|
|
| Screen width | u16 | Client screen width |
|
|
|
|
| Screen height | u16 | Client screen height |
|
|
|
|
| GUI scale | u8 | Client GUI scale |
|
|
|
|
|
2020-06-19 17:18:18 +02:00
|
|
|
#### ChatMessage (serverbound)
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Message | std::string | Message sent by the client |
|
|
|
|
|
|
|
|
#### KeyPressed
|
|
|
|
|
|
|
|
| Field name | Field type | Notes |
|
|
|
|
| ------------- | ----------- | ---------------------------------------------------- |
|
|
|
|
| Key ID | u16 | Key ID in the registry |
|
|
|
|
| Screen width | u16 | Client screen width |
|
|
|
|
| Screen height | u16 | Client screen height |
|
|
|
|
| GUI scale | u8 | Client GUI scale |
|
|
|
|
|