|null */ private ?CacheableNbt $spawnCompoundCache = null; /** * @deprecated */ public function isDirty() : bool{ return $this->spawnCompoundCache === null; } /** * @deprecated */ public function setDirty(bool $dirty = true) : void{ $this->clearSpawnCompoundCache(); } public function clearSpawnCompoundCache() : void{ $this->spawnCompoundCache = null; } /** * Returns encoded NBT (varint, little-endian) used to spawn this tile to clients. Uses cache where possible, * populates cache if it is null. * * @phpstan-return CacheableNbt<\pocketmine\nbt\tag\CompoundTag> */ final public function getSerializedSpawnCompound() : CacheableNbt{ if($this->spawnCompoundCache === null){ $this->spawnCompoundCache = new CacheableNbt($this->getSpawnCompound()); } return $this->spawnCompoundCache; } final public function getSpawnCompound() : CompoundTag{ $nbt = CompoundTag::create() ->setString(self::TAG_ID, TileFactory::getInstance()->getSaveId(get_class($this))) //TODO: disassociate network ID from save ID ->setInt(self::TAG_X, $this->position->x) ->setInt(self::TAG_Y, $this->position->y) ->setInt(self::TAG_Z, $this->position->z); $this->addAdditionalSpawnData($nbt); return $nbt; } /** * An extension to getSpawnCompound() for * further modifying the generic tile NBT. */ abstract protected function addAdditionalSpawnData(CompoundTag $nbt) : void; }