mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-10 05:34:54 +00:00
Switch to BiomeRegistry
I accidentally committed this in c869a7f099237ca189dc574fe3df6e7630eeec51 and didn't notice. I intended to use it and never noticed.
This commit is contained in:
parent
f991961d9a
commit
b176f4c12f
@ -90,7 +90,6 @@ use pocketmine\utils\Terminal;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\utils\Utils;
|
||||
use pocketmine\uuid\UUID;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\format\io\WorldProviderManager;
|
||||
use pocketmine\world\format\io\WritableWorldProvider;
|
||||
use pocketmine\world\generator\Generator;
|
||||
@ -936,8 +935,6 @@ class Server{
|
||||
|
||||
$this->commandMap = new SimpleCommandMap($this);
|
||||
|
||||
Biome::init();
|
||||
|
||||
$this->craftingManager = CraftingManagerFromDataHelper::make(\pocketmine\RESOURCE_PATH . '/vanilla/recipes.json');
|
||||
|
||||
$this->resourceManager = new ResourcePackManager($this->getDataPath() . "resource_packs" . DIRECTORY_SEPARATOR, $this->logger);
|
||||
|
@ -64,6 +64,7 @@ use pocketmine\timings\Timings;
|
||||
use pocketmine\utils\Limits;
|
||||
use pocketmine\utils\ReversePriorityQueue;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\biome\BiomeRegistry;
|
||||
use pocketmine\world\format\Chunk;
|
||||
use pocketmine\world\format\io\exception\CorruptedChunkException;
|
||||
use pocketmine\world\format\io\WritableWorldProvider;
|
||||
@ -1879,7 +1880,7 @@ class World implements ChunkManager{
|
||||
}
|
||||
|
||||
public function getBiome(int $x, int $z) : Biome{
|
||||
return Biome::getBiome($this->getBiomeId($x, $z));
|
||||
return BiomeRegistry::getInstance()->getBiome($this->getBiomeId($x, $z));
|
||||
}
|
||||
|
||||
public function setBiomeId(int $x, int $z, int $biomeId) : void{
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\world\biome;
|
||||
|
||||
use pocketmine\block\Block;
|
||||
use pocketmine\block\utils\TreeType;
|
||||
use pocketmine\utils\Random;
|
||||
use pocketmine\world\ChunkManager;
|
||||
use pocketmine\world\generator\populator\Populator;
|
||||
@ -50,12 +49,6 @@ abstract class Biome{
|
||||
|
||||
public const MAX_BIOMES = 256;
|
||||
|
||||
/**
|
||||
* @var Biome[]|\SplFixedArray
|
||||
* @phpstan-var \SplFixedArray<Biome>
|
||||
*/
|
||||
private static $biomes;
|
||||
|
||||
/** @var int */
|
||||
private $id;
|
||||
/** @var bool */
|
||||
@ -77,37 +70,6 @@ abstract class Biome{
|
||||
/** @var float */
|
||||
protected $temperature = 0.5;
|
||||
|
||||
protected static function register(int $id, Biome $biome) : void{
|
||||
self::$biomes[$id] = $biome;
|
||||
$biome->setId($id);
|
||||
}
|
||||
|
||||
public static function init() : void{
|
||||
self::$biomes = new \SplFixedArray(self::MAX_BIOMES);
|
||||
|
||||
self::register(self::OCEAN, new OceanBiome());
|
||||
self::register(self::PLAINS, new PlainBiome());
|
||||
self::register(self::DESERT, new DesertBiome());
|
||||
self::register(self::MOUNTAINS, new MountainsBiome());
|
||||
self::register(self::FOREST, new ForestBiome());
|
||||
self::register(self::TAIGA, new TaigaBiome());
|
||||
self::register(self::SWAMP, new SwampBiome());
|
||||
self::register(self::RIVER, new RiverBiome());
|
||||
|
||||
self::register(self::ICE_PLAINS, new IcePlainsBiome());
|
||||
|
||||
self::register(self::SMALL_MOUNTAINS, new SmallMountainsBiome());
|
||||
|
||||
self::register(self::BIRCH_FOREST, new ForestBiome(TreeType::BIRCH()));
|
||||
}
|
||||
|
||||
public static function getBiome(int $id) : Biome{
|
||||
if(self::$biomes[$id] === null){
|
||||
self::register($id, new UnknownBiome());
|
||||
}
|
||||
return self::$biomes[$id];
|
||||
}
|
||||
|
||||
public function clearPopulators() : void{
|
||||
$this->populators = [];
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
||||
namespace pocketmine\world\generator;
|
||||
|
||||
use pocketmine\scheduler\AsyncTask;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\SimpleChunkManager;
|
||||
use pocketmine\world\World;
|
||||
use function igbinary_serialize;
|
||||
@ -60,7 +59,6 @@ class GeneratorRegisterTask extends AsyncTask{
|
||||
}
|
||||
|
||||
public function onRun() : void{
|
||||
Biome::init();
|
||||
$manager = new SimpleChunkManager($this->worldHeight);
|
||||
$this->worker->saveToThreadStore("generation.world{$this->worldId}.manager", $manager);
|
||||
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\world\generator\biome;
|
||||
|
||||
use pocketmine\utils\Random;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\biome\BiomeRegistry;
|
||||
use pocketmine\world\biome\UnknownBiome;
|
||||
use pocketmine\world\generator\noise\Simplex;
|
||||
|
||||
@ -55,9 +56,10 @@ abstract class BiomeSelector{
|
||||
public function recalculate() : void{
|
||||
$this->map = new \SplFixedArray(64 * 64);
|
||||
|
||||
$biomeRegistry = BiomeRegistry::getInstance();
|
||||
for($i = 0; $i < 64; ++$i){
|
||||
for($j = 0; $j < 64; ++$j){
|
||||
$biome = Biome::getBiome($this->lookup($i / 63, $j / 63));
|
||||
$biome = $biomeRegistry->getBiome($this->lookup($i / 63, $j / 63));
|
||||
if($biome instanceof UnknownBiome){
|
||||
throw new \RuntimeException("Unknown biome returned by selector with ID " . $biome->getId());
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\world\generator\hell;
|
||||
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\biome\BiomeRegistry;
|
||||
use pocketmine\world\ChunkManager;
|
||||
use pocketmine\world\generator\Generator;
|
||||
use pocketmine\world\generator\InvalidGeneratorOptionsException;
|
||||
@ -84,9 +85,7 @@ class Nether extends Generator{
|
||||
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
|
||||
$biome = Biome::getBiome(Biome::HELL);
|
||||
$chunk->setBiomeId($x, $z, $biome->getId());
|
||||
$chunk->setBiomeId($x, $z, Biome::HELL);
|
||||
|
||||
for($y = 0; $y < 128; ++$y){
|
||||
if($y === 0 or $y === 127){
|
||||
@ -117,7 +116,7 @@ class Nether extends Generator{
|
||||
}
|
||||
|
||||
$chunk = $world->getChunk($chunkX, $chunkZ);
|
||||
$biome = Biome::getBiome($chunk->getBiomeId(7, 7));
|
||||
$biome = BiomeRegistry::getInstance()->getBiome($chunk->getBiomeId(7, 7));
|
||||
$biome->populateChunk($world, $chunkX, $chunkZ, $this->random);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\world\generator\normal;
|
||||
|
||||
use pocketmine\block\VanillaBlocks;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\biome\BiomeRegistry;
|
||||
use pocketmine\world\ChunkManager;
|
||||
use pocketmine\world\generator\biome\BiomeSelector;
|
||||
use pocketmine\world\generator\Gaussian;
|
||||
@ -227,7 +228,7 @@ class Normal extends Generator{
|
||||
}
|
||||
|
||||
$chunk = $world->getChunk($chunkX, $chunkZ);
|
||||
$biome = Biome::getBiome($chunk->getBiomeId(7, 7));
|
||||
$biome = BiomeRegistry::getInstance()->getBiome($chunk->getBiomeId(7, 7));
|
||||
$biome->populateChunk($world, $chunkX, $chunkZ, $this->random);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ use pocketmine\block\BlockFactory;
|
||||
use pocketmine\block\BlockLegacyIds;
|
||||
use pocketmine\block\Liquid;
|
||||
use pocketmine\utils\Random;
|
||||
use pocketmine\world\biome\Biome;
|
||||
use pocketmine\world\biome\BiomeRegistry;
|
||||
use pocketmine\world\ChunkManager;
|
||||
use function count;
|
||||
use function min;
|
||||
@ -37,9 +37,10 @@ class GroundCover extends Populator{
|
||||
public function populate(ChunkManager $world, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
$chunk = $world->getChunk($chunkX, $chunkZ);
|
||||
$factory = BlockFactory::getInstance();
|
||||
$biomeRegistry = BiomeRegistry::getInstance();
|
||||
for($x = 0; $x < 16; ++$x){
|
||||
for($z = 0; $z < 16; ++$z){
|
||||
$biome = Biome::getBiome($chunk->getBiomeId($x, $z));
|
||||
$biome = $biomeRegistry->getBiome($chunk->getBiomeId($x, $z));
|
||||
$cover = $biome->getGroundCover();
|
||||
if(count($cover) > 0){
|
||||
$diffY = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user