pocketmine / bedrock-protocol
An implementation of the Minecraft: Bedrock Edition protocol in PHP
Installs: 316 734
Dependents: 9
Suggesters: 0
Security: 1
Stars: 139
Watchers: 16
Forks: 97
Open Issues: 8
Requires
- php: ^8.1
- ext-json: *
- pocketmine/binaryutils: ^0.2.0
- pocketmine/color: ^0.2.0 || ^0.3.0
- pocketmine/math: ^0.3.0 || ^0.4.0 || ^1.0.0
- pocketmine/nbt: ^1.0.0
- ramsey/uuid: ^4.1
Requires (Dev)
- phpstan/phpstan: 1.11.9
- phpstan/phpstan-phpunit: ^1.0.0
- phpstan/phpstan-strict-rules: ^1.0.0
- phpunit/phpunit: ^9.5 || ^10.0
- dev-master
- 35.0.0+bedrock-1.21.50
- 34.0.0+bedrock-1.21.30
- 33.0.0+bedrock-1.21.20
- 32.2.0+bedrock-1.21.2
- 32.1.0+bedrock-1.21.2
- 32.0.0+bedrock-1.21.2
- 31.0.0+bedrock-1.21.0
- 30.0.0+bedrock-1.20.80
- 29.0.0+bedrock-1.20.70
- 28.0.1+bedrock-1.20.60
- 28.0.0+bedrock-1.20.60
- 27.0.2+bedrock-1.20.60
- 27.0.1+bedrock-1.20.60
- 27.0.0+bedrock-1.20.60
- 26.0.0+bedrock-1.20.50
- 25.0.0+bedrock-1.20.40
- 24.0.0+bedrock-1.20.30
- 23.0.4+bedrock-1.20.10
- 23.0.3+bedrock-1.20.10
- 23.0.2+bedrock-1.20.10
- 23.0.1+bedrock-1.20.10
- 23.0.0+bedrock-1.20.10
- 22.0.0+bedrock-1.20.0
- 21.0.1+bedrock-1.19.80
- 21.0.0+bedrock-1.19.80
- 20.1.2+bedrock-1.19.70
- 20.1.1+bedrock-1.19.70
- 20.1.0+bedrock-1.19.70
- 20.0.0+bedrock-1.19.70
- 19.3.0+bedrock-1.19.62
- 19.2.0+bedrock-1.19.62
- 19.1.0+bedrock-1.19.60
- 19.0.0+bedrock-1.19.60
- 18.2.0+bedrock-1.19.50
- 18.1.0+bedrock-1.19.50
- 18.0.0+bedrock-1.19.50
- 17.1.0+bedrock-1.19.50
- 17.0.0+bedrock-1.19.50
- 16.0.0+bedrock-1.19.40
- 15.0.0+bedrock-1.19.40
- 14.0.0+bedrock-1.19.40
- 13.0.0+bedrock-1.19.30
- 12.2.0+bedrock-1.19.21
- 12.1.0+bedrock-1.19.20
- 12.0.0+bedrock-1.19.20
- 11.0.4+bedrock-1.19.10
- 11.0.3+bedrock-1.19.10
- 11.0.2+bedrock-1.19.10
- 11.0.1+bedrock-1.19.10
- 11.0.0+bedrock-1.19.10
- 10.0.1+bedrock-1.19.0
- 10.0.0+bedrock-1.19.0
- 9.0.2+bedrock-1.18.30
- 9.0.1+bedrock-1.18.30
- 9.0.0+bedrock-1.18.30
- 8.0.2+bedrock-1.18.10
- 8.0.1+bedrock-1.18.10
- 8.0.0+bedrock-1.18.10
- 7.3.1+bedrock-1.18.0
- 7.3.0+bedrock-1.18.0
- 7.2.0+bedrock-1.18.0
- 7.1.0+bedrock-1.18.0
- 7.0.0+bedrock-1.18.0
- 6.0.0+bedrock-1.17.40
- 5.1.3+bedrock-1.17.40
- 5.1.2+bedrock-1.17.40
- 5.1.1+bedrock-1.17.40
- 5.1.0+bedrock-1.17.40
- 5.0.0+bedrock-1.17.40
- 4.0.1+bedrock-1.17.40
- 4.0.0+bedrock-1.17.40
- 3.0.2+bedrock-1.17.40
- 3.0.1+bedrock-1.17.40
- 3.0.0+bedrock-1.17.40
- 2.0.0+bedrock-1.17.30
- 1.1.0+bedrock-1.17.10
- 1.0.0+bedrock-1.17.10
- dev-bedrock-1.21.50
This package is auto-updated.
Last update: 2024-12-05 08:29:10 UTC
README
An implementation of the Minecraft: Bedrock Edition protocol in PHP
This library implements all of the packets in the Minecraft: Bedrock Edition protocol, as well as a few extra things needed to support them. However, at the time of writing, it does not include the following:
- Anything related to JWT handling/verification
- Anything related to encryption
- Anything related to compression
Decoding packets
Assuming you've decrypted and decompressed a Minecraft packet successfully, you're next going to want to decode it.
With this library, that's currently done using PacketBatch
, like so:
foreach(PacketBatch::decodePackets(new BinaryStream($payload), PacketPool::getInstance()) as $packetObject){ var_dump($packetObject); //tada }
Encoding packets
This is easy:
/** @var Packet[] $packets */ $stream = new BinaryStream(); PacketBatch::encodePackets($stream, $packets); $batchPayload = $stream->getBuffer();
Footnotes
This library is a little rough around the edges, since it's only ever been intended for PocketMine-MP usage. It's only recently that this mess has been separated from the core to allow it to be used by other things. This means that API changes might be in order, and your feedback would be nice to drive them. If you want to improve BedrockProtocol, please open issues with suggestions, or better, make pull requests.