mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 20:58:34 +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[] */
|
/** @var Entity[] */
|
||||||
protected $entities = [];
|
protected $entities = [];
|
||||||
|
|
||||||
/** @var int[] */
|
/** @var \SplFixedArray|int[] */
|
||||||
protected $heightMap = [];
|
protected $heightMap;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $biomeIds;
|
protected $biomeIds;
|
||||||
@ -110,11 +110,11 @@ class Chunk{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(count($heightMap) === 256){
|
if(count($heightMap) === 256){
|
||||||
$this->heightMap = $heightMap;
|
$this->heightMap = \SplFixedArray::fromArray($heightMap);
|
||||||
}else{
|
}else{
|
||||||
assert(count($heightMap) === 0, "Wrong HeightMap value count, expected 256, got " . count($heightMap));
|
assert(count($heightMap) === 0, "Wrong HeightMap value count, expected 256, got " . count($heightMap));
|
||||||
$val = ($this->height * 16);
|
$val = ($this->height * 16);
|
||||||
$this->heightMap = array_fill(0, 256, $val);
|
$this->heightMap = \SplFixedArray::fromArray(array_fill(0, 256, $val));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(strlen($biomeIds) === 256){
|
if(strlen($biomeIds) === 256){
|
||||||
@ -739,7 +739,7 @@ class Chunk{
|
|||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
public function getHeightMapArray() : array{
|
public function getHeightMapArray() : array{
|
||||||
return $this->heightMap;
|
return $this->heightMap->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user