Skip to content

A Minecraft Bedrock server implementation in Elixir.

Notifications You must be signed in to change notification settings

hbackman/bedrock-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bedrock Server

A Minecraft Bedrock server implementation in Elixir. This is experimental and is not a fully featured minecraft server (yet). Use at your own risk.

Installation

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

Todo

  • ipv6

Notes

Start an iex session with:

iex -S mix

Elixir <<>> types: https://hexdocs.pm/elixir/1.12/Kernel.SpecialForms.html#%3C%3C%3E%3E/1

RakNet

Reliability

Frame Set Packet

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

Handshake

  1. C -> S: Open Connection Request 1
  2. S -> C: Open Connection Reply 1
  3. C -> S: Open Connection Request 2
  4. S -> C: Open Connection Reply 2

Once the handshake is established, messages will be contained in a Frame Set Packet.

  1. C -> S: Connection Request
  2. S -> C: Connection Request Accepted
  3. C -> S: New Incoming Connection

All following packets will be Game Packets.

Types

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

Packets

Unconnected Ping 0x01

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

Unconnected Ping 0x02

Same as 0x01, except for that it should only be replied to if there are any open connections to the server.

Unconnected Pong 0x1c

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

Connected Ping 0x00

This packet should be replied to with a connected pong.

Field Type Notes
Time i64 The ping time

Connected Pong 0x03

Field Type Notes
Ping Time i64
Ping Time i64

Open Connection Request 1 0x05

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

Open Connection Reply 1 0x06

Field Type Notes
MAGIC MAGIC
Server GUID i64
Use Security boolean This must be false
MTU i16 See Open Connection Request 1

Open Connection Request 2 0x07

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

Open Connection Reply 2 0x08

Field Type Notes
MAGIC MAGIC
Server GUID i64
MTU i16 See Open Connection Request 1
Use Encryption boolean Not sure what this does

Connection Request 0x09

This packet should be replied to with Connection Request Accepted.

Field Type
GUID i64
Time i64

Connection Request Accepted 0x10

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

New Incoming Connection 0x13

Field Type Notes
Server address ip
Internal address int8 Unknown what this does.

Disconnect 0x15

This packet is empty.

About

A Minecraft Bedrock server implementation in Elixir.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages