本文整理汇总了PHP中pocketmine\level\Level::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Level::getId方法的具体用法?PHP Level::getId怎么用?PHP Level::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\level\Level
的用法示例。
在下文中一共展示了Level::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: blockZone
public function blockZone(Vector3 $a, Vector3 $b, Level $level)
{
if (!isset($this->activeZones[$level->getId()])) {
$this->activeZones[$level->getId()] = [];
}
$id = count($this->activeZones[$level->getId()]);
$this->activeZones[$level->getId()][$id] = [$a, $b];
$this->clearZone($level, $id);
return $id;
}
示例2: __construct
public function __construct(Level $level, FullChunk $chunk)
{
$this->state = true;
$this->levelId = $level->getId();
$this->chunk = $chunk->toFastBinary();
$this->chunkClass = get_class($chunk);
}
示例3: __construct
public function __construct(Level $level, Generator $generator)
{
$this->generator = get_class($generator);
$this->settings = $generator->getSettings();
$this->seed = $level->getSeed();
$this->levelId = $level->getId();
}
示例4: __construct
public function __construct(Level $level, Generator $generator)
{
$this->generator = get_class($generator);
$this->waterHeight = $generator->getWaterHeight();
$this->settings = serialize($generator->getSettings());
$this->seed = $level->getSeed();
$this->levelId = $level->getId();
}
示例5: __construct
public function __construct(Level $level, FullChunk $chunk)
{
$this->state = true;
$this->levelId = $level->getId();
$this->chunk = $chunk->toFastBinary();
$this->chunkClass = get_class($chunk);
$this->chunk00 = $level->getChunk($chunk->getX() - 1, $chunk->getZ() - 1, true)->toFastBinary();
$this->chunk01 = $level->getChunk($chunk->getX() - 1, $chunk->getZ(), true)->toFastBinary();
$this->chunk02 = $level->getChunk($chunk->getX() - 1, $chunk->getZ() + 1, true)->toFastBinary();
$this->chunk10 = $level->getChunk($chunk->getX(), $chunk->getZ() - 1, true)->toFastBinary();
$this->chunk12 = $level->getChunk($chunk->getX(), $chunk->getZ() + 1, true)->toFastBinary();
$this->chunk20 = $level->getChunk($chunk->getX() + 1, $chunk->getZ() - 1, true)->toFastBinary();
$this->chunk21 = $level->getChunk($chunk->getX() + 1, $chunk->getZ(), true)->toFastBinary();
$this->chunk22 = $level->getChunk($chunk->getX() + 1, $chunk->getZ() + 1, true)->toFastBinary();
}
示例6: __construct
public function __construct(Level $level, FullChunk $chunk)
{
$this->state = \true;
$this->levelId = $level->getId();
$this->chunk = $chunk->toFastBinary();
$this->chunkClass = \get_class($chunk);
for ($i = 0; $i < 9; ++$i) {
if ($i === 4) {
continue;
}
$xx = -1 + $i % 3;
$zz = -1 + (int) ($i / 3);
$ck = $level->getChunk($chunk->getX() + $xx, $chunk->getZ() + $zz, \false);
$this->{"chunk{$i}"} = $ck !== \null ? $ck->toFastBinary() : \null;
}
}
示例7: __construct
public function __construct(Level $level, Chunk $chunk)
{
$this->levelId = $level->getId();
$this->chunk = $chunk->toFastBinary();
$this->chunkX = $chunk->getX();
$this->chunkZ = $chunk->getZ();
$tiles = "";
$nbt = new NBT(NBT::LITTLE_ENDIAN);
foreach ($chunk->getTiles() as $tile) {
if ($tile instanceof Spawnable) {
$nbt->setData($tile->getSpawnCompound());
$tiles .= $nbt->write();
}
}
$this->tiles = $tiles;
}
示例8: generateLevel
/**
* Generates a new level if it does not exists
*
* @param string $name
* @param int $seed
* @param string $generator Class name that extends pocketmine\level\generator\Generator
* @param array $options
*
* @return bool
*/
public function generateLevel($name, $seed = null, $generator = null, $options = [])
{
if (trim($name) === "" or $this->isLevelGenerated($name)) {
return false;
}
$seed = $seed === null ? PHP_INT_SIZE === 8 ? unpack("N", @Utils::getRandomBytes(4, false))[1] << 32 >> 32 : unpack("N", @Utils::getRandomBytes(4, false))[1] : (int) $seed;
if ($generator !== null and class_exists($generator) and is_subclass_of($generator, Generator::class)) {
$generator = new $generator($options);
} else {
$options["preset"] = $this->getConfigString("generator-settings", "");
$generator = Generator::getGenerator($this->getLevelType());
}
if (($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === null) {
$provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
}
try {
$path = $this->getDataPath() . "worlds/" . $name . "/";
/** @var \pocketmine\level\format\LevelProvider $provider */
$provider::generate($path, $name, $seed, $generator, $options);
$level = new Level($this, $name, $path, $provider);
$this->levels[$level->getId()] = $level;
$level->initLevel();
} catch (\Exception $e) {
$this->logger->error("Could not generate level \"" . $name . "\": " . $e->getMessage());
if ($this->logger instanceof MainLogger) {
$this->logger->logException($e);
}
return false;
}
$this->getPluginManager()->callEvent(new LevelInitEvent($level));
$this->getPluginManager()->callEvent(new LevelLoadEvent($level));
$this->getLogger()->notice("Spawn terrain for level \"{$name}\" is being generated in the background");
$centerX = $level->getSpawnLocation()->getX() >> 4;
$centerZ = $level->getSpawnLocation()->getZ() >> 4;
$order = [];
for ($X = -4; $X <= 4; ++$X) {
for ($Z = -4; $Z <= 4; ++$Z) {
$distance = $X ** 2 + $Z ** 2;
$chunkX = $X + $centerX;
$chunkZ = $Z + $centerZ;
$index = PHP_INT_SIZE === 8 ? ($chunkX & 0xffffffff) << 32 | $chunkZ & 0xffffffff : $chunkX . ":" . $chunkZ;
$order[$index] = $distance;
}
}
asort($order);
$chunkX = $chunkZ = null;
foreach ($order as $index => $distance) {
if (PHP_INT_SIZE === 8) {
$chunkX = $index >> 32 << 32 >> 32;
$chunkZ = ($index & 0xffffffff) << 32 >> 32;
} else {
list($chunkX, $chunkZ) = explode(":", $index);
$chunkX = (int) $chunkX;
$chunkZ = (int) $chunkZ;
}
$level->generateChunk($chunkX, $chunkZ, true);
}
return true;
}
示例9: generateLevel
/**
* Generates a new level if it does not exists
*
* @param string $name
* @param int $seed
* @param string $generator Class name that extends pocketmine\level\generator\Generator
* @param array $options
*
* @return bool
*/
public function generateLevel($name, $seed = null, $generator = null, $options = [])
{
if (trim($name) === "" or $this->isLevelGenerated($name)) {
return false;
}
$seed = $seed === null ? Binary::readInt(@Utils::getRandomBytes(4, false)) : (int) $seed;
if ($generator !== null and class_exists($generator) and is_subclass_of($generator, Generator::class)) {
$generator = new $generator($options);
} else {
$options["preset"] = $this->getConfigString("generator-settings", "");
$generator = Generator::getGenerator($this->getLevelType());
}
if (($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === null) {
$provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
}
try {
$path = $this->getDataPath() . "worlds/" . $name . "/";
/** @var \pocketmine\level\format\LevelProvider $provider */
$provider::generate($path, $name, $seed, $generator, $options);
$level = new Level($this, $name, $path, $provider);
$this->levels[$level->getId()] = $level;
$level->initLevel();
} catch (\Exception $e) {
$this->logger->error("Could not generate level \"" . $name . "\": " . $e->getMessage());
if ($this->logger instanceof MainLogger) {
$this->logger->logException($e);
}
return false;
}
$this->getPluginManager()->callEvent(new LevelInitEvent($level));
$this->getPluginManager()->callEvent(new LevelLoadEvent($level));
$this->getLogger()->notice("Spawn terrain for level \"{$name}\" is being generated in the background");
$radiusSquared = ($this->getViewDistance() + 1) / M_PI;
$radius = ceil(sqrt($radiusSquared));
$centerX = $level->getSpawnLocation()->getX() >> 4;
$centerZ = $level->getSpawnLocation()->getZ() >> 4;
$order = [];
for ($X = -$radius; $X <= $radius; ++$X) {
for ($Z = -$radius; $Z <= $radius; ++$Z) {
$distance = $X ** 2 + $Z ** 2;
if ($distance > $radiusSquared) {
continue;
}
$chunkX = $X + $centerX;
$chunkZ = $Z + $centerZ;
$index = Level::chunkHash($chunkX, $chunkZ);
$order[$index] = $distance;
}
}
asort($order);
$chunkX = $chunkZ = null;
foreach ($order as $index => $distance) {
Level::getXZ($index, $chunkX, $chunkZ);
$level->generateChunk($chunkX, $chunkZ);
}
return true;
}
示例10: setLevel
public function setLevel(Level $level)
{
$this->levelId = $level !== null ? $level->getId() : -1;
return $this;
}
示例11: generateLevel
/**
* Generates a new level if it does not exists
*
* @param string $name
* @param int $seed
* @param string $generator Class name that extends pocketmine\level\generator\Noise
* @param array $options
*
* @return bool
*/
public function generateLevel($name, $seed = \null, $generator = \null, $options = [])
{
if (\trim($name) === "" or $this->isLevelGenerated($name)) {
return \false;
}
$seed = $seed === \null ? \PHP_INT_SIZE === 8 ? \unpack("N", @Utils::getRandomBytes(4, \false))[1] << 32 >> 32 : \unpack("N", @Utils::getRandomBytes(4, \false))[1] : (int) $seed;
if (!isset($options["preset"])) {
$options["preset"] = $this->getConfigString("generator-settings", "");
}
if (!($generator !== \null and \class_exists($generator, \true) and \is_subclass_of($generator, Generator::class))) {
$generator = Generator::getGenerator($this->getLevelType());
}
if (($provider = LevelProviderManager::getProviderByName($providerName = $this->getProperty("level-settings.default-format", "mcregion"))) === \null) {
$provider = LevelProviderManager::getProviderByName($providerName = "mcregion");
}
try {
$path = $this->getDataPath() . "worlds/" . $name . "/";
/** @var \pocketmine\level\format\LevelProvider $provider */
$provider::generate($path, $name, $seed, $generator, $options);
$level = new Level($this, $name, $path, $provider);
$this->levels[$level->getId()] = $level;
$level->initLevel();
$level->setTickRate($this->baseTickRate);
} catch (\Exception $e) {
$this->logger->error($this->getLanguage()->translateString("pocketmine.level.generateError", [$name, $e->getMessage()]));
if ($this->logger instanceof MainLogger) {
$this->logger->logException($e);
}
return \false;
}
$this->getPluginManager()->callEvent(new LevelInitEvent($level));
$this->getPluginManager()->callEvent(new LevelLoadEvent($level));
$this->getLogger()->notice($this->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name]));
$centerX = $level->getSpawnLocation()->getX() >> 4;
$centerZ = $level->getSpawnLocation()->getZ() >> 4;
$order = [];
for ($X = -3; $X <= 3; ++$X) {
for ($Z = -3; $Z <= 3; ++$Z) {
$distance = $X ** 2 + $Z ** 2;
$chunkX = $X + $centerX;
$chunkZ = $Z + $centerZ;
$index = \PHP_INT_SIZE === 8 ? ($chunkX & 4294967295.0) << 32 | $chunkZ & 4294967295.0 : $chunkX . ":" . $chunkZ;
$order[$index] = $distance;
}
}
\asort($order);
foreach ($order as $index => $distance) {
if (\PHP_INT_SIZE === 8) {
$chunkX = $index >> 32 << 32 >> 32;
$chunkZ = ($index & 4294967295.0) << 32 >> 32;
} else {
list($chunkX, $chunkZ) = \explode(":", $index);
$chunkX = (int) $chunkX;
$chunkZ = (int) $chunkZ;
}
$level->populateChunk($chunkX, $chunkZ, \true);
}
return \true;
}
示例12: requestChunk
public function requestChunk(Level $level, $chunkX, $chunkZ)
{
$buffer = chr(GenerationManager::PACKET_REQUEST_CHUNK) . Binary::writeInt($level->getId()) . Binary::writeInt($chunkX) . Binary::writeInt($chunkZ);
$this->generationThread->pushMainToThreadPacket($buffer);
}
示例13: sendLevelInfo
/**
* @param CommandSender $sender
* @param Level $level
*/
public function sendLevelInfo(CommandSender $sender, Level $level)
{
$sender->sendMessage("Name: " . $level->getName());
$sender->sendMessage("Id: " . $level->getId());
$sender->sendMessage("Entities: " . count($level->getEntities()));
$sender->sendMessage("Players: " . count($level->getPlayers()));
$sender->sendMessage("Tiles: " . count($level->getTiles()));
$sender->sendMessage("Chunks: " . count($level->getChunks()));
$sender->sendMessage("Loaders: " . count($level->getLoaders()));
$sender->sendMessage("Spawn: " . $level->getSafeSpawn()->getFloorX() . ":" . $level->getSafeSpawn()->getFloorY() . ":" . $level->getSafeSpawn()->getFloorZ());
$sender->sendMessage("Time: " . $level->getTime());
$sender->sendMessage("Tick-rate: " . $level->getTickRate());
$sender->sendMessage("Tick-rate-time: " . $level->getTickRateTime());
$sender->sendMessage("Seed: " . $level->getSeed());
$sender->sendMessage("Is-auto-saving: " . ($level->getAutoSave() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
$sender->sendMessage("Is-generated: " . ($level->getServer()->isLevelGenerated($level->getName()) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
$sender->sendMessage("Is-loaded: " . ($level->getServer()->isLevelLoaded($level->getName()) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
}
示例14: requestChunk
public function requestChunk(Level $level, $chunkX, $chunkZ)
{
$this->generationManager->enqueueChunk($level->getId(), $chunkX, $chunkZ);
}
示例15: __construct
public function __construct(Level $level)
{
$this->levelId = $level->getId();
}