getLevel(); assert($level !== null); $minX = $consumer->getFloorX() - 8; $minY = min($consumer->getFloorY(), $consumer->getLevel()->getWorldHeight()) - 8; $minZ = $consumer->getFloorZ() - 8; $maxX = $minX + 16; $maxY = $minY + 16; $maxZ = $minZ + 16; for($attempts = 0; $attempts < 16; ++$attempts){ $x = mt_rand($minX, $maxX); $y = mt_rand($minY, $maxY); $z = mt_rand($minZ, $maxZ); while($y >= 0 and !$level->getBlockAt($x, $y, $z)->isSolid()){ $y--; } if($y < 0){ continue; } $blockUp = $level->getBlockAt($x, $y + 1, $z); $blockUp2 = $level->getBlockAt($x, $y + 2, $z); if($blockUp->isSolid() or $blockUp instanceof Liquid or $blockUp2->isSolid() or $blockUp2 instanceof Liquid){ continue; } //Sounds are broadcasted at both source and destination $level->addSound(new EndermanTeleportSound($consumer->asVector3())); $consumer->teleport(new Vector3($x + 0.5, $y + 1, $z + 0.5)); $level->addSound(new EndermanTeleportSound($consumer->asVector3())); break; } } public function getCooldownTicks() : int{ return 20; } }