38 private array $canPlaceOn,
39 private array $canDestroy
46 return $this->canPlaceOn;
53 return $this->canDestroy;
61 $nbtLen = $in->getLShort();
65 if($nbtLen === 0xffff){
66 $nbtDataVersion = $in->
getByte();
67 if($nbtDataVersion !== 1){
70 $offset = $in->getOffset();
72 $compound = (
new LittleEndianNbtSerializer())->read($in->getBuffer(), $offset, 512)->mustGetCompoundTag();
73 }
catch(NbtDataException $e){
74 throw PacketDecodeException::wrap($e,
"Failed decoding NBT root");
76 $in->setOffset($offset);
78 }elseif($nbtLen !== 0){
79 throw new PacketDecodeException(
"Unexpected fake NBT length $nbtLen");
83 for($i = 0, $canPlaceOnCount = $in->
getLInt(); $i < $canPlaceOnCount; ++$i){
88 for($i = 0, $canDestroyCount = $in->
getLInt(); $i < $canDestroyCount; ++$i){
92 return new self($compound, $canPlaceOn, $canDestroy);
95 public function write(PacketSerializer $out) : void{
96 if($this->nbt !== null){
97 $out->putLShort(0xffff);
99 $out->put((
new LittleEndianNbtSerializer())->write(
new TreeRoot($this->nbt)));
104 $out->putLInt(count($this->canPlaceOn));
105 foreach($this->canPlaceOn as $entry){
106 $out->putLShort(strlen($entry));
109 $out->putLInt(count($this->canDestroy));
110 foreach($this->canDestroy as $entry){
111 $out->putLShort(strlen($entry));