mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 16:51:42 +00:00
Chunk: Use an SplFixedArray for heightmap
this goes on 3.1 because it changes the behaviour of chunk cloning, which might possibly break some plugins, and this isn't a bug fix. This should see no change in behaviour other than a minor performance improvement and slight reduction in memory usage.
This commit is contained in:
parent
0f0d12bebc
commit
28a72a93b4
@ -75,8 +75,8 @@ class Chunk{
|
||||
/** @var Entity[] */
|
||||
protected $entities = [];
|
||||
|
||||
/** @var int[] */
|
||||
protected $heightMap = [];
|
||||
/** @var \SplFixedArray|int[] */
|
||||
protected $heightMap;
|
||||
|
||||
/** @var string */
|
||||
protected $biomeIds;
|
||||
@ -110,11 +110,11 @@ class Chunk{
|
||||
}
|
||||
|
||||
if(count($heightMap) === 256){
|
||||
$this->heightMap = $heightMap;
|
||||
$this->heightMap = \SplFixedArray::fromArray($heightMap);
|
||||
}else{
|
||||
assert(count($heightMap) === 0, "Wrong HeightMap value count, expected 256, got " . count($heightMap));
|
||||
$val = ($this->height * 16);
|
||||
$this->heightMap = array_fill(0, 256, $val);
|
||||
$this->heightMap = \SplFixedArray::fromArray(array_fill(0, 256, $val));
|
||||
}
|
||||
|
||||
if(strlen($biomeIds) === 256){
|
||||
@ -739,7 +739,7 @@ class Chunk{
|
||||
* @return int[]
|
||||
*/
|
||||
public function getHeightMapArray() : array{
|
||||
return $this->heightMap;
|
||||
return $this->heightMap->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user