From 3ad8e20283052d09d25b41f6bbc208af33c3a372 Mon Sep 17 00:00:00 2001 From: Dries C Date: Tue, 24 Dec 2024 13:23:44 +0100 Subject: [PATCH] Fix LoomStackRequestAction for versions under 1.21.20 --- .../inventory/stackrequest/LoomStackRequestAction.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/types/inventory/stackrequest/LoomStackRequestAction.php b/src/types/inventory/stackrequest/LoomStackRequestAction.php index dbf6f3f3..8436d2f8 100644 --- a/src/types/inventory/stackrequest/LoomStackRequestAction.php +++ b/src/types/inventory/stackrequest/LoomStackRequestAction.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{ $patternId = $in->getString(); - $repetitions = $in->getByte(); - return new self($patternId, $repetitions); + if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $repetitions = $in->getVarInt(); + } + return new self($patternId, $repetitions ?? 1); } public function write(PacketSerializer $out) : void{ $out->putString($this->patternId); - $out->putByte($this->repetitions); + if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){ + $out->putByte($this->repetitions); + } } }