Noclip in spectator mode, changed chunk format

This commit is contained in:
Shoghi Cervantes
2015-04-29 12:29:59 +02:00
parent 3872a21474
commit c2b3f7cd7f
6 changed files with 75 additions and 39 deletions

View File

@ -40,9 +40,6 @@ abstract class BaseFullChunk implements FullChunk{
/** @var Tile[] */
protected $tileList = [];
/** @var string */
protected $biomeIds;
/** @var int[256] */
protected $biomeColors;
@ -92,18 +89,20 @@ abstract class BaseFullChunk implements FullChunk{
$this->skyLight = $skyLight;
$this->blockLight = $blockLight;
if(strlen($biomeIds) === 256){
$this->biomeIds = $biomeIds;
}else{
$this->biomeIds = str_repeat("\x01", 256);
}
if(count($biomeColors) === 256){
$this->biomeColors = $biomeColors;
}else{
$this->biomeColors = array_fill(0, 256, Binary::readInt("\x00\x85\xb2\x4a"));
}
if(strlen($biomeIds) !== 256){
$biomeIds = str_repeat("\x01", 256);
}
for($i = 0; $i < 256; ++$i){
$this->biomeColors[$i] = ($this->biomeColors[$i] & 0xFFFFFF) | (ord($biomeIds{$i}) << 24);
}
if(count($heightMap) === 256){
$this->heightMap = $heightMap;
}else{
@ -161,9 +160,16 @@ abstract class BaseFullChunk implements FullChunk{
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->stopTiming();
for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){
$this->setHeightMap($x, $z, $this->getHighestBlockAt($x, $z));
}
}
$this->NBTentities = null;
$this->NBTtiles = null;
$this->hasChanged = false;
}
}
@ -204,12 +210,12 @@ abstract class BaseFullChunk implements FullChunk{
}
public function getBiomeId($x, $z){
return ord($this->biomeIds{($z << 4) + $x});
return ($this->biomeColors[($z << 4) + $x] & 0xFF000000) >> 24;
}
public function setBiomeId($x, $z, $biomeId){
$this->hasChanged = true;
$this->biomeIds{($z << 4) + $x} = chr($biomeId);
$this->biomeColors[($z << 4) + $x] = ($this->biomeColors[($z << 4) + $x] & 0xFFFFFF) | ($biomeId << 24);
}
public function getBiomeColor($x, $z){
@ -220,7 +226,7 @@ abstract class BaseFullChunk implements FullChunk{
public function setBiomeColor($x, $z, $R, $G, $B){
$this->hasChanged = true;
$this->biomeColors[($z << 4) + $x] = 0 | (($R & 0xFF) << 16) | (($G & 0xFF) << 8) | ($B & 0xFF);
$this->biomeColors[($z << 4) + $x] = ($this->biomeColors[($z << 4) + $x] & 0xFF000000) | (($R & 0xFF) << 16) | (($G & 0xFF) << 8) | ($B & 0xFF);
}
public function getHeightMap($x, $z){
@ -338,7 +344,11 @@ abstract class BaseFullChunk implements FullChunk{
}
public function getBiomeIdArray(){
return $this->biomeIds;
$ids = "";
foreach($this->biomeColors as $d){
$ids .= chr(($d & 0xFF000000) >> 24);
}
return $ids;
}
public function getBiomeColorArray(){