*/ protected array $slots = []; protected function describeBlockOnlyState(RuntimeDataDescriber $w) : void{ $w->enumSet($this->slots, BrewingStandSlot::cases()); } protected function recalculateCollisionBoxes() : array{ return [ //bottom slab part - in PC this is also inset on X/Z by 1/16, but Bedrock sucks AxisAlignedBB::one()->trim(Facing::UP, 7 / 8), //center post AxisAlignedBB::one() ->squash(Axis::X, 7 / 16) ->squash(Axis::Z, 7 / 16) ->trim(Facing::UP, 1 / 8) ]; } public function getSupportType(int $facing) : SupportType{ return SupportType::NONE; } public function hasSlot(BrewingStandSlot $slot) : bool{ return array_key_exists(spl_object_id($slot), $this->slots); } public function setSlot(BrewingStandSlot $slot, bool $occupied) : self{ if($occupied){ $this->slots[spl_object_id($slot)] = $slot; }else{ unset($this->slots[spl_object_id($slot)]); } return $this; } /** * @return BrewingStandSlot[] * @phpstan-return array */ public function getSlots() : array{ return $this->slots; } /** @param BrewingStandSlot[] $slots */ public function setSlots(array $slots) : self{ $this->slots = []; foreach($slots as $slot){ $this->slots[spl_object_id($slot)] = $slot; } return $this; } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ if($player instanceof Player){ $stand = $this->position->getWorld()->getTile($this->position); if($stand instanceof TileBrewingStand && $stand->canOpenWith($item->getCustomName())){ $player->setCurrentWindow($stand->getInventory()); } } return true; } public function onScheduledUpdate() : void{ $world = $this->position->getWorld(); $brewing = $world->getTile($this->position); if($brewing instanceof TileBrewingStand){ if($brewing->onUpdate()){ $world->scheduleDelayedBlockUpdate($this->position, 1); } $changed = false; foreach(BrewingStandSlot::cases() as $slot){ $occupied = !$brewing->getInventory()->isSlotEmpty($slot->getSlotNumber()); if($occupied !== $this->hasSlot($slot)){ $this->setSlot($slot, $occupied); $changed = true; } } if($changed){ $world->setBlock($this->position, $this); } } } }