Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pmmp/BedrockProtocol
An implementation of the Minecraft: Bedrock Edition protocol in PHP
https://github.com/pmmp/BedrockProtocol
github-actions-enabled on-packagist php81 php82 phpstan-l9 phpstan-strict
Last synced: 3 months ago
JSON representation
An implementation of the Minecraft: Bedrock Edition protocol in PHP
- Host: GitHub
- URL: https://github.com/pmmp/BedrockProtocol
- Owner: pmmp
- License: lgpl-3.0
- Created: 2021-07-14T13:55:58.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-13T10:26:07.000Z (6 months ago)
- Last Synced: 2024-05-17T23:42:35.176Z (6 months ago)
- Topics: github-actions-enabled, on-packagist, php81, php82, phpstan-l9, phpstan-strict
- Language: PHP
- Homepage:
- Size: 1.42 MB
- Stars: 123
- Watchers: 14
- Forks: 77
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-minecraft-bedrock - BedrockProtocol - An implementation of the Minecraft: Bedrock Edition protocol in PHP (Library)
README
# BedrockProtocol
[![CI](https://github.com/pmmp/BedrockProtocol/actions/workflows/ci.yml/badge.svg)](https://github.com/pmmp/BedrockProtocol/actions/workflows/ci.yml)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:```php
foreach(PacketBatch::decodePackets(new BinaryStream($payload), PacketPool::getInstance()) as $packetObject){
var_dump($packetObject); //tada
}
```## Encoding packets
This is easy:```php
/** @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.