Skip to content

Commit

Permalink
Fix LoomStackRequestAction for versions under 1.21.20
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Dec 24, 2024
1 parent bdf59a4 commit 3ad8e20
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/types/inventory/stackrequest/LoomStackRequestAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
}
}

0 comments on commit 3ad8e20

Please sign in to comment.