From df7a1fcba63bb19df8a8a08dd5b4295dabfddca8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 9 Aug 2022 19:06:05 +0100 Subject: [PATCH] Changes for 1.19.20 --- composer.json | 4 +-- composer.lock | 26 +++++++++---------- src/entity/Entity.php | 2 +- src/network/mcpe/ChunkRequestTask.php | 3 ++- src/network/mcpe/NetworkSession.php | 4 +-- .../mcpe/handler/InGamePacketHandler.php | 9 ++++++- .../mcpe/handler/PreSpawnPacketHandler.php | 3 ++- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 4e011f884..5334687cf 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,8 @@ "adhocore/json-comment": "^1.1", "fgrosse/phpasn1": "^2.3", "netresearch/jsonmapper": "^4.0", - "pocketmine/bedrock-data": "~1.9.0+bedrock-1.19.10", - "pocketmine/bedrock-protocol": "~11.0.0+bedrock-1.19.10", + "pocketmine/bedrock-data": "~1.10.0+bedrock-1.19.20", + "pocketmine/bedrock-protocol": "~12.0.0+bedrock-1.19.20", "pocketmine/binaryutils": "^0.2.1", "pocketmine/callback-validator": "^1.0.2", "pocketmine/classloader": "^0.2.0", diff --git a/composer.lock b/composer.lock index 5b65af9f7..34cce5d63 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "f9d81230e16fff707deb5cbe7ff37376", + "content-hash": "80afa24adf37096a23643e051d6128ce", "packages": [ { "name": "adhocore/json-comment", @@ -245,16 +245,16 @@ }, { "name": "pocketmine/bedrock-data", - "version": "1.9.0+bedrock-1.19.10", + "version": "1.10.0+bedrock-1.19.20", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockData.git", - "reference": "ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1" + "reference": "43610f6749f22d15ede6b60ed5402bdeff47453e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1", - "reference": "ecd798a3e7ead50b7da73141bbb0c4ba14dd76a1", + "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/43610f6749f22d15ede6b60ed5402bdeff47453e", + "reference": "43610f6749f22d15ede6b60ed5402bdeff47453e", "shasum": "" }, "type": "library", @@ -265,22 +265,22 @@ "description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP", "support": { "issues": "https://github.com/pmmp/BedrockData/issues", - "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.19.10" + "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.19.20" }, - "time": "2022-07-12T19:33:21+00:00" + "time": "2022-08-09T17:44:22+00:00" }, { "name": "pocketmine/bedrock-protocol", - "version": "11.0.4+bedrock-1.19.10", + "version": "12.0.0+bedrock-1.19.20", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockProtocol.git", - "reference": "1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab" + "reference": "c2778039544fa0c7c5bd3af7963149e7552f4215" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab", - "reference": "1c87aa1187bc7a31b4fc3e1c0f3e22251c2e6eab", + "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/c2778039544fa0c7c5bd3af7963149e7552f4215", + "reference": "c2778039544fa0c7c5bd3af7963149e7552f4215", "shasum": "" }, "require": { @@ -312,9 +312,9 @@ "description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP", "support": { "issues": "https://github.com/pmmp/BedrockProtocol/issues", - "source": "https://github.com/pmmp/BedrockProtocol/tree/11.0.4+bedrock-1.19.10" + "source": "https://github.com/pmmp/BedrockProtocol/tree/bedrock-1.19.20" }, - "time": "2022-07-24T19:22:18+00:00" + "time": "2022-08-09T17:57:29+00:00" }, { "name": "pocketmine/binaryutils", diff --git a/src/entity/Entity.php b/src/entity/Entity.php index 40382c564..54873f9f1 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1466,7 +1466,7 @@ abstract class Entity{ $this->location->yaw, //TODO: head yaw $this->location->yaw, //TODO: body yaw (wtf mojang?) array_map(function(Attribute $attr) : NetworkAttribute{ - return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue()); + return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue(), []); }, $this->attributeMap->getAll()), $this->getAllNetworkData(), [] //TODO: entity links diff --git a/src/network/mcpe/ChunkRequestTask.php b/src/network/mcpe/ChunkRequestTask.php index 1be39e978..f66614099 100644 --- a/src/network/mcpe/ChunkRequestTask.php +++ b/src/network/mcpe/ChunkRequestTask.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\convert\RuntimeBlockMapping; use pocketmine\network\mcpe\protocol\LevelChunkPacket; use pocketmine\network\mcpe\protocol\serializer\PacketBatch; use pocketmine\network\mcpe\protocol\serializer\PacketSerializerContext; +use pocketmine\network\mcpe\protocol\types\ChunkPosition; use pocketmine\network\mcpe\serializer\ChunkSerializer; use pocketmine\scheduler\AsyncTask; use pocketmine\world\format\Chunk; @@ -71,7 +72,7 @@ class ChunkRequestTask extends AsyncTask{ $subCount = ChunkSerializer::getSubChunkCount($chunk) + ChunkSerializer::LOWER_PADDING_SIZE; $encoderContext = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary()); $payload = ChunkSerializer::serializeFullChunk($chunk, RuntimeBlockMapping::getInstance(), $encoderContext, $this->tiles); - $this->setResult($this->compressor->compress(PacketBatch::fromPackets($encoderContext, LevelChunkPacket::create($this->chunkX, $this->chunkZ, $subCount, false, null, $payload))->getBuffer())); + $this->setResult($this->compressor->compress(PacketBatch::fromPackets($encoderContext, LevelChunkPacket::create(new ChunkPosition($this->chunkX, $this->chunkZ), $subCount, false, null, $payload))->getBuffer())); } public function onError() : void{ diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index 9fde7ed23..da0a1c26a 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -756,7 +756,7 @@ class NetworkSession{ } public function syncViewAreaCenterPoint(Vector3 $newPos, int $viewDistance) : void{ - $this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create(BlockPosition::fromVector3($newPos), $viewDistance * 16)); //blocks, not chunks >.> + $this->sendDataPacket(NetworkChunkPublisherUpdatePacket::create(BlockPosition::fromVector3($newPos), $viewDistance * 16, [])); //blocks, not chunks >.> } public function syncPlayerSpawnPoint(Position $newSpawn) : void{ @@ -834,7 +834,7 @@ class NetworkSession{ public function syncAttributes(Living $entity, array $attributes) : void{ if(count($attributes) > 0){ $this->sendDataPacket(UpdateAttributesPacket::create($entity->getId(), array_map(function(Attribute $attr) : NetworkAttribute{ - return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue()); + return new NetworkAttribute($attr->getId(), $attr->getMinValue(), $attr->getMaxValue(), $attr->getValue(), $attr->getDefaultValue(), []); }, $attributes), 0)); } } diff --git a/src/network/mcpe/handler/InGamePacketHandler.php b/src/network/mcpe/handler/InGamePacketHandler.php index 6cf39609e..af38ac0f6 100644 --- a/src/network/mcpe/handler/InGamePacketHandler.php +++ b/src/network/mcpe/handler/InGamePacketHandler.php @@ -890,7 +890,14 @@ class InGamePacketHandler extends PacketHandler{ } public function handleModalFormResponse(ModalFormResponsePacket $packet) : bool{ - return $this->player->onFormSubmit($packet->formId, self::stupid_json_decode($packet->formData, true)); + if($packet->cancelReason !== null){ + //TODO: make APIs for this to allow plugins to use this information + return $this->player->onFormSubmit($packet->formId, null); + }elseif($packet->formData !== null){ + return $this->player->onFormSubmit($packet->formId, self::stupid_json_decode($packet->formData, true)); + }else{ + throw new PacketHandlingException("Expected either formData or cancelReason to be set in ModalFormResponsePacket"); + } } /** diff --git a/src/network/mcpe/handler/PreSpawnPacketHandler.php b/src/network/mcpe/handler/PreSpawnPacketHandler.php index 5237cdb4d..f9ff35808 100644 --- a/src/network/mcpe/handler/PreSpawnPacketHandler.php +++ b/src/network/mcpe/handler/PreSpawnPacketHandler.php @@ -98,9 +98,10 @@ class PreSpawnPacketHandler extends PacketHandler{ false, sprintf("%s %s", VersionInfo::NAME, VersionInfo::VERSION()->getFullVersion(true)), Uuid::fromString(Uuid::NIL), + false, [], 0, - GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries() + GlobalItemTypeDictionary::getInstance()->getDictionary()->getEntries(), )); $this->session->sendDataPacket(StaticPacketCache::getInstance()->getAvailableActorIdentifiers());