Added HeightMap get/set methods on chunks, Level

This commit is contained in:
Shoghi Cervantes
2014-12-07 18:02:07 +01:00
parent 964bf98ca6
commit e4557a2e8e
6 changed files with 84 additions and 23 deletions

View File

@ -54,6 +54,8 @@ abstract class BaseFullChunk implements FullChunk{
protected $blockLight;
protected $heightMap;
protected $NBTtiles;
protected $NBTentities;
@ -76,10 +78,11 @@ abstract class BaseFullChunk implements FullChunk{
* @param string $blockLight
* @param string $biomeIds
* @param int[] $biomeColors
* @param int[] $heightMap
* @param Compound[] $entities
* @param Compound[] $tiles
*/
protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, $biomeIds = null, array $biomeColors = [], array $entities = [], array $tiles = []){
protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, $biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
$this->provider = $provider;
$this->x = (int) $x;
$this->z = (int) $z;
@ -101,6 +104,12 @@ abstract class BaseFullChunk implements FullChunk{
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
}
if(count($heightMap) === 256){
$this->heightMap = 256;
}else{
$this->heightMap = array_fill(0, 256, 127);
}
$this->NBTtiles = $tiles;
$this->NBTentities = $entities;
}
@ -214,6 +223,14 @@ abstract class BaseFullChunk implements FullChunk{
$this->biomeColors[($z << 4) + $x] = 0 | (($R & 0xFF) << 16) | (($G & 0xFF) << 8) | ($B & 0xFF);
}
public function getHeightMap($x, $z){
return $this->heightMap[($z << 4) + $x];
}
public function setHeightMap($x, $z, $value){
$this->heightMap[($z << 4) + $x] = $value;
}
public function getHighestBlockAt($x, $z){
$column = $this->getBlockIdColumn($x, $z);
for($y = 127; $y >= 0; --$y){
@ -324,6 +341,10 @@ abstract class BaseFullChunk implements FullChunk{
return $this->biomeColors;
}
public function getHeightMapArray(){
return $this->heightMap;
}
public function hasChanged(){
return $this->hasChanged;
}