22declare(strict_types=1);
28use pocketmine\block\utils\FallableTrait;
29use pocketmine\block\utils\SupportType;
44 public const MIN_LAYERS = 1;
45 public const MAX_LAYERS = 8;
47 protected int $layers = self::MIN_LAYERS;
50 $w->boundedIntAuto(self::MIN_LAYERS, self::MAX_LAYERS, $this->layers);
53 public function getLayers() : int{ return $this->layers; }
57 if($layers < self::MIN_LAYERS || $layers > self::MAX_LAYERS){
58 throw new \InvalidArgumentException(
"Layers must be in range " . self::MIN_LAYERS .
" ... " . self::MAX_LAYERS);
60 $this->layers = $layers;
65 return $this->layers < self::MAX_LAYERS;
77 if(!$this->canBeReplaced()){
78 return SupportType::FULL;
80 return SupportType::NONE;
83 private function canBeSupportedAt(Block $block) : bool{
84 return $block->getAdjacentSupportType(Facing::DOWN) === SupportType::FULL;
89 if($blockReplace->layers >= self::MAX_LAYERS){
92 $this->layers = $blockReplace->layers + 1;
94 if($this->canBeSupportedAt($blockReplace)){
95 return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player);
106 $world = $this->position->getWorld();
107 if($world->getBlockLightAt($this->position->x, $this->position->y, $this->position->z) >= 12){
108 BlockEventHelper::melt($this, VanillaBlocks::AIR());
114 VanillaItems::SNOWBALL()->setCount(max(1, (int) floor($this->layers / 2)))
describeBlockOnlyState(RuntimeDataDescriber $w)
getDropsForCompatibleTool(Item $item)
getSupportType(int $facing)
recalculateCollisionBoxes()
place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player=null)