45 public const TAG_FACING =
"facing";
47 protected Facing $facing = Facing::NORTH;
52 parent::__construct($world, $pos);
56 $blockTypeId = ItemTypeIds::toBlockTypeId($item->getTypeId());
57 if($blockTypeId === BlockTypeIds::SHULKER_BOX || $blockTypeId === BlockTypeIds::DYED_SHULKER_BOX){
65 public function readSaveData(
CompoundTag $nbt) :
void{
66 $this->loadName($nbt);
67 $this->loadItems($nbt);
69 $this->facing = Facing::tryFrom($nbt->getByte(self::TAG_FACING, $this->facing->value)) ??
throw new SavedDataLoadingException(
"Invalid facing value");
73 $this->saveName($nbt);
74 $this->saveItems($nbt);
76 $nbt->
setByte(self::TAG_FACING, $this->facing->value);
80 $this->readSaveData($item->getNamedTag());
81 if($item->hasCustomName()){
82 $this->setName($item->getCustomName());
86 public function close() : void{
88 $this->inventory->removeAllWindows();
98 $nbt = parent::getCleanedNBT();
105 public function getFacing() :
Facing{
106 return $this->facing;
109 public function setFacing(Facing $facing) : void{
110 $this->facing = $facing;
113 public function getInventory() : Inventory{
114 return $this->inventory;
117 public function getRealInventory() : Inventory{
118 return $this->inventory;
121 public function getDefaultName() : string{
122 return
"Shulker Box";
127 $nbt->setByte(self::TAG_FACING, $this->facing->value);
128 $this->addNameSpawnData($nbt);