Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created April 26, 2020 16:00
Show Gist options
  • Save PJZ9n/73d343213256e48056be258a24f9804b to your computer and use it in GitHub Desktop.
Save PJZ9n/73d343213256e48056be258a24f9804b to your computer and use it in GitHub Desktop.
1チャンクしか生成させないやつ
<?php
declare(strict_types=1);
namespace sample;
use pocketmine\level\generator\GeneratorManager;
use pocketmine\level\generator\normal\Normal;
use pocketmine\plugin\PluginBase;
class Main extends PluginBase
{
public function onEnable(): void
{
//ジェネレーターを登録する
GeneratorManager::addGenerator(SingleChunkNormal::class, "SingleChunkNormal");
}
}
class SingleChunkNormal extends Normal
{
public function getName(): string
{
return "SingleChunkNormal";
}
public function populateChunk(int $chunkX, int $chunkZ): void
{
//チャンクを生成するときの処理
if ($chunkX === 0 || $chunkZ === 0) {
//X,Zが両方とも0だった場合のみチャンクを生成する
parent::populateChunk($chunkX, $chunkZ);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment