A Minecraft Bedrock server implementation in Elixir. This is experimental and is not a fully featured minecraft server (yet). Use at your own risk.
If available in Hex, the package can be installed
by adding bedrock_server
to your list of dependencies in mix.exs
:
def deps do
[
{:bedrock_server, "~> 0.1.0"}
]
end
- ipv6
Start an iex session with:
iex -S mix
Elixir <<>> types: https://hexdocs.pm/elixir/1.12/Kernel.SpecialForms.html#%3C%3C%3E%3E/1
Packet ID | Field Name | Field Type | Notes | ||
---|---|---|---|---|---|
0x80..0x8d | Sequence number | uint24le | |||
Frames | Flags | byte | Top 3 bits are reliability type, fourth bit is 1 when the frame is fragmented and part of a compound. | ||
Length IN BITS | unsigned short | Length of the body in bits. | |||
Reliable frame index | uint24le | only if reliable | |||
Sequenced frame index | uint24le | only if sequenced | |||
Order | Ordered frame index | uint24le | only if ordered | ||
Order channel | byte | ||||
Fragment | Compound size | int | only if fragmented | ||
Compound ID | short | ||||
Index | int | ||||
Body | ceil(length/8) bytes |
- C -> S: Open Connection Request 1
- S -> C: Open Connection Reply 1
- C -> S: Open Connection Request 2
- S -> C: Open Connection Reply 2
Once the handshake is established, messages will be contained in a Frame Set Packet.
- C -> S: Connection Request
- S -> C: Connection Request Accepted
- C -> S: New Incoming Connection
All following packets will be Game Packets.
Name | Size | Desc |
---|---|---|
addr | 7 | |
int8 | 1 | Signed 8-bit integer |
int16 | 2 | Signed 16-bit integer |
int24 | 3 | Signed 24-bit integer |
int64 | 4 | Signed 64-bit integer |
MAGIC | 16 | 0x00ffff00fefefefefdfdfdfd12345678 This is hardcoded in the RakNet source |
Clients start by sending this packet to the server on port 19132 repeatedly for server discovery. Once the client has established a connection, it will send connected pings instead.
This packet should be replied to with an unconnected pong.
Field | Type | Notes |
---|---|---|
Ping ID | i64 | Time since start in milliseconds |
MAGIC | MAGIC |
Same as 0x01
, except for that it should only be replied to if there are any open
connections to the server.
Field | Type | Notes |
---|---|---|
Time | i64 | |
Server GUID | i64 | |
MAGIC | MAGIC | |
Server ID | string | This is used for the MOTD |
Server ID string format
The server id is seperated by semicolons and uses the following fields in order. Again,
joined by a semicolon.
Field | Desc |
---|---|
Edition | MCPE (Bedrock), MCEE (Education Edition) |
MOTD Line 1 | Server MOTD |
Protocol | The protocol version number |
Version | The minecraft version number |
Player Count | The number of connected players |
Player Limit | The maximum number of players the server supports |
Server ID | todo |
MOTD Line 2 | Server MOTD |
Gamemode | The game mode string representation (seems unused) |
Gamemode ID | The game mode number representation (seems unused) |
IPv4 Port | |
IPv6 Port |
This packet should be replied to with a connected pong.
Field | Type | Notes |
---|---|---|
Time | i64 | The ping time |
Field | Type | Notes |
---|---|---|
Ping Time | i64 | |
Ping Time | i64 |
The client will send this packet with decreasing MTU until the server responds. This is done to discover the MTU size for the connection.
This packet should be replied to with Open Connection Reply 1 with the MTU size of the amount of padding you received in bytes plus 46. (improve) (28 udp overhead, 1 packet id, 16 magic, 1 protocol version)
Field | Type | Notes |
---|---|---|
MAGIC | MAGIC | |
Protocol Version | i8 | Currently 11 |
MTU | Zero padding | Padding used to detect the maximum MTU size |
Field | Type | Notes |
---|---|---|
MAGIC | MAGIC | |
Server GUID | i64 | |
Use Security | boolean | This must be false |
MTU | i16 | See Open Connection Request 1 |
This packet should be replied to with Open Connection Reply 2.
Field | Type | Notes |
---|---|---|
MAGIC | MAGIC | |
Server Address | address | |
MTU | i16 | See Open Connection Request 1 |
Field | Type | Notes |
---|---|---|
MAGIC | MAGIC | |
Server GUID | i64 | |
MTU | i16 | See Open Connection Request 1 |
Use Encryption | boolean | Not sure what this does |
This packet should be replied to with Connection Request Accepted.
Field | Type |
---|---|
GUID | i64 |
Time | i64 |
Field | Type | Notes |
---|---|---|
Client address | ip | |
System index | int8 | Unknown what this does. |
Internal IDs | ip*10 | Unknown what these do. Empty ipts for all of them works. |
Request time | int64 | |
Time | int64 |
Field | Type | Notes |
---|---|---|
Server address | ip | |
Internal address | int8 | Unknown what this does. |
This packet is empty.