diff --git a/src/world/format/BiomeArray.php b/src/world/format/BiomeArray.php index ca91fbea0..30a5d2cb0 100644 --- a/src/world/format/BiomeArray.php +++ b/src/world/format/BiomeArray.php @@ -25,6 +25,7 @@ namespace pocketmine\world\format; use function chr; use function ord; +use function str_repeat; use function strlen; final class BiomeArray{ @@ -42,6 +43,10 @@ final class BiomeArray{ $this->payload = $payload; } + public static function fill(int $biomeId) : self{ + return new BiomeArray(str_repeat(chr($biomeId), 256)); + } + private static function idx(int $x, int $z) : int{ if($x < 0 or $x >= 16 or $z < 0 or $z >= 16){ throw new \InvalidArgumentException("x and z must be in the range 0-15"); diff --git a/src/world/format/Chunk.php b/src/world/format/Chunk.php index c6d0fd668..286325807 100644 --- a/src/world/format/Chunk.php +++ b/src/world/format/Chunk.php @@ -35,12 +35,12 @@ use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\IntTag; use pocketmine\nbt\tag\StringTag; use pocketmine\player\Player; +use pocketmine\world\biome\Biome; use pocketmine\world\World; use function array_fill; use function array_filter; use function array_map; use function count; -use function str_repeat; class Chunk{ public const DIRTY_FLAG_TERRAIN = 1 << 0; @@ -106,7 +106,7 @@ class Chunk{ $val = ($this->subChunks->getSize() * 16); $this->heightMap = $heightMap ?? new HeightArray(array_fill(0, 256, $val)); - $this->biomeIds = $biomeIds ?? new BiomeArray(str_repeat("\x00", 256)); + $this->biomeIds = $biomeIds ?? BiomeArray::fill(Biome::OCEAN); $this->NBTtiles = $tiles; $this->NBTentities = $entities;