mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 19:41:54 +00:00
Biome: Added UnknownBiome class to avoid astonishing behaviour on unknown biomes
This commit is contained in:
parent
8c6161a4f2
commit
4e3e807741
@ -107,7 +107,10 @@ abstract class Biome{
|
|||||||
* @return Biome
|
* @return Biome
|
||||||
*/
|
*/
|
||||||
public static function getBiome(int $id) : Biome{
|
public static function getBiome(int $id) : Biome{
|
||||||
return self::$biomes[$id] ?? self::$biomes[self::OCEAN];
|
if(self::$biomes[$id] === null){
|
||||||
|
self::register($id, new UnknownBiome());
|
||||||
|
}
|
||||||
|
return self::$biomes[$id];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clearPopulators(){
|
public function clearPopulators(){
|
||||||
|
34
src/pocketmine/level/biome/UnknownBiome.php
Normal file
34
src/pocketmine/level/biome/UnknownBiome.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* ____ _ _ __ __ _ __ __ ____
|
||||||
|
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||||
|
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||||
|
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||||
|
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* @author PocketMine Team
|
||||||
|
* @link http://www.pocketmine.net/
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace pocketmine\level\biome;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Polyfill class for biomes that are unknown to PocketMine-MP
|
||||||
|
*/
|
||||||
|
class UnknownBiome extends Biome{
|
||||||
|
|
||||||
|
public function getName() : string{
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user