22declare(strict_types=1);
24namespace pocketmine\world\format\io;
26use pocketmine\world\format\PalettedBlockArray;
29use
function str_repeat;
41 $result = str_repeat(
"\x00", 256);
42 foreach($array as $i => $color){
43 $result[$i] = chr(($color >> 24) & 0xff);
52 if(strlen($biomes2d) !== 256){
53 throw new \InvalidArgumentException(
"Biome array is expected to be exactly 256 bytes");
55 $biomePalette =
new PalettedBlockArray(ord($biomes2d[0]));
56 for($x = 0; $x < 16; ++$x){
57 for($z = 0; $z < 16; ++$z){
58 $biomeId = ord($biomes2d[($z << 4) | $x]);
59 for($y = 0; $y < 16; ++$y){
60 $biomePalette->set($x, $y, $z, $biomeId);