mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
Fixed SimpleChunk metadata
This commit is contained in:
parent
4354d76cae
commit
429f7ffe8d
@ -143,7 +143,7 @@ class SimpleChunk{
|
||||
*/
|
||||
public function getBlockData($x, $y, $z){
|
||||
$m = ord($this->meta[$y >> 4]{(($y & 0x0f) << 7) + ($z << 3) + ($x >> 1)});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
return $m & 0x0F;
|
||||
}else{
|
||||
return $m >> 4;
|
||||
@ -159,7 +159,7 @@ class SimpleChunk{
|
||||
public function setBlockData($x, $y, $z, $data){
|
||||
$i = (($y & 0x0f) << 7) + ($z << 3) + ($x >> 1);
|
||||
$old_m = ord($this->meta[$y >> 4]{$i});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
$this->meta[$y >> 4]{$i} = chr(($old_m & 0xf0) | ($data & 0x0f));
|
||||
}else{
|
||||
$this->meta[$y >> 4]{$i} = chr((($data & 0x0f) << 4) | ($old_m & 0x0f));
|
||||
|
@ -53,7 +53,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
|
||||
public function getBlockData($x, $y, $z){
|
||||
$m = ord($this->data{($y << 7) + ($z << 3) + ($x >> 1)});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
return $m & 0x0F;
|
||||
}else{
|
||||
return $m >> 4;
|
||||
@ -63,7 +63,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
public function setBlockData($x, $y, $z, $data){
|
||||
$i = ($y << 7) + ($z << 3) + ($x >> 1);
|
||||
$old_m = ord($this->data{$i});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
$this->data{$i} = chr(($old_m & 0xf0) | ($data & 0x0f));
|
||||
}else{
|
||||
$this->data{$i} = chr((($data & 0x0f) << 4) | ($old_m & 0x0f));
|
||||
@ -74,7 +74,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
$i = ($y << 8) + ($z << 4) + $x;
|
||||
$blockId = ord($this->blocks{$i});
|
||||
$m = ord($this->data{$i >> 1});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
$meta = $m & 0x0F;
|
||||
}else{
|
||||
$meta = $m >> 4;
|
||||
@ -90,7 +90,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
if($meta !== null){
|
||||
$i >>= 1;
|
||||
$old_m = ord($this->data{$i});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
$this->data{$i} = chr(($old_m & 0xf0) | ($meta & 0x0f));
|
||||
}else{
|
||||
$this->data{$i} = chr((($meta & 0x0f) << 4) | ($old_m & 0x0f));
|
||||
@ -100,7 +100,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
|
||||
public function getBlockSkyLight($x, $y, $z){
|
||||
$sl = ord($this->skyLight{($y << 7) + ($z << 3) + ($x >> 1)});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
return $sl & 0x0F;
|
||||
}else{
|
||||
return $sl >> 4;
|
||||
@ -110,7 +110,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
public function setBlockSkyLight($x, $y, $z, $level){
|
||||
$i = ($y << 7) + ($z << 3) + ($x >> 1);
|
||||
$old_sl = ord($this->skyLight{$i});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
$this->skyLight{$i} = chr(($old_sl & 0xf0) | ($level & 0x0f));
|
||||
}else{
|
||||
$this->skyLight{$i} = chr((($level & 0x0f) << 4) | ($old_sl & 0x0f));
|
||||
@ -119,7 +119,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
|
||||
public function getBlockLight($x, $y, $z){
|
||||
$l = ord($this->blockLight{($y << 7) + ($z << 3) + ($x >> 1)});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
return $l & 0x0F;
|
||||
}else{
|
||||
return $l >> 4;
|
||||
@ -129,7 +129,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
public function setBlockLight($x, $y, $z, $level){
|
||||
$i = ($y << 7) + ($z << 3) + ($x >> 1);
|
||||
$old_l = ord($this->blockLight{$i});
|
||||
if(($y & 1) === 0){
|
||||
if(($x & 1) === 0){
|
||||
$this->blockLight{$i} = chr(($old_l & 0xf0) | ($level & 0x0f));
|
||||
}else{
|
||||
$this->blockLight{$i} = chr((($level & 0x0f) << 4) | ($old_l & 0x0f));
|
||||
@ -148,8 +148,14 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
|
||||
public function getBlockDataColumn($x, $z){
|
||||
$i = ($z << 3) + ($x >> 1);
|
||||
$column = "";
|
||||
for($y = 0; $y < 16; $y += 2){
|
||||
$column .= chr((ord($this->data{($y << 7) + $i}) & 0x0f) | ((ord($this->data{(($y + 1) << 7) + $i}) & 0x0f) << 4));
|
||||
if(($x & 1) === 0){
|
||||
for($y = 0; $y < 16; $y += 2){
|
||||
$column .= chr((ord($this->data{($y << 7) + $i}) & 0x0f) | ((ord($this->data{(($y + 1) << 7) + $i}) & 0x0f) << 4));
|
||||
}
|
||||
}else{
|
||||
for($y = 0; $y < 16; $y += 2){
|
||||
$column .= chr(((ord($this->data{($y << 7) + $i}) & 0xf0) >> 4) | (ord($this->data{(($y + 1) << 7) + $i}) & 0xf0));
|
||||
}
|
||||
}
|
||||
|
||||
return $column;
|
||||
|
Loading…
x
Reference in New Issue
Block a user