Difference between revisions of "Pocket Edition Protocol Documentation"

From wiki.vg
Jump to navigation Jump to search
(Fixed datagram header information link)
(Started work on updated packet documentation. I will do more during the weekend.)
Line 1: Line 1:
 
This is the (unofficial) protocol docs for Minecraft: PE. The protocol currently uses UDP for communication, different from PC (TCP). The usual UDP issues are still here (lost packets, wrong order, etc.), but the protocol solves a few of those problems using special packet encapsulation, based on TCP. The Minecraft: PE client uses RakNet for it's networking library. Even though it uses RakNet, you can still write software without the library.
 
This is the (unofficial) protocol docs for Minecraft: PE. The protocol currently uses UDP for communication, different from PC (TCP). The usual UDP issues are still here (lost packets, wrong order, etc.), but the protocol solves a few of those problems using special packet encapsulation, based on TCP. The Minecraft: PE client uses RakNet for it's networking library. Even though it uses RakNet, you can still write software without the library.
 
+
Currently, the game's default port is 19132. It is recommended to use this when possible because processes such as server discovering will not work otherwise.
  
 
== Data Types ==
 
== Data Types ==
Line 22: Line 22:
 
| class="col3" | <code></code>
 
| class="col3" | <code></code>
 
|- class="row3"
 
|- class="row3"
! class="col0 centeralign" | Integer
+
! class="col0 centeralign" | int
 
| class="col1 centeralign" | 4
 
| class="col1 centeralign" | 4
 
| class="col2" | -2147483648 to 2147483647
 
| class="col2" | -2147483648 to 2147483647
 
| class="col3" | <code></code>
 
| class="col3" | <code></code>
 
|- class="row4"
 
|- class="row4"
! class="col0 centeralign" | Long
+
! class="col0 centeralign" | long
 
| class="col1 centeralign" | 8
 
| class="col1 centeralign" | 8
 
| class="col2" |  
 
| class="col2" |  
Line 38: Line 38:
 
|- class="row6"
 
|- class="row6"
 
! class="col0 centeralign" | string
 
! class="col0 centeralign" | string
| class="col1 centeralign" | short + string
+
| class="col1 centeralign" | unsigned short + string
 
| class="col2" | N/A
 
| class="col2" | N/A
 
| class="col3" | Prefixed by a short containing the length of the string in characters. It appears that only the following ASCII characters can be displayed: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 
| class="col3" | Prefixed by a short containing the length of the string in characters. It appears that only the following ASCII characters can be displayed: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
 
|}
 
|}
  
== Reference ==
+
== Packet format ==
 +
All packet's in Minecraft: Pocket Edition start with their ID, which is an unsigned byte. If you are using a language which does not support unsigned types such as Java, you can do (byte & 0xFF) to get the unsigned version.
 +
 
 +
 
 +
== References ==
  
 
RakNet datagram and message header information: http://jenkinssoftware.com/raknet/manual/systemoverview.html
 
RakNet datagram and message header information: http://jenkinssoftware.com/raknet/manual/systemoverview.html

Revision as of 00:46, 6 April 2016

This is the (unofficial) protocol docs for Minecraft: PE. The protocol currently uses UDP for communication, different from PC (TCP). The usual UDP issues are still here (lost packets, wrong order, etc.), but the protocol solves a few of those problems using special packet encapsulation, based on TCP. The Minecraft: PE client uses RakNet for it's networking library. Even though it uses RakNet, you can still write software without the library. Currently, the game's default port is 19132. It is recommended to use this when possible because processes such as server discovering will not work otherwise.

Data Types

Minecraft packets use different data types to communicate with each other. The documented ones are listed below:

Size Range Notes
byte 1 -128 to 127
short 2 -32768 to 32767
int 4 -2147483648 to 2147483647
long 8
MAGIC 16 0x00ffff00fefefefefdfdfdfd12345678 always those hex bytes, corresponding to RakNet's default OFFLINE_MESSAGE_DATA_ID
string unsigned short + string N/A Prefixed by a short containing the length of the string in characters. It appears that only the following ASCII characters can be displayed: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Packet format

All packet's in Minecraft: Pocket Edition start with their ID, which is an unsigned byte. If you are using a language which does not support unsigned types such as Java, you can do (byte & 0xFF) to get the unsigned version.


References

RakNet datagram and message header information: http://jenkinssoftware.com/raknet/manual/systemoverview.html

The latest version of the protocol is not fully documented yet, but all of the packets can be found in the Dragonet server code https://github.com/DragonetMC/Dragonet/tree/master/src/main/java/org/dragonet/net/packet Protocol Version: 23 (MCPE 0.11.0b6)

The older protocol specification(ver <= 0.10.x): There is also an automatically generated specification of many of the packages can be found in the MiNET server code https://github.com/NiclasOlofsson/MiNET/blob/master/src/MiNET/MiNET/Net/MCPE%20Protocol%20Documentation.md

The MiNET wiki also contain development notes around some functionality https://github.com/NiclasOlofsson/MiNET/wiki These will be migrated to this wiki in due time.