53 if($player !== null && $player->getGamemode() !== GameMode::CREATIVE){
60 public function teleport() : void{
61 $world = $this->position->getWorld();
62 for($tries = 0; $tries < 16; ++$tries){
63 $block = $world->getBlockAt(
64 $this->position->x + mt_rand(-16, 16),
65 max(World::Y_MIN, min(World::Y_MAX - 1, $this->position->y + mt_rand(-8, 8))),
66 $this->position->z + mt_rand(-16, 16)
68 if($block instanceof Air){
69 $ev =
new BlockTeleportEvent($this, $block->position);
71 if($ev->isCancelled()){
75 $blockPos = $ev->getTo();
76 $world->addParticle($this->position,
new DragonEggTeleportParticle($this->position->x - $blockPos->x, $this->position->y - $blockPos->y, $this->position->z - $blockPos->z));
77 $world->setBlock($this->position, VanillaBlocks::AIR());
78 $world->setBlock($blockPos, $this);
85 return SupportType::NONE;