0
0
mirror of https://github.com/pmmp/BedrockProtocol.git synced 2024-09-22 01:31:31 +00:00
An implementation of the Minecraft: Bedrock Edition protocol in PHP
Go to file
Vega Nicholas S. 440c8078c6
CameraTargetInstruction: Use little-endian long for ActorUniqueId (#271)
thanks for the consistency mojang... :/
Co-authored-by: IvanCraft623 <ivancraft623@gmail.com>
2024-09-18 15:58:42 -05:00
.github Bump shivammathur/setup-php from 2.30.4 to 2.31.1 (#253) 2024-08-06 15:12:59 +00:00
.idea Make PhpStorm styles consistent with php-cs-fixer 2021-11-08 16:26:25 +00:00
src CameraTargetInstruction: Use little-endian long for ActorUniqueId (#271) 2024-09-18 15:58:42 -05:00
tests Fix CS in tests 2024-02-26 16:18:34 +00:00
tools Allow any static function to have a @generate-create-func tag 2024-08-13 17:20:20 +01:00
.editorconfig new repo who dis 2021-07-14 15:23:03 +01:00
.gitattributes new repo who dis 2021-07-14 15:23:03 +01:00
.gitignore added .php-cs-fixer.cache to gitignore 2021-11-01 23:23:42 +00:00
.php-cs-fixer.php Run CS fixer on tools directory 2024-03-13 14:34:51 +00:00
composer.json Update phpstan/phpstan requirement from 1.11.7 to 1.11.9 (#254) 2024-08-06 15:12:00 +00:00
LICENSE new repo who dis 2021-07-14 15:23:03 +01:00
phpstan.neon.dist Protocol changes for 1.19.10 2022-07-13 00:47:47 +01:00
README.md Update outdated PacketBatch documentation. (#249) 2024-07-14 19:27:58 +01:00

BedrockProtocol

CI

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.