From b430f079b3b45c4674a3b1efdd54d833e682a5cf Mon Sep 17 00:00:00 2001 From: Dries C Date: Wed, 14 Aug 2024 02:52:55 +0200 Subject: [PATCH] Add 1.21.2 BC support --- src/ChangeDimensionPacket.php | 8 ++++++-- src/EditorNetworkPacket.php | 8 ++++++-- src/InventoryContentPacket.php | 8 ++++++-- src/InventorySlotPacket.php | 8 ++++++-- src/MobArmorEquipmentPacket.php | 8 ++++++-- src/PlayerArmorDamagePacket.php | 10 +++++++--- src/SetTitlePacket.php | 8 ++++++-- src/StopSoundPacket.php | 8 ++++++-- src/serializer/PacketSerializer.php | 11 ++++++++--- src/types/inventory/FullContainerName.php | 11 ++++++++--- src/types/inventory/UseItemTransactionData.php | 17 +++++++++++++---- .../CraftRecipeAutoStackRequestAction.php | 11 ++++++++--- .../CraftRecipeStackRequestAction.php | 11 ++++++++--- .../CreativeCreateStackRequestAction.php | 11 ++++++++--- .../GrindstoneStackRequestAction.php | 11 ++++++++--- .../inventory/stackrequest/ItemStackRequest.php | 2 ++ .../stackrequest/ItemStackRequestActionType.php | 2 ++ .../resourcepacks/BehaviorPackInfoEntry.php | 11 ++++++++--- .../resourcepacks/ResourcePackInfoEntry.php | 11 ++++++++--- 19 files changed, 130 insertions(+), 45 deletions(-) diff --git a/src/ChangeDimensionPacket.php b/src/ChangeDimensionPacket.php index 6e2cdd34..44ab0a56 100644 --- a/src/ChangeDimensionPacket.php +++ b/src/ChangeDimensionPacket.php @@ -41,14 +41,18 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->dimension = $in->getVarInt(); $this->position = $in->getVector3(); $this->respawn = $in->getBool(); - $this->loadingScreenId = $in->readOptional(fn() => $in->getLInt()); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->loadingScreenId = $in->readOptional(fn() => $in->getLInt()); + } } protected function encodePayload(PacketSerializer $out) : void{ $out->putVarInt($this->dimension); $out->putVector3($this->position); $out->putBool($this->respawn); - $out->writeOptional($this->loadingScreenId, $out->putLInt(...)); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->writeOptional($this->loadingScreenId, $out->putLInt(...)); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/EditorNetworkPacket.php b/src/EditorNetworkPacket.php index 17bd81d6..6cf8d32a 100644 --- a/src/EditorNetworkPacket.php +++ b/src/EditorNetworkPacket.php @@ -44,12 +44,16 @@ public function getPayload() : CacheableNbt{ return $this->payload; } public function isRouteToManager() : bool{ return $this->isRouteToManager; } protected function decodePayload(PacketSerializer $in) : void{ - $this->isRouteToManager = $in->getBool(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->isRouteToManager = $in->getBool(); + } $this->payload = new CacheableNbt($in->getNbtCompoundRoot()); } protected function encodePayload(PacketSerializer $out) : void{ - $out->putBool($this->isRouteToManager); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putBool($this->isRouteToManager); + } $out->put($this->payload->getEncodedNbt()); } diff --git a/src/InventoryContentPacket.php b/src/InventoryContentPacket.php index c3cb7702..ae248956 100644 --- a/src/InventoryContentPacket.php +++ b/src/InventoryContentPacket.php @@ -44,7 +44,9 @@ protected function decodePayload(PacketSerializer $in) : void{ for($i = 0; $i < $count; ++$i){ $this->items[] = $in->getItemStackWrapper(); } - $this->dynamicContainerId = $in->getUnsignedVarInt(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->dynamicContainerId = $in->getUnsignedVarInt(); + } } protected function encodePayload(PacketSerializer $out) : void{ @@ -53,7 +55,9 @@ protected function encodePayload(PacketSerializer $out) : void{ foreach($this->items as $item){ $out->putItemStackWrapper($item); } - $out->putUnsignedVarInt($this->dynamicContainerId); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putUnsignedVarInt($this->dynamicContainerId); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/InventorySlotPacket.php b/src/InventorySlotPacket.php index cb860ecc..c3f9c0ca 100644 --- a/src/InventorySlotPacket.php +++ b/src/InventorySlotPacket.php @@ -40,14 +40,18 @@ public static function create(int $windowId, int $inventorySlot, ItemStackWrappe protected function decodePayload(PacketSerializer $in) : void{ $this->windowId = $in->getUnsignedVarInt(); $this->inventorySlot = $in->getUnsignedVarInt(); - $this->dynamicContainerId = $in->getUnsignedVarInt(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->dynamicContainerId = $in->getUnsignedVarInt(); + } $this->item = $in->getItemStackWrapper(); } protected function encodePayload(PacketSerializer $out) : void{ $out->putUnsignedVarInt($this->windowId); $out->putUnsignedVarInt($this->inventorySlot); - $out->putUnsignedVarInt($this->dynamicContainerId); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putUnsignedVarInt($this->dynamicContainerId); + } $out->putItemStackWrapper($this->item); } diff --git a/src/MobArmorEquipmentPacket.php b/src/MobArmorEquipmentPacket.php index 947173a0..5090b6cd 100644 --- a/src/MobArmorEquipmentPacket.php +++ b/src/MobArmorEquipmentPacket.php @@ -49,7 +49,9 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->chest = $in->getItemStackWrapper(); $this->legs = $in->getItemStackWrapper(); $this->feet = $in->getItemStackWrapper(); - $this->body = $in->getItemStackWrapper(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->body = $in->getItemStackWrapper(); + } } protected function encodePayload(PacketSerializer $out) : void{ @@ -58,7 +60,9 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putItemStackWrapper($this->chest); $out->putItemStackWrapper($this->legs); $out->putItemStackWrapper($this->feet); - $out->putItemStackWrapper($this->body); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putItemStackWrapper($this->body); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/PlayerArmorDamagePacket.php b/src/PlayerArmorDamagePacket.php index b5a10e4b..70a0dd4c 100644 --- a/src/PlayerArmorDamagePacket.php +++ b/src/PlayerArmorDamagePacket.php @@ -68,7 +68,9 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->chestSlotDamage = $this->maybeReadDamage($flags, self::FLAG_CHEST, $in); $this->legsSlotDamage = $this->maybeReadDamage($flags, self::FLAG_LEGS, $in); $this->feetSlotDamage = $this->maybeReadDamage($flags, self::FLAG_FEET, $in); - $this->bodySlotDamage = $this->maybeReadDamage($flags, self::FLAG_BODY, $in); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->bodySlotDamage = $this->maybeReadDamage($flags, self::FLAG_BODY, $in); + } } private function composeFlag(?int $field, int $flag) : int{ @@ -87,14 +89,16 @@ protected function encodePayload(PacketSerializer $out) : void{ $this->composeFlag($this->chestSlotDamage, self::FLAG_CHEST) | $this->composeFlag($this->legsSlotDamage, self::FLAG_LEGS) | $this->composeFlag($this->feetSlotDamage, self::FLAG_FEET) | - $this->composeFlag($this->bodySlotDamage, self::FLAG_BODY) + ($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20 ? $this->composeFlag($this->bodySlotDamage, self::FLAG_BODY) : 0) ); $this->maybeWriteDamage($this->headSlotDamage, $out); $this->maybeWriteDamage($this->chestSlotDamage, $out); $this->maybeWriteDamage($this->legsSlotDamage, $out); $this->maybeWriteDamage($this->feetSlotDamage, $out); - $this->maybeWriteDamage($this->bodySlotDamage, $out); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->maybeWriteDamage($this->bodySlotDamage, $out); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/SetTitlePacket.php b/src/SetTitlePacket.php index e8be6ccb..19fa5ad7 100644 --- a/src/SetTitlePacket.php +++ b/src/SetTitlePacket.php @@ -71,7 +71,9 @@ protected function decodePayload(PacketSerializer $in) : void{ $this->fadeOutTime = $in->getVarInt(); $this->xuid = $in->getString(); $this->platformOnlineId = $in->getString(); - $this->filteredTitleText = $in->getString(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->filteredTitleText = $in->getString(); + } } protected function encodePayload(PacketSerializer $out) : void{ @@ -82,7 +84,9 @@ protected function encodePayload(PacketSerializer $out) : void{ $out->putVarInt($this->fadeOutTime); $out->putString($this->xuid); $out->putString($this->platformOnlineId); - $out->putString($this->filteredTitleText); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putString($this->filteredTitleText); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/StopSoundPacket.php b/src/StopSoundPacket.php index 6ee20d3c..b0b781b9 100644 --- a/src/StopSoundPacket.php +++ b/src/StopSoundPacket.php @@ -37,13 +37,17 @@ public static function create(string $soundName, bool $stopAll, bool $stopLegacy protected function decodePayload(PacketSerializer $in) : void{ $this->soundName = $in->getString(); $this->stopAll = $in->getBool(); - $this->stopLegacyMusic = $in->getBool(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->stopLegacyMusic = $in->getBool(); + } } protected function encodePayload(PacketSerializer $out) : void{ $out->putString($this->soundName); $out->putBool($this->stopAll); - $out->putBool($this->stopLegacyMusic); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putBool($this->stopLegacyMusic); + } } public function handle(PacketHandlerInterface $handler) : bool{ diff --git a/src/serializer/PacketSerializer.php b/src/serializer/PacketSerializer.php index b17a3a4d..484b8dff 100644 --- a/src/serializer/PacketSerializer.php +++ b/src/serializer/PacketSerializer.php @@ -20,6 +20,7 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\TreeRoot; use pocketmine\network\mcpe\protocol\PacketDecodeException; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\types\BlockPosition; use pocketmine\network\mcpe\protocol\types\BoolGameRule; use pocketmine\network\mcpe\protocol\types\command\CommandOriginData; @@ -648,8 +649,10 @@ public function getEntityLink() : EntityLink{ $type = $this->getByte(); $immediate = $this->getBool(); $causedByRider = $this->getBool(); - $vehicleAngularVelocity = $this->getLFloat(); - return new EntityLink($fromActorUniqueId, $toActorUniqueId, $type, $immediate, $causedByRider, $vehicleAngularVelocity); + if($this->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $vehicleAngularVelocity = $this->getLFloat(); + } + return new EntityLink($fromActorUniqueId, $toActorUniqueId, $type, $immediate, $causedByRider, $vehicleAngularVelocity ?? 0.0); } public function putEntityLink(EntityLink $link) : void{ @@ -658,7 +661,9 @@ public function putEntityLink(EntityLink $link) : void{ $this->putByte($link->type); $this->putBool($link->immediate); $this->putBool($link->causedByRider); - $this->putLFloat($link->vehicleAngularVelocity); + if($this->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->putLFloat($link->vehicleAngularVelocity); + } } /** diff --git a/src/types/inventory/FullContainerName.php b/src/types/inventory/FullContainerName.php index 49b90884..20c45d2d 100644 --- a/src/types/inventory/FullContainerName.php +++ b/src/types/inventory/FullContainerName.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\inventory; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; final class FullContainerName{ @@ -28,12 +29,16 @@ public function getDynamicId() : int{ return $this->dynamicId; } public static function read(PacketSerializer $in) : self{ $containerId = $in->getByte(); - $dynamicId = $in->getLInt(); - return new self($containerId, $dynamicId); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $dynamicId = $in->getLInt(); + } + return new self($containerId, $dynamicId ?? 0); } public function write(PacketSerializer $out) : void{ $out->putByte($this->containerId); - $out->putLInt($this->dynamicId); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putLInt($this->dynamicId); + } } } diff --git a/src/types/inventory/UseItemTransactionData.php b/src/types/inventory/UseItemTransactionData.php index 1fd97646..c258e022 100644 --- a/src/types/inventory/UseItemTransactionData.php +++ b/src/types/inventory/UseItemTransactionData.php @@ -16,6 +16,7 @@ use pocketmine\math\Vector3; use pocketmine\network\mcpe\protocol\InventoryTransactionPacket; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\BlockPosition; use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; @@ -78,7 +79,9 @@ public function getClientInteractPrediction() : PredictedResult{ return $this->c protected function decodeData(PacketSerializer $stream) : void{ $this->actionType = $stream->getUnsignedVarInt(); - $this->triggerType = TriggerType::fromPacket($stream->getUnsignedVarInt()); + if($stream->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->triggerType = TriggerType::fromPacket($stream->getUnsignedVarInt()); + } $this->blockPosition = $stream->getBlockPosition(); $this->face = $stream->getVarInt(); $this->hotbarSlot = $stream->getVarInt(); @@ -86,12 +89,16 @@ protected function decodeData(PacketSerializer $stream) : void{ $this->playerPosition = $stream->getVector3(); $this->clickPosition = $stream->getVector3(); $this->blockRuntimeId = $stream->getUnsignedVarInt(); - $this->clientInteractPrediction = PredictedResult::fromPacket($stream->getUnsignedVarInt()); + if($stream->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $this->clientInteractPrediction = PredictedResult::fromPacket($stream->getUnsignedVarInt()); + } } protected function encodeData(PacketSerializer $stream) : void{ $stream->putUnsignedVarInt($this->actionType); - $stream->putUnsignedVarInt($this->triggerType->value); + if($stream->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $stream->putUnsignedVarInt($this->triggerType->value); + } $stream->putBlockPosition($this->blockPosition); $stream->putVarInt($this->face); $stream->putVarInt($this->hotbarSlot); @@ -99,7 +106,9 @@ protected function encodeData(PacketSerializer $stream) : void{ $stream->putVector3($this->playerPosition); $stream->putVector3($this->clickPosition); $stream->putUnsignedVarInt($this->blockRuntimeId); - $stream->putUnsignedVarInt($this->clientInteractPrediction->value); + if($stream->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $stream->putUnsignedVarInt($this->clientInteractPrediction->value); + } } /** diff --git a/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php b/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php index b8cfacf2..5656c10c 100644 --- a/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php +++ b/src/types/inventory/stackrequest/CraftRecipeAutoStackRequestAction.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; use pocketmine\network\mcpe\protocol\types\recipe\RecipeIngredient; @@ -53,18 +54,22 @@ public function getIngredients() : array{ return $this->ingredients; } public static function read(PacketSerializer $in) : self{ $recipeId = $in->readRecipeNetId(); - $repetitions2 = $in->getByte(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $repetitions2 = $in->getByte(); + } $repetitions = $in->getByte(); $ingredients = []; for($i = 0, $count = $in->getByte(); $i < $count; ++$i){ $ingredients[] = $in->getRecipeIngredient(); } - return new self($recipeId, $repetitions2, $repetitions, $ingredients); + return new self($recipeId, $repetitions2 ?? 0, $repetitions, $ingredients); } public function write(PacketSerializer $out) : void{ $out->writeRecipeNetId($this->recipeId); - $out->putByte($this->repetitions2); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putByte($this->repetitions2); + } $out->putByte($this->repetitions); $out->putByte(count($this->ingredients)); foreach($this->ingredients as $ingredient){ diff --git a/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php b/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php index 60773ab7..0d7caafd 100644 --- a/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php +++ b/src/types/inventory/stackrequest/CraftRecipeStackRequestAction.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; @@ -36,12 +37,16 @@ public function getRepetitions() : int { return $this->repetitions; } public static function read(PacketSerializer $in) : self{ $recipeId = $in->readRecipeNetId(); - $repetitions = $in->getByte(); - return new self($recipeId, $repetitions); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $repetitions = $in->getByte(); + } + return new self($recipeId, $repetitions ?? 0); } public function write(PacketSerializer $out) : void{ $out->writeRecipeNetId($this->recipeId); - $out->putByte($this->repetitions); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putByte($this->repetitions); + } } } diff --git a/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php b/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php index 2469675b..1322d29d 100644 --- a/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php +++ b/src/types/inventory/stackrequest/CreativeCreateStackRequestAction.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; @@ -36,12 +37,16 @@ public function getRepetitions() : int { return $this->repetitions; } public static function read(PacketSerializer $in) : self{ $creativeItemId = $in->readCreativeItemNetId(); - $repetitions = $in->getByte(); - return new self($creativeItemId, $repetitions); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $repetitions = $in->getByte(); + } + return new self($creativeItemId, $repetitions ?? 0); } public function write(PacketSerializer $out) : void{ $out->writeCreativeItemNetId($this->creativeItemId); - $out->putByte($this->repetitions); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putByte($this->repetitions); + } } } diff --git a/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php b/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php index 332082e0..39effc1f 100644 --- a/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php +++ b/src/types/inventory/stackrequest/GrindstoneStackRequestAction.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\inventory\stackrequest; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait; @@ -41,14 +42,18 @@ public function getRepetitions() : int { return $this->repetitions; } public static function read(PacketSerializer $in) : self{ $recipeId = $in->readRecipeNetId(); $repairCost = $in->getVarInt(); //WHY!!!! - $repetitions = $in->getByte(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $repetitions = $in->getByte(); + } - return new self($recipeId, $repairCost, $repetitions); + return new self($recipeId, $repairCost, $repetitions ?? 0); } public function write(PacketSerializer $out) : void{ $out->writeRecipeNetId($this->recipeId); $out->putVarInt($this->repairCost); - $out->putByte($this->repetitions); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putByte($this->repetitions); + } } } diff --git a/src/types/inventory/stackrequest/ItemStackRequest.php b/src/types/inventory/stackrequest/ItemStackRequest.php index dd82de79..9e8c698e 100644 --- a/src/types/inventory/stackrequest/ItemStackRequest.php +++ b/src/types/inventory/stackrequest/ItemStackRequest.php @@ -58,6 +58,8 @@ private static function readAction(PacketSerializer $in, int $typeId) : ItemStac DestroyStackRequestAction::ID => DestroyStackRequestAction::read($in), CraftingConsumeInputStackRequestAction::ID => CraftingConsumeInputStackRequestAction::read($in), CraftingCreateSpecificResultStackRequestAction::ID => CraftingCreateSpecificResultStackRequestAction::read($in), + PlaceIntoBundleStackRequestAction::ID => PlaceIntoBundleStackRequestAction::read($in), + TakeFromBundleStackRequestAction::ID => TakeFromBundleStackRequestAction::read($in), LabTableCombineStackRequestAction::ID => LabTableCombineStackRequestAction::read($in), BeaconPaymentStackRequestAction::ID => BeaconPaymentStackRequestAction::read($in), MineBlockStackRequestAction::ID => MineBlockStackRequestAction::read($in), diff --git a/src/types/inventory/stackrequest/ItemStackRequestActionType.php b/src/types/inventory/stackrequest/ItemStackRequestActionType.php index 59ddd8f1..e93d26d8 100644 --- a/src/types/inventory/stackrequest/ItemStackRequestActionType.php +++ b/src/types/inventory/stackrequest/ItemStackRequestActionType.php @@ -27,6 +27,8 @@ private function __construct(){ public const DESTROY = 4; public const CRAFTING_CONSUME_INPUT = 5; public const CRAFTING_CREATE_SPECIFIC_RESULT = 6; + public const PLACE_INTO_BUNDLE = 7; + public const TAKE_FROM_BUNDLE = 8; public const LAB_TABLE_COMBINE = 9; public const BEACON_PAYMENT = 10; public const MINE_BLOCK = 11; diff --git a/src/types/resourcepacks/BehaviorPackInfoEntry.php b/src/types/resourcepacks/BehaviorPackInfoEntry.php index 230f73f6..5b80ca4a 100644 --- a/src/types/resourcepacks/BehaviorPackInfoEntry.php +++ b/src/types/resourcepacks/BehaviorPackInfoEntry.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\resourcepacks; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; class BehaviorPackInfoEntry{ @@ -66,7 +67,9 @@ public function write(PacketSerializer $out) : void{ $out->putString($this->subPackName); $out->putString($this->contentId); $out->putBool($this->hasScripts); - $out->putBool($this->isAddonPack); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putBool($this->isAddonPack); + } } public static function read(PacketSerializer $in) : self{ @@ -77,7 +80,9 @@ public static function read(PacketSerializer $in) : self{ $subPackName = $in->getString(); $contentId = $in->getString(); $hasScripts = $in->getBool(); - $isAddonPack = $in->getBool(); - return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $isAddonPack); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $isAddonPack = $in->getBool(); + } + return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $isAddonPack ?? false); } } diff --git a/src/types/resourcepacks/ResourcePackInfoEntry.php b/src/types/resourcepacks/ResourcePackInfoEntry.php index d673e031..08b0c625 100644 --- a/src/types/resourcepacks/ResourcePackInfoEntry.php +++ b/src/types/resourcepacks/ResourcePackInfoEntry.php @@ -14,6 +14,7 @@ namespace pocketmine\network\mcpe\protocol\types\resourcepacks; +use pocketmine\network\mcpe\protocol\ProtocolInfo; use pocketmine\network\mcpe\protocol\serializer\PacketSerializer; class ResourcePackInfoEntry{ @@ -69,7 +70,9 @@ public function write(PacketSerializer $out) : void{ $out->putString($this->subPackName); $out->putString($this->contentId); $out->putBool($this->hasScripts); - $out->putBool($this->isAddonPack); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putBool($this->isAddonPack); + } $out->putBool($this->isRtxCapable); } @@ -81,8 +84,10 @@ public static function read(PacketSerializer $in) : self{ $subPackName = $in->getString(); $contentId = $in->getString(); $hasScripts = $in->getBool(); - $isAddonPack = $in->getBool(); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $isAddonPack = $in->getBool(); + } $rtxCapable = $in->getBool(); - return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $isAddonPack, $rtxCapable); + return new self($uuid, $version, $sizeBytes, $encryptionKey, $subPackName, $contentId, $hasScripts, $isAddonPack ?? false, $rtxCapable); } }