本文整理汇总了PHP中pocketmine\Server::getLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getLevel方法的具体用法?PHP Server::getLevel怎么用?PHP Server::getLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\Server
的用法示例。
在下文中一共展示了Server::getLevel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCompletion
public function onCompletion(Server $server)
{
$level = $server->getLevel($this->levelId);
if ($level instanceof Level and $this->hasResult()) {
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult());
}
}
示例2: handlePackets
public function handlePackets()
{
while (strlen($packet = $this->generationThread->readThreadToMainPacket()) > 0) {
$pid = ord($packet[0]);
$offset = 1;
if ($pid === GenerationManager::PACKET_REQUEST_CHUNK) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$chunkX = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$chunkZ = Binary::readInt(substr($packet, $offset, 4));
$this->handleRequest($levelID, $chunkX, $chunkZ);
} elseif ($pid === GenerationManager::PACKET_SEND_CHUNK) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$len = ord($packet[$offset++]);
/** @var FullChunk $class */
$class = substr($packet, $offset, $len);
$offset += $len;
$level = $this->server->getLevel($levelID);
if ($level instanceof Level) {
$chunk = $class::fromBinary(substr($packet, $offset), $level->getProvider());
$this->receiveChunk($levelID, $chunk);
}
}
}
}
示例3: onCompletion
public function onCompletion(Server $server)
{
$level = $server->getLevel($this->levelId);
if ($level instanceof Level and $this->hasResult()) {
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult(), FullChunkDataPacket::ORDER_LAYERED);
}
}
示例4: receiveChunk
public function receiveChunk($levelID, FullChunk $chunk)
{
if (($level = $this->server->getLevel($levelID)) instanceof Level) {
$level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
} else {
$this->generationManager->closeLevel($levelID);
}
}
示例5: onCompletion
public function onCompletion(Server $server)
{
$level = $server->getLevel($this->levelId);
if ($level !== null) {
/** @var FullChunk $chunk */
$chunk = $this->chunkClass;
$chunk = $chunk::fromFastBinary($this->chunk, $level->getProvider());
if ($chunk === null) {
//TODO error
return;
}
$level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
}
}
示例6: onCompletion
public function onCompletion(Server $server)
{
$chunks = $this->getResult();
$plugin = $server->getPluginManager()->getPlugin("MineReset");
if ($plugin instanceof MineReset and $plugin->isEnabled()) {
$level = $server->getLevel($this->levelId);
if ($level != null) {
foreach ($chunks as $hash => $chunk) {
Level::getXZ($hash, $x, $z);
$level->setChunk($x, $z, $chunk);
}
}
$plugin->getRegionBlocker()->freeZone($this->regionId, $this->levelId);
}
}
示例7: onCompletion
public function onCompletion(Server $server)
{
$level = $server->getLevel($this->levelId);
if ($level instanceof Level and $this->hasResult()) {
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult(), FullChunkDataPacket::ORDER_LAYERED);
}
$this->levelId = null;
$this->chunkX = null;
$this->chunkZ = null;
$this->chunk = null;
$this->tiles = null;
$this->setResult(null, false);
unset($this->levelId);
unset($this->chunk);
unset($this->chunkX);
unset($this->chunkZ);
unset($this->tiles);
}
示例8: onCompletion
public function onCompletion(Server $server)
{
$level = $server->getLevel($this->levelId);
if ($level !== \null) {
if ($this->state === \false) {
$level->registerGenerator();
return;
}
/** @var FullChunk $chunkC */
$chunkC = $this->chunkClass;
$chunk = $chunkC::fromFastBinary($this->chunk, $level->getProvider());
if ($chunk === \null) {
//TODO error
return;
}
for ($i = 0; $i < 9; ++$i) {
if ($i === 4) {
continue;
}
$c = $this->{"chunk{$i}"};
if ($c !== \null) {
$c = $chunkC::fromFastBinary($c, $level->getProvider());
$level->generateChunkCallback($c->getX(), $c->getZ(), $c);
}
}
$level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
}
}
示例9: onCompletion
public function onCompletion(Server $server)
{
$level = $server->getLevel($this->levelId);
if ($level !== null) {
if ($this->state === false) {
$level->registerGenerator();
return;
}
/** @var FullChunk[] $chunks */
$chunks = [];
/** @var FullChunk $chunkC */
$chunkC = $this->chunkClass;
$chunks[0] = $chunkC::fromFastBinary($this->chunk00, $level->getProvider());
$chunks[1] = $chunkC::fromFastBinary($this->chunk01, $level->getProvider());
$chunks[2] = $chunkC::fromFastBinary($this->chunk02, $level->getProvider());
$chunks[3] = $chunkC::fromFastBinary($this->chunk10, $level->getProvider());
$chunk = $chunkC::fromFastBinary($this->chunk, $level->getProvider());
$chunks[5] = $chunkC::fromFastBinary($this->chunk12, $level->getProvider());
$chunks[6] = $chunkC::fromFastBinary($this->chunk20, $level->getProvider());
$chunks[7] = $chunkC::fromFastBinary($this->chunk21, $level->getProvider());
$chunks[8] = $chunkC::fromFastBinary($this->chunk22, $level->getProvider());
foreach ($chunks as $c) {
if ($c !== null) {
$level->generateChunkCallback($c->getX(), $c->getZ(), $c);
}
}
if ($chunk === null) {
//TODO error
return;
}
$level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
}
}