本文整理匯總了PHP中pocketmine\level\generator\Generator::getGeneratorName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Generator::getGeneratorName方法的具體用法?PHP Generator::getGeneratorName怎麽用?PHP Generator::getGeneratorName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pocketmine\level\generator\Generator
的用法示例。
在下文中一共展示了Generator::getGeneratorName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onSCommand
public function onSCommand(CommandSender $c, Command $cc, $scmd, $data, array $args)
{
if (count($args) < 1 || count($args) > 4) {
return false;
}
$world = array_shift($args);
if ($this->owner->getServer()->isLevelGenerated($world)) {
$c->sendMessage(TextFormat::RED . mc::_("[MW] A world named %1% already exists", $world));
return true;
}
$seed = null;
$generator = null;
$opts = [];
if (isset($args[0])) {
$seed = intval($args[0]);
}
if (isset($args[1])) {
$generator = Generator::getGenerator($args[1]);
if (strtolower($args[1]) != Generator::getGeneratorName($generator)) {
$c->sendMessage(TextFormat::RED . mc::_("[MW] Unknown generator %1%", $args[1]));
return true;
}
$c->sendMessage(TextFormat::GREEN . mc::_("[MW] Using %1%", Generator::getGeneratorName($generator)));
}
if (isset($args[2])) {
$opts = ["preset" => $args[2]];
}
$this->owner->getServer()->broadcastMessage(mc::_("[MW] Creating level %1%... (Expect Lag)", $world));
$this->owner->getServer()->generateLevel($world, $seed, $generator, $opts);
$this->owner->getServer()->loadLevel($world);
return true;
}
示例2: generate
public static function generate($path, $name, $seed, $generator, array $options = [])
{
@mkdir($path, 0777, true);
@mkdir($path . "/region", 0777);
//TODO, add extra details
$levelData = new Compound("Data", ["hardcore" => new Byte("hardcore", 0), "initialized" => new Byte("initialized", 1), "GameType" => new Int("GameType", 0), "generatorVersion" => new Int("generatorVersion", 1), "SpawnX" => new Int("SpawnX", 128), "SpawnY" => new Int("SpawnY", 70), "SpawnZ" => new Int("SpawnZ", 128), "version" => new Int("version", 19133), "DayTime" => new Int("DayTime", 0), "LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), "RandomSeed" => new Long("RandomSeed", $seed), "SizeOnDisk" => new Long("SizeOnDisk", 0), "Time" => new Long("Time", 0), "generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), "generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), "LevelName" => new String("LevelName", $name), "GameRules" => new Compound("GameRules", [])]);
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->setData(new Compound(null, ["Data" => $levelData]));
$buffer = $nbt->writeCompressed();
@file_put_contents($path . "level.dat", $buffer);
}
示例3: generate
public static function generate($path, $name, $seed, $generator, array $options = [])
{
if (!file_exists($path)) {
mkdir($path, 0777, true);
}
if (!file_exists($path . "/db")) {
mkdir($path . "/db", 0777, true);
}
//TODO, add extra details
$levelData = new Compound("", ["hardcore" => new Byte("hardcore", 0), "initialized" => new Byte("initialized", 1), "GameType" => new Int("GameType", 0), "generatorVersion" => new Int("generatorVersion", 1), "SpawnX" => new Int("SpawnX", 128), "SpawnY" => new Int("SpawnY", 70), "SpawnZ" => new Int("SpawnZ", 128), "version" => new Int("version", 19133), "DayTime" => new Int("DayTime", 0), "LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), "RandomSeed" => new Long("RandomSeed", $seed), "SizeOnDisk" => new Long("SizeOnDisk", 0), "Time" => new Long("Time", 0), "RainTime" => new Int("RainTime", 0), "Raining" => new String("Raining", false), "ThunderTime" => new Int("ThunderTime", 0), "Thundering" => new String("Thundering", false), "generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), "generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), "LevelName" => new String("LevelName", $name), "GameRules" => new Compound("GameRules", [])]);
$nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->setData($levelData);
$buffer = $nbt->write();
file_put_contents($path . "level.dat", Binary::writeLInt(3) . Binary::writeLInt(strlen($buffer)) . $buffer);
$db = new \LevelDB($path . "/db");
$db->close();
}