public function SignSpawn($text, $pos) { if ($this->getServer()->getDefaultLevel()->isChunkGenerated($pos[0], $pos[2])) { $this->getServer()->getDefaultLevel()->generateChunk($pos[0], $pos[1]); } $chunk = $this->getServer()->getDefaultLevel()->getChunk($pos[0] >> 4, $pos[2] >> 4, true); $nbt = new Compound("", [new String("Text1", $text[0]), new String("Text2", $text[1]), new String("Text3", $text[2]), new String("Text4", $text[3]), new String("id", Tile::SIGN), new Int("x", (int) $pos[0]), new Int("y", (int) $pos[1]), new Int("z", (int) $pos[2])]); if (!$chunk instanceof FullChunk) { break; } $entities = $this->getServer()->getDefaultLevel()->getEntities(); foreach ($entities as $tile) { if (!$tile instanceof Tile) { continue; } if ($tile->x != $pos[0] or $tile->y != $pos[1] or $tile->z != $pos[2]) { continue; } $tile->close(); } $id = $this->list[$pos[0] . "." . $pos[1] . "." . $pos[2]]['id']; $damage = $this->list[$pos[0] . "." . $pos[1] . "." . $pos[2]]['damage']; $this->getServer()->getDefaultLevel()->setBlock(new Vector3($pos[0], $pos[1], $pos[2]), Block::get($id, $damage), false, true); $sign = new Sign($chunk, $nbt); $sign->saveNBT(); $this->getServer()->getDefaultLevel()->addTile($sign); }
public function onCommand(CommandSender $player, Command $command, $label, array $args) { /* SEND HELP */ if (!isset($args[3])) { $player->sendMessage(TextFormat::DARK_AQUA . "/signgen <x> <y> <z> <world> <id> <meta> <text>"); return true; } /* SET X Y Z */ $x = (int) $args[0]; $y = (int) $args[1]; $z = (int) $args[2]; /* SET WORLD */ $world = $this->getServer()->getLevelByName($args[3]); if (!$world instanceof Level) { $world = $this->getServer()->getDefaultLevel(); } /* SET ID AND DAMAGE */ $id = $args[4]; $damage = $args[5]; /* SET TEXT */ for ($i = 0; $i <= 5; $i++) { array_shift($args); } $text = implode(" ", $args); $text = explode("\\n", $text); if (!isset($text[1])) { $text[1] = ""; } if (!isset($text[2])) { $text[2] = ""; } if (!isset($text[3])) { $text[3] = ""; } /* SET CHUNK */ if ($world->isChunkGenerated($x, $z)) { $world->generateChunk($x, $z); } $chunk = $world->getChunk($x >> 4, $z >> 4, true); if (!$chunk instanceof FullChunk) { $player->sendMessage(TextFormat::DARK_AQUA . "[SignGeneration] WRONG CHUNK PROBLEM EXIST"); return true; } /* SET NBT */ $nbt = new Compound("", [new String("Text1", $text[0]), new String("Text2", $text[1]), new String("Text3", $text[2]), new String("Text4", $text[3]), new String("id", Tile::SIGN), new Int("x", (int) $x), new Int("y", (int) $y), new Int("z", (int) $z)]); /* DELETE OVERLAP TILE */ $entities = $world->getEntities(); foreach ($entities as $tile) { if (!$tile instanceof Tile) { continue; } if ($tile->x != $x or $tile->y != $y or $tile->z != $z) { continue; } $tile->close(); } /* SET SIGN BLOCK */ $world->setBlock(new Vector3($x, $y, $z), Block::get($id, $damage), false, true); $sign = new Sign($chunk, $nbt); $sign->saveNBT(); $world->addTile($sign); $player->sendMessage(TextFormat::DARK_AQUA . "[SignGeneration] COMPLETE!"); return true; }