pocketmine / bedrock-protocol
Minecraft: Bedrock Edition 协议的 PHP 实现
34.0.0+bedrock-1.21.30
2024-09-18 20:58 UTC
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
- 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-dependabot/composer/phpstan/phpstan-1.12.3
- dev-next-major
This package is auto-updated.
Last update: 2024-09-18 21:02:21 UTC
README
Minecraft: Bedrock Edition 协议的 PHP 实现
此库实现了Minecraft: Bedrock Edition 协议中的所有数据包,以及一些额外的东西来支持它们。然而,在撰写本文时,它不包括以下内容
- 与JWT处理/验证相关的任何内容
- 与加密相关的任何内容
- 与压缩相关的任何内容
解码数据包
假设你已经成功地解密并解压缩了一个Minecraft数据包,接下来你想要对其进行解码。使用此库,目前是通过PacketBatch
来完成的,如下所示
foreach(PacketBatch::decodePackets(new BinaryStream($payload), PacketPool::getInstance()) as $packetObject){ var_dump($packetObject); //tada }
编码数据包
这很简单
/** @var Packet[] $packets */ $stream = new BinaryStream(); PacketBatch::encodePackets($stream, $packets); $batchPayload = $stream->getBuffer();
脚注
由于此库仅打算用于PocketMine-MP,因此边缘处理略显粗糙。直到最近,这个混乱才从核心中分离出来,以便其他东西可以使用它。这意味着可能需要API更改,并且您的反馈将有助于推动这些更改。如果您想改进BedrockProtocol,请提出建议,或者更好的是,提交拉取请求。