44 public const TAG_ID =
"id";
45 public const TAG_X =
"x";
46 public const TAG_Y =
"y";
47 public const TAG_Z =
"z";
50 public bool $closed =
false;
54 $this->position = Position::fromObject($pos, $world);
55 $this->timings = Timings::getTileEntityTimings($this);
63 abstract public function readSaveData(
CompoundTag $nbt) : void;
72 ->setString(self::TAG_ID,
TileFactory::getInstance()->getSaveId(get_class($this)))
73 ->setInt(self::TAG_X, $this->position->getFloorX())
74 ->setInt(self::TAG_Y, $this->position->getFloorY())
75 ->setInt(self::TAG_Z, $this->position->getFloorZ())
84 return $tag->
getCount() > 0 ? $tag :
null;
92 public function copyDataFromItem(
Item $item) : void{
93 if(($blockNbt = $item->getCustomBlockData()) !== null){
94 $this->readSaveData($blockNbt);
98 public function getBlock() : Block{
99 return $this->position->getWorld()->getBlock($this->position);
103 return $this->position;
106 public function isClosed() : bool{
107 return $this->closed;
110 public function __destruct(){
129 public function close() : void{
131 $this->closed =
true;
133 if($this->position->isValid()){
134 $this->position->getWorld()->removeTile($this);