35 private \SplFixedArray $array;
42 if(count($values) !== 256){
43 throw new \InvalidArgumentException(
"Expected exactly 256 values");
45 $this->array = \SplFixedArray::fromArray($values);
48 public static function fill(
int $value) : self{
49 return new self(array_fill(0, 256, $value));
52 private static function idx(
int $x,
int $z) : int{
53 if($x < 0 || $x >= 16 || $z < 0 || $z >= 16){
54 throw new \InvalidArgumentException(
"x and z must be in the range 0-15");
56 return ($z << 4) | $x;
59 public function get(
int $x,
int $z) : int{
60 return $this->array[self::idx($x, $z)];
63 public function set(
int $x,
int $z,
int $height) : void{
64 $this->array[self::idx($x, $z)] = $height;
72 return $this->array->toArray();
75 public function __clone(){
76 $this->array = clone $this->array;