getHarvestLevel())); } public function getLightLevel() : int{ return 1; } public function tickFalling() : ?Block{ return null; } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $this->teleport(); return true; } public function onAttack(Item $item, int $face, ?Player $player = null) : bool{ $this->teleport(); return true; } public function teleport() : void{ for($tries = 0; $tries < 16; ++$tries){ $block = $this->pos->getWorldNonNull()->getBlockAt( $this->pos->x + mt_rand(-16, 16), max(0, min(World::Y_MAX - 1, $this->pos->y + mt_rand(-8, 8))), $this->pos->z + mt_rand(-16, 16) ); if($block instanceof Air){ $ev = new BlockTeleportEvent($this, $block->pos); $ev->call(); if($ev->isCancelled()){ break; } $blockPos = $ev->getTo(); $this->pos->getWorldNonNull()->addParticle($this->pos, new DragonEggTeleportParticle($this->pos->x - $blockPos->x, $this->pos->y - $blockPos->y, $this->pos->z - $blockPos->z)); $this->pos->getWorldNonNull()->setBlock($this->pos, VanillaBlocks::AIR()); $this->pos->getWorldNonNull()->setBlock($blockPos, $this); break; } } } }