Improved block reading

* Created global block states array
* Improved Level->getBlock() using block states
* Improved Level->getBlock() for 64-bit systems
* Added Level->getFullBlock()
* Added FullChunk->getFullBlock()
* Added Chunk->getFullBlock()
* Added ChunkSection->getFullBlock()
* Deprecated FullChunk->getBlock()
* Deprecated Chunk->getBlock()
* Deprecated ChunkSection->getBlock()
This commit is contained in:
Shoghi Cervantes
2014-12-08 20:54:47 +01:00
parent 1041bb0e6a
commit 3bb2f12cde
9 changed files with 87 additions and 27 deletions

View File

@ -120,17 +120,21 @@ class Chunk extends BaseFullChunk{
$this->hasChanged = true;
}
public function getBlock($x, $y, $z, &$blockId, &$meta = null){
public function getFullBlock($x, $y, $z){
$i = ($x << 11) + ($z << 7) + $y;
$blockId = ord($this->blocks{$i});
$m = ord($this->data{$i >> 1});
if(($y & 1) === 0){
$meta = $m & 0x0F;
return (ord($this->blocks{$i}) << 4) | (ord($this->data{$i >> 1}) & 0x0F);
}else{
$meta = $m >> 4;
return (ord($this->blocks{$i}) << 4) | (ord($this->data{$i >> 1}) >> 4);
}
}
public function getBlock($x, $y, $z, &$blockId, &$meta = null){
$full = $this->getFullBlock($x, $y, $z);
$blockId = $full >> 4;
$meta = $full & 0x0f;
}
public function setBlock($x, $y, $z, $blockId = null, $meta = null){
$i = ($x << 11) + ($z << 7) + $y;