public function getLocByVector(Vector3 $block, $levelFolderName) { return $block->getFloorX() . ";" . $block->getFloorY() . ";" . $block->getFloorZ() . ";" . $levelFolderName; }
/** * @param CommandSender $sender * @param Vector3 $waypoint * @param int $index * @return bool */ public function sendWaypointMessage(CommandSender $sender, Vector3 $waypoint, $index) { $this->sendMessage($sender, "message-waypoint-info", ["index" => $index, "x" => $waypoint->getFloorX(), "y" => $waypoint->getFloorY(), "z" => $waypoint->getFloorZ()]); return true; }
public function canBlockSeeSky(Vector3 $pos) : bool { return $this->getHighestBlockAt($pos->getFloorX(), $pos->getFloorZ()) < $pos->getY(); }
/** * @param Vector3|Position $pos * @param null|Level $level */ public function createTNT(Vector3 $pos, Level $level = null) { if ($level === null) { if ($pos instanceof Position) { $level = $pos->getLevel(); } else { return; } } $mot = (new Random())->nextSignedFloat() * M_PI * 2; $entity = Entity::createEntity("PrimedTNT", $level->getChunk($pos->x >> 4, $pos->z >> 4), new Compound("EssNuke", ["Pos" => new Enum("Pos", [new DoubleTag("", $pos->getFloorX() + 0.5), new DoubleTag("", $pos->getFloorY()), new DoubleTag("", $pos->getFloorZ() + 0.5)]), "Motion" => new Enum("Motion", [new DoubleTag("", -sin($mot) * 0.02), new DoubleTag("", 0.2), new DoubleTag("", -cos($mot) * 0.02)]), "Rotation" => new Enum("Rotation", [new FloatTag("", 0), new FloatTag("", 0)]), "Fuse" => new ByteTag("Fuse", 80)])); $entity->spawnToAll(); }
public function place() { for ($x = $this->start->getFloorX(); $x < $this->end->getFloorX(); $x++) { $xOffset = ($this->chunk->getX() + $x + 0.5 - $this->target->getX()) / $this->horizontalSize; for ($z = $this->start->getFloorZ(); $z < $this->end->getFloorZ(); $z++) { $zOffset = ($this->chunk->getZ() + $z + 0.5 - $this->target->getZ()) / $this->horizontalSize; if ($xOffset * $xOffset + $zOffset * $zOffset >= 1) { continue; } for ($y = $this->end->getFloorY() - 1; $y >= $this->start->getFloorY(); $y--) { $yOffset = ($y + 0.5 - $this->target->getY()) / $this->verticalSize; if ($yOffset > -0.7 and $xOffset * $xOffset + $yOffset * $yOffset + $zOffset * $zOffset < 1) { $xx = $this->chunk->getX() + $x; $zz = $this->chunk->getZ() + $z; $blockId = $this->level->getBlockIdAt($xx, $y, $zz); if ($blockId == Block::STONE or $blockId == Block::DIRT or $blockId == Block::GRASS) { if ($y < 10) { $this->level->setBlockIdAt($xx, $y, $zz, Block::STILL_LAVA); } else { if ($blockId == Block::GRASS and $this->level->getBlockIdAt($xx, $y - 1, $zz) == Block::DIRT) { $this->level->setBlockIdAt($xx, $y - 1, $zz, Block::GRASS); } $this->level->setBlockIdAt($xx, $y, $zz, Block::AIR); } } } } } } }
/** * @param string|Entity|CustomEntity $class * @param Vector3 $spawnPos * @param $data */ public function addCustomEntity($class, Vector3 $spawnPos, $data) { $key = Level::chunkHash($spawnPos->getFloorX() >> 4, $spawnPos->getFloorZ() >> 4); $id = $this->nextId++; $this->locs[$key][$id] = new RegisteredSpawn($spawnPos->x, $spawnPos->y, $spawnPos->z, $id, $class, $data); }