SubChunk: remove legacy crap

This commit is contained in:
Dylan K. Taylor 2019-02-23 13:18:37 +00:00
parent 66a1b35767
commit 991483938c
4 changed files with 4 additions and 69 deletions

View File

@ -77,22 +77,6 @@ class EmptySubChunk implements SubChunkInterface{
return -1; return -1;
} }
public function getBlockIdColumn(int $x, int $z) : string{
return "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
}
public function getBlockDataColumn(int $x, int $z) : string{
return "\x00\x00\x00\x00\x00\x00\x00\x00";
}
public function getBlockLightColumn(int $x, int $z) : string{
return "\x00\x00\x00\x00\x00\x00\x00\x00";
}
public function getBlockSkyLightColumn(int $x, int $z) : string{
return "\xff\xff\xff\xff\xff\xff\xff\xff";
}
public function getBlockIdArray() : string{ public function getBlockIdArray() : string{
return str_repeat("\x00", 4096); return str_repeat("\x00", 4096);
} }

View File

@ -30,7 +30,6 @@ use function defined;
use function ord; use function ord;
use function str_repeat; use function str_repeat;
use function strlen; use function strlen;
use function substr;
use function substr_count; use function substr_count;
if(!defined(__NAMESPACE__ . '\ZERO_NIBBLE_ARRAY')){ if(!defined(__NAMESPACE__ . '\ZERO_NIBBLE_ARRAY')){
@ -145,22 +144,6 @@ class SubChunk implements SubChunkInterface{
return -1; //highest block not in this subchunk return -1; //highest block not in this subchunk
} }
public function getBlockIdColumn(int $x, int $z) : string{
return substr($this->ids, ($x << 8) | ($z << 4), 16);
}
public function getBlockDataColumn(int $x, int $z) : string{
return substr($this->data, ($x << 7) | ($z << 3), 8);
}
public function getBlockLightColumn(int $x, int $z) : string{
return substr($this->blockLight, ($x << 7) | ($z << 3), 8);
}
public function getBlockSkyLightColumn(int $x, int $z) : string{
return substr($this->skyLight, ($x << 7) | ($z << 3), 8);
}
public function getBlockIdArray() : string{ public function getBlockIdArray() : string{
assert(strlen($this->ids) === 4096, "Wrong length of ID array, expecting 4096 bytes, got " . strlen($this->ids)); assert(strlen($this->ids) === 4096, "Wrong length of ID array, expecting 4096 bytes, got " . strlen($this->ids));
return $this->ids; return $this->ids;

View File

@ -116,38 +116,6 @@ interface SubChunkInterface{
*/ */
public function getHighestBlockAt(int $x, int $z) : int; public function getHighestBlockAt(int $x, int $z) : int;
/**
* @param int $x
* @param int $z
*
* @return string
*/
public function getBlockIdColumn(int $x, int $z) : string;
/**
* @param int $x
* @param int $z
*
* @return string
*/
public function getBlockDataColumn(int $x, int $z) : string;
/**
* @param int $x
* @param int $z
*
* @return string
*/
public function getBlockLightColumn(int $x, int $z) : string;
/**
* @param int $x
* @param int $z
*
* @return string
*/
public function getBlockSkyLightColumn(int $x, int $z) : string;
/** /**
* @return string * @return string
*/ */

View File

@ -65,10 +65,10 @@ class McRegion extends RegionLevelProvider{
for($z = 0; $z < 16; ++$z){ for($z = 0; $z < 16; ++$z){
for($y = 0; $y < 8; ++$y){ for($y = 0; $y < 8; ++$y){
$subChunk = $subChunks[$y]; $subChunk = $subChunks[$y];
$ids .= $subChunk->getBlockIdColumn($x, $z); $ids .= substr($subChunk->getBlockIdArray(), ($x << 8) | ($z << 4), 16);
$data .= $subChunk->getBlockDataColumn($x, $z); $data .= substr($subChunk->getBlockDataArray(), ($x << 7) | ($z << 3), 8);
$skyLight .= $subChunk->getBlockSkyLightColumn($x, $z); $skyLight .= substr($subChunk->getBlockSkyLightArray(), ($x << 7) | ($z << 3), 8);
$blockLight .= $subChunk->getBlockLightColumn($x, $z); $blockLight .= substr($subChunk->getBlockLightArray(), ($x << 7) | ($z << 3), 8);
} }
} }
} }