diff --git a/composer.json b/composer.json index fdc4d75eb1c..7a705bdcbeb 100644 --- a/composer.json +++ b/composer.json @@ -33,10 +33,10 @@ "composer-runtime-api": "^2.0", "adhocore/json-comment": "~1.2.0", "fgrosse/phpasn1": "~2.5.0", - "pocketmine/bedrock-block-upgrade-schema": "~4.2.0+bedrock-1.21.0", - "pocketmine/bedrock-data": "~2.11.0+bedrock-1.21.0", - "pocketmine/bedrock-item-upgrade-schema": "~1.10.0+bedrock-1.21.0", - "pocketmine/bedrock-protocol": "~31.0.0+bedrock-1.21.0", + "pocketmine/bedrock-block-upgrade-schema": "~4.3.0+bedrock-1.21.20", + "pocketmine/bedrock-data": "~2.12.0+bedrock-1.21.20", + "pocketmine/bedrock-item-upgrade-schema": "~1.11.0+bedrock-1.21.20", + "pocketmine/bedrock-protocol": "~33.0.0+bedrock-1.21.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 cff05b65086..6a92aa5fa3e 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": "9ff582c727a0315b9d0ca0a0ce3f813a", + "content-hash": "92b121901393f0715c1480b2f01e7f04", "packages": [ { "name": "adhocore/json-comment", @@ -203,16 +203,16 @@ }, { "name": "pocketmine/bedrock-block-upgrade-schema", - "version": "4.2.0", + "version": "4.3.0", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockBlockUpgradeSchema.git", - "reference": "8a327197b3b462fa282f40f76b070ffe585a25d2" + "reference": "53d3a41c37ce90d58b33130cdadad08e442d7c47" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/8a327197b3b462fa282f40f76b070ffe585a25d2", - "reference": "8a327197b3b462fa282f40f76b070ffe585a25d2", + "url": "https://api.github.com/repos/pmmp/BedrockBlockUpgradeSchema/zipball/53d3a41c37ce90d58b33130cdadad08e442d7c47", + "reference": "53d3a41c37ce90d58b33130cdadad08e442d7c47", "shasum": "" }, "type": "library", @@ -223,22 +223,22 @@ "description": "Schemas describing how to upgrade saved block data in older Minecraft: Bedrock Edition world saves", "support": { "issues": "https://github.com/pmmp/BedrockBlockUpgradeSchema/issues", - "source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/4.2.0" + "source": "https://github.com/pmmp/BedrockBlockUpgradeSchema/tree/4.3.0" }, - "time": "2024-06-13T17:28:26+00:00" + "time": "2024-08-13T18:04:27+00:00" }, { "name": "pocketmine/bedrock-data", - "version": "2.11.0+bedrock-1.21.0", + "version": "2.12.0+bedrock-1.21.20", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockData.git", - "reference": "cae40bde98081b388c4d3ab59d45b8d1cf5d8761" + "reference": "d4ee3d08964fa16fbbdd04af1fb52bbde540b665" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/cae40bde98081b388c4d3ab59d45b8d1cf5d8761", - "reference": "cae40bde98081b388c4d3ab59d45b8d1cf5d8761", + "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/d4ee3d08964fa16fbbdd04af1fb52bbde540b665", + "reference": "d4ee3d08964fa16fbbdd04af1fb52bbde540b665", "shasum": "" }, "type": "library", @@ -249,22 +249,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.21.0" + "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.21.20" }, - "time": "2024-06-13T17:17:55+00:00" + "time": "2024-08-15T12:50:26+00:00" }, { "name": "pocketmine/bedrock-item-upgrade-schema", - "version": "1.10.0", + "version": "1.11.0", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockItemUpgradeSchema.git", - "reference": "b4687afa19f91eacebd46c40d487f4cc515be504" + "reference": "35c18d093fc2b12da8737b2edb2c3ad6a14a53dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockItemUpgradeSchema/zipball/b4687afa19f91eacebd46c40d487f4cc515be504", - "reference": "b4687afa19f91eacebd46c40d487f4cc515be504", + "url": "https://api.github.com/repos/pmmp/BedrockItemUpgradeSchema/zipball/35c18d093fc2b12da8737b2edb2c3ad6a14a53dd", + "reference": "35c18d093fc2b12da8737b2edb2c3ad6a14a53dd", "shasum": "" }, "type": "library", @@ -275,22 +275,22 @@ "description": "JSON schemas for upgrading items found in older Minecraft: Bedrock world saves", "support": { "issues": "https://github.com/pmmp/BedrockItemUpgradeSchema/issues", - "source": "https://github.com/pmmp/BedrockItemUpgradeSchema/tree/1.10.0" + "source": "https://github.com/pmmp/BedrockItemUpgradeSchema/tree/1.11.0" }, - "time": "2024-05-15T15:15:55+00:00" + "time": "2024-08-13T18:06:25+00:00" }, { "name": "pocketmine/bedrock-protocol", - "version": "31.0.0+bedrock-1.21.0", + "version": "33.0.0+bedrock-1.21.20", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockProtocol.git", - "reference": "972373b6b8068963649f0a95163424eb5b645e29" + "reference": "e2264137c5cd0522de2c6ee4921a3a803818ea32" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/972373b6b8068963649f0a95163424eb5b645e29", - "reference": "972373b6b8068963649f0a95163424eb5b645e29", + "url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/e2264137c5cd0522de2c6ee4921a3a803818ea32", + "reference": "e2264137c5cd0522de2c6ee4921a3a803818ea32", "shasum": "" }, "require": { @@ -303,7 +303,7 @@ "ramsey/uuid": "^4.1" }, "require-dev": { - "phpstan/phpstan": "1.11.2", + "phpstan/phpstan": "1.11.9", "phpstan/phpstan-phpunit": "^1.0.0", "phpstan/phpstan-strict-rules": "^1.0.0", "phpunit/phpunit": "^9.5 || ^10.0" @@ -321,9 +321,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/31.0.0+bedrock-1.21.0" + "source": "https://github.com/pmmp/BedrockProtocol/tree/33.0.0+bedrock-1.21.20" }, - "time": "2024-06-13T17:34:14+00:00" + "time": "2024-08-15T23:07:53+00:00" }, { "name": "pocketmine/binaryutils", @@ -3333,5 +3333,5 @@ "platform-overrides": { "php": "8.1.0" }, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 5c484e8f4ec..67520fa7e6c 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,7 +31,7 @@ final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "4.30.0"; + public const BASE_VERSION = "4.31.1"; public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; diff --git a/src/network/mcpe/InventoryManager.php b/src/network/mcpe/InventoryManager.php index 2a0252b9d94..cff32affe33 100644 --- a/src/network/mcpe/InventoryManager.php +++ b/src/network/mcpe/InventoryManager.php @@ -451,14 +451,16 @@ private function sendInventorySlotPackets(int $windowId, int $netSlot, ItemStack $this->session->sendDataPacket(InventorySlotPacket::create( $windowId, $netSlot, - new ItemStackWrapper(0, ItemStack::null()) + new ItemStackWrapper(0, ItemStack::null()), + 0 )); } //now send the real contents $this->session->sendDataPacket(InventorySlotPacket::create( $windowId, $netSlot, - $itemStackWrapper + $itemStackWrapper, + 0 )); } @@ -476,10 +478,11 @@ private function sendInventoryContentPackets(int $windowId, array $itemStackWrap */ $this->session->sendDataPacket(InventoryContentPacket::create( $windowId, - array_fill_keys(array_keys($itemStackWrappers), new ItemStackWrapper(0, ItemStack::null())) + array_fill_keys(array_keys($itemStackWrappers), new ItemStackWrapper(0, ItemStack::null())), + 0 )); //now send the real contents - $this->session->sendDataPacket(InventoryContentPacket::create($windowId, $itemStackWrappers)); + $this->session->sendDataPacket(InventoryContentPacket::create($windowId, $itemStackWrappers, 0)); } public function syncSlot(Inventory $inventory, int $slot, ItemStack $itemStack) : void{ diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index cb4775d62bd..1eadafaa09b 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -55,6 +55,7 @@ use pocketmine\network\mcpe\handler\SpawnResponsePacketHandler; use pocketmine\network\mcpe\protocol\AvailableCommandsPacket; use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket; +use pocketmine\network\mcpe\protocol\ClientboundCloseFormPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\DisconnectPacket; use pocketmine\network\mcpe\protocol\ModalFormRequestPacket; @@ -632,7 +633,7 @@ private function dispose() : void{ public function disconnect(string $reason, bool $notify = true) : void{ $this->tryDisconnect(function() use ($reason, $notify) : void{ if($notify){ - $this->sendDataPacket(DisconnectPacket::create(0, $reason)); + $this->sendDataPacket(DisconnectPacket::create(0, $reason, "")); } if($this->player !== null){ $this->player->onPostDisconnect($reason, null); @@ -657,7 +658,7 @@ public function transfer(string $ip, int $port, string $reason = "transfer") : v */ public function onPlayerDestroyed(string $reason) : void{ $this->tryDisconnect(function() use ($reason) : void{ - $this->sendDataPacket(DisconnectPacket::create(0, $reason)); + $this->sendDataPacket(DisconnectPacket::create(0, $reason, "")); }, $reason); } @@ -1005,6 +1006,10 @@ public function onFormSent(int $id, Form $form) : bool{ return $this->sendDataPacket(ModalFormRequestPacket::create($id, json_encode($form, JSON_THROW_ON_ERROR))); } + public function onCloseAllForms() : void{ + $this->sendDataPacket(ClientboundCloseFormPacket::create()); + } + /** * Instructs the networksession to start using the chunk at the given coordinates. This may occur asynchronously. * @param \Closure $onCompletion To be called when chunk sending has completed. diff --git a/src/network/mcpe/StandardEntityEventBroadcaster.php b/src/network/mcpe/StandardEntityEventBroadcaster.php index 2b6028f9a69..5adef2d7062 100644 --- a/src/network/mcpe/StandardEntityEventBroadcaster.php +++ b/src/network/mcpe/StandardEntityEventBroadcaster.php @@ -41,6 +41,7 @@ use pocketmine\network\mcpe\protocol\types\entity\Attribute as NetworkAttribute; use pocketmine\network\mcpe\protocol\types\entity\PropertySyncData; use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds; +use pocketmine\network\mcpe\protocol\types\inventory\ItemStack; use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper; use pocketmine\network\mcpe\protocol\UpdateAttributesPacket; use function array_map; @@ -130,7 +131,8 @@ public function onMobArmorChange(array $recipients, Living $mob) : void{ ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getHelmet())), ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getChestplate())), ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getLeggings())), - ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getBoots())) + ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getBoots())), + new ItemStackWrapper(0, ItemStack::null()) )); } diff --git a/src/network/mcpe/handler/ItemStackRequestExecutor.php b/src/network/mcpe/handler/ItemStackRequestExecutor.php index f9532291c36..77649fdc615 100644 --- a/src/network/mcpe/handler/ItemStackRequestExecutor.php +++ b/src/network/mcpe/handler/ItemStackRequestExecutor.php @@ -111,10 +111,10 @@ private function matchItemStack(Inventory $inventory, int $slotId, int $clientIt * @throws ItemStackRequestProcessException */ protected function getBuilderInventoryAndSlot(ItemStackRequestSlotInfo $info) : array{ - [$windowId, $slotId] = ItemStackContainerIdTranslator::translate($info->getContainerId(), $this->inventoryManager->getCurrentWindowId(), $info->getSlotId()); + [$windowId, $slotId] = ItemStackContainerIdTranslator::translate($info->getContainerName()->getContainerId(), $this->inventoryManager->getCurrentWindowId(), $info->getSlotId()); $windowAndSlot = $this->inventoryManager->locateWindowAndSlot($windowId, $slotId); if($windowAndSlot === null){ - throw new ItemStackRequestProcessException("No open inventory matches container UI ID: " . $info->getContainerId() . ", slot ID: " . $info->getSlotId()); + throw new ItemStackRequestProcessException("No open inventory matches container UI ID: " . $info->getContainerName()->getContainerId() . ", slot ID: " . $info->getSlotId()); } [$inventory, $slot] = $windowAndSlot; if(!$inventory->slotExists($slot)){ @@ -141,7 +141,7 @@ protected function transferItems(ItemStackRequestSlotInfo $source, ItemStackRequ * @throws ItemStackRequestProcessException */ protected function removeItemFromSlot(ItemStackRequestSlotInfo $slotInfo, int $count) : Item{ - if($slotInfo->getContainerId() === ContainerUIIds::CREATED_OUTPUT && $slotInfo->getSlotId() === UIInventorySlotOffset::CREATED_ITEM_OUTPUT){ + if($slotInfo->getContainerName()->getContainerId() === ContainerUIIds::CREATED_OUTPUT && $slotInfo->getSlotId() === UIInventorySlotOffset::CREATED_ITEM_OUTPUT){ //special case for the "created item" output slot //TODO: do we need to send a response for this slot info? return $this->takeCreatedItem($count); @@ -381,7 +381,7 @@ public function generateInventoryTransaction() : InventoryTransaction{ public function buildItemStackResponse() : ItemStackResponse{ $builder = new ItemStackResponseBuilder($this->request->getRequestId(), $this->inventoryManager); foreach($this->requestSlotInfos as $requestInfo){ - $builder->addSlot($requestInfo->getContainerId(), $requestInfo->getSlotId()); + $builder->addSlot($requestInfo->getContainerName()->getContainerId(), $requestInfo->getSlotId()); } return $builder->build(); diff --git a/src/network/mcpe/handler/ItemStackResponseBuilder.php b/src/network/mcpe/handler/ItemStackResponseBuilder.php index 09af69f2a3b..a947eae7268 100644 --- a/src/network/mcpe/handler/ItemStackResponseBuilder.php +++ b/src/network/mcpe/handler/ItemStackResponseBuilder.php @@ -27,6 +27,7 @@ use pocketmine\item\Durable; use pocketmine\network\mcpe\InventoryManager; use pocketmine\network\mcpe\protocol\types\inventory\ContainerUIIds; +use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName; use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponse; use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponseContainerInfo; use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponseSlotInfo; @@ -99,7 +100,7 @@ public function build() : ItemStackResponse{ $responseContainerInfos = []; foreach($responseInfosByContainer as $containerInterfaceId => $responseInfos){ - $responseContainerInfos[] = new ItemStackResponseContainerInfo($containerInterfaceId, $responseInfos); + $responseContainerInfos[] = new ItemStackResponseContainerInfo(new FullContainerName($containerInterfaceId, 0), $responseInfos); } return new ItemStackResponse(ItemStackResponse::RESULT_OK, $this->requestId, $responseContainerInfos); diff --git a/src/player/Player.php b/src/player/Player.php index 830ea264a9d..a0ead8f30be 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -2122,6 +2122,13 @@ public function onFormSubmit(int $formId, $responseData) : bool{ return true; } + /** + * Closes the current viewing form and forms in queue. + */ + public function closeAllForms() : void{ + $this->getNetworkSession()->onCloseAllForms(); + } + /** * Transfers a player to another server. *