mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 17:41:46 +00:00
BiomeArray: added ::fill()
This commit is contained in:
parent
05470d0621
commit
59a3e8c096
@ -25,6 +25,7 @@ namespace pocketmine\world\format;
|
|||||||
|
|
||||||
use function chr;
|
use function chr;
|
||||||
use function ord;
|
use function ord;
|
||||||
|
use function str_repeat;
|
||||||
use function strlen;
|
use function strlen;
|
||||||
|
|
||||||
final class BiomeArray{
|
final class BiomeArray{
|
||||||
@ -42,6 +43,10 @@ final class BiomeArray{
|
|||||||
$this->payload = $payload;
|
$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{
|
private static function idx(int $x, int $z) : int{
|
||||||
if($x < 0 or $x >= 16 or $z < 0 or $z >= 16){
|
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");
|
throw new \InvalidArgumentException("x and z must be in the range 0-15");
|
||||||
|
@ -35,12 +35,12 @@ use pocketmine\nbt\tag\CompoundTag;
|
|||||||
use pocketmine\nbt\tag\IntTag;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
use pocketmine\nbt\tag\StringTag;
|
use pocketmine\nbt\tag\StringTag;
|
||||||
use pocketmine\player\Player;
|
use pocketmine\player\Player;
|
||||||
|
use pocketmine\world\biome\Biome;
|
||||||
use pocketmine\world\World;
|
use pocketmine\world\World;
|
||||||
use function array_fill;
|
use function array_fill;
|
||||||
use function array_filter;
|
use function array_filter;
|
||||||
use function array_map;
|
use function array_map;
|
||||||
use function count;
|
use function count;
|
||||||
use function str_repeat;
|
|
||||||
|
|
||||||
class Chunk{
|
class Chunk{
|
||||||
public const DIRTY_FLAG_TERRAIN = 1 << 0;
|
public const DIRTY_FLAG_TERRAIN = 1 << 0;
|
||||||
@ -106,7 +106,7 @@ class Chunk{
|
|||||||
|
|
||||||
$val = ($this->subChunks->getSize() * 16);
|
$val = ($this->subChunks->getSize() * 16);
|
||||||
$this->heightMap = $heightMap ?? new HeightArray(array_fill(0, 256, $val));
|
$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->NBTtiles = $tiles;
|
||||||
$this->NBTentities = $entities;
|
$this->NBTentities = $entities;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user