Fixed chunk rotation on McRegion-based worlds

This commit is contained in:
Shoghi Cervantes
2014-08-01 11:52:13 +02:00
parent 171de939cd
commit 7c68e42a86
2 changed files with 30 additions and 18 deletions

View File

@ -78,15 +78,15 @@ class Chunk extends BaseFullChunk{
}
public function getBlockId($x, $y, $z){
return ord($this->blocks{($z << 11) + ($x << 7) + $y});
return ord($this->blocks{($x << 11) + ($z << 7) + $y});
}
public function setBlockId($x, $y, $z, $id){
$this->blocks{($z << 11) + ($x << 7) + $y} = chr($id);
$this->blocks{($x << 11) + ($z << 7) + $y} = chr($id);
}
public function getBlockData($x, $y, $z){
$m = ord($this->data{($z << 10) + ($x << 6) + ($y >> 1)});
$m = ord($this->data{($x << 10) + ($z << 6) + ($y >> 1)});
if(($y & 1) === 0){
return $m >> 4;
}else{
@ -95,7 +95,7 @@ class Chunk extends BaseFullChunk{
}
public function setBlockData($x, $y, $z, $data){
$i = ($z << 10) + ($x << 6) + ($y >> 1);
$i = ($x << 10) + ($z << 6) + ($y >> 1);
$old_m = ord($this->data{$i});
if(($y & 1) === 0){
$this->data{$i} = chr((($data & 0x0f) << 4) | ($old_m & 0x0f));
@ -105,7 +105,7 @@ class Chunk extends BaseFullChunk{
}
public function getBlock($x, $y, $z, &$blockId, &$meta = null){
$i = ($z << 11) + ($x << 7) + $y;
$i = ($x << 11) + ($z << 7) + $y;
$blockId = ord($this->blocks{$i});
$m = ord($this->data{$i >> 1});
if(($y & 1) === 0){
@ -116,7 +116,7 @@ class Chunk extends BaseFullChunk{
}
public function setBlock($x, $y, $z, $blockId = null, $meta = null){
$i = ($z << 11) + ($x << 7) + $y;
$i = ($x << 11) + ($z << 7) + $y;
$changed = false;
@ -148,7 +148,7 @@ class Chunk extends BaseFullChunk{
}
public function getBlockSkyLight($x, $y, $z){
$sl = ord($this->skyLight{($z << 10) + ($x << 6) + ($y >> 1)});
$sl = ord($this->skyLight{($x << 10) + ($z << 6) + ($y >> 1)});
if(($y & 1) === 0){
return $sl >> 4;
}else{
@ -157,7 +157,7 @@ class Chunk extends BaseFullChunk{
}
public function setBlockSkyLight($x, $y, $z, $level){
$i = ($z << 10) + ($x << 6) + ($y >> 1);
$i = ($x << 10) + ($z << 6) + ($y >> 1);
$old_sl = ord($this->skyLight{$i});
if(($y & 1) === 0){
$this->skyLight{$i} = chr((($level & 0x0f) << 4) | ($old_sl & 0x0f));
@ -167,7 +167,7 @@ class Chunk extends BaseFullChunk{
}
public function getBlockLight($x, $y, $z){
$l = ord($this->blockLight{($z << 10) + ($x << 6) + ($y >> 1)});
$l = ord($this->blockLight{($x << 10) + ($z << 6) + ($y >> 1)});
if(($y & 1) === 0){
return $l >> 4;
}else{
@ -176,7 +176,7 @@ class Chunk extends BaseFullChunk{
}
public function setBlockLight($x, $y, $z, $level){
$i = ($z << 10) + ($x << 6) + ($y >> 1);
$i = ($x << 10) + ($z << 6) + ($y >> 1);
$old_l = ord($this->blockLight{$i});
if(($y & 1) === 0){
$this->blockLight{$i} = chr((($level & 0x0f) << 4) | ($old_l & 0x0f));
@ -186,19 +186,19 @@ class Chunk extends BaseFullChunk{
}
public function getBlockIdColumn($x, $z){
return substr($this->blocks, ($z << 11) + ($x << 7), 128);
return substr($this->blocks, ($x << 11) + ($z << 7), 128);
}
public function getBlockDataColumn($x, $z){
return substr($this->data, ($z << 10) + ($x << 6), 64);
return substr($this->data, ($x << 10) + ($z << 6), 64);
}
public function getBlockSkyLightColumn($x, $z){
return substr($this->skyLight, ($z << 10) + ($x << 6), 64);
return substr($this->skyLight, ($x << 10) + ($z << 6), 64);
}
public function getBlockLightColumn($x, $z){
return substr($this->blockLight, ($z << 10) + ($x << 6), 64);
return substr($this->blockLight, ($x << 10) + ($z << 6), 64);
}
/**