From c43431c9211339833641c59906385c7e8583d665 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 10 Aug 2014 12:27:49 +0200 Subject: [PATCH] Fixed #1826 Block damage values were swapped in McRegion --- .../{format => conversor}/pmf/LevelFormat.php | 2 +- .../level/{format => conversor}/pmf/PMF.php | 2 +- .../level/format/mcregion/Chunk.php | 36 ++--- .../level/format/pmf/ChunkSection.php | 151 ------------------ 4 files changed, 20 insertions(+), 171 deletions(-) rename src/pocketmine/level/{format => conversor}/pmf/LevelFormat.php (99%) rename src/pocketmine/level/{format => conversor}/pmf/PMF.php (98%) delete mode 100644 src/pocketmine/level/format/pmf/ChunkSection.php diff --git a/src/pocketmine/level/format/pmf/LevelFormat.php b/src/pocketmine/level/conversor/pmf/LevelFormat.php similarity index 99% rename from src/pocketmine/level/format/pmf/LevelFormat.php rename to src/pocketmine/level/conversor/pmf/LevelFormat.php index 04a645da0..2089a9e94 100644 --- a/src/pocketmine/level/format/pmf/LevelFormat.php +++ b/src/pocketmine/level/conversor/pmf/LevelFormat.php @@ -19,7 +19,7 @@ * */ -namespace pocketmine\level\format\pmf; +namespace pocketmine\level\conversor\pmf; use pocketmine\level\Level; use pocketmine\nbt\NBT; diff --git a/src/pocketmine/level/format/pmf/PMF.php b/src/pocketmine/level/conversor/pmf/PMF.php similarity index 98% rename from src/pocketmine/level/format/pmf/PMF.php rename to src/pocketmine/level/conversor/pmf/PMF.php index 34cf1b302..002d8a1a1 100644 --- a/src/pocketmine/level/format/pmf/PMF.php +++ b/src/pocketmine/level/conversor/pmf/PMF.php @@ -22,7 +22,7 @@ /** * PMF (PocketMine Format) handling */ -namespace pocketmine\level\format\pmf; +namespace pocketmine\level\conversor\pmf; use pocketmine\utils\MainLogger; diff --git a/src/pocketmine/level/format/mcregion/Chunk.php b/src/pocketmine/level/format/mcregion/Chunk.php index effdaed3a..2afdf00b3 100644 --- a/src/pocketmine/level/format/mcregion/Chunk.php +++ b/src/pocketmine/level/format/mcregion/Chunk.php @@ -98,9 +98,9 @@ class Chunk extends BaseFullChunk{ public function getBlockData($x, $y, $z){ $m = ord($this->data{($x << 10) + ($z << 6) + ($y >> 1)}); if(($y & 1) === 0){ - return $m >> 4; - }else{ return $m & 0x0F; + }else{ + return $m >> 4; } } @@ -108,9 +108,9 @@ class Chunk extends BaseFullChunk{ $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)); - }else{ $this->data{$i} = chr(($old_m & 0xf0) | ($data & 0x0f)); + }else{ + $this->data{$i} = chr((($data & 0x0f) << 4) | ($old_m & 0x0f)); } } @@ -119,9 +119,9 @@ class Chunk extends BaseFullChunk{ $blockId = ord($this->blocks{$i}); $m = ord($this->data{$i >> 1}); if(($y & 1) === 0){ - $meta = $m >> 4; - }else{ $meta = $m & 0x0F; + }else{ + $meta = $m >> 4; } } @@ -142,13 +142,13 @@ class Chunk extends BaseFullChunk{ $i >>= 1; $old_m = ord($this->data{$i}); if(($y & 1) === 0){ - $this->data{$i} = chr((($meta & 0x0f) << 4) | ($old_m & 0x0f)); - if((($old_m & 0xf0) >> 4) !== $meta){ + $this->data{$i} = chr(($old_m & 0xf0) | ($meta & 0x0f)); + if(($old_m & 0x0f) !== $meta){ $changed = true; } }else{ - $this->data{$i} = chr(($old_m & 0xf0) | ($meta & 0x0f)); - if(($old_m & 0x0f) !== $meta){ + $this->data{$i} = chr((($meta & 0x0f) << 4) | ($old_m & 0x0f)); + if((($old_m & 0xf0) >> 4) !== $meta){ $changed = true; } } @@ -160,9 +160,9 @@ class Chunk extends BaseFullChunk{ public function getBlockSkyLight($x, $y, $z){ $sl = ord($this->skyLight{($x << 10) + ($z << 6) + ($y >> 1)}); if(($y & 1) === 0){ - return $sl >> 4; - }else{ return $sl & 0x0F; + }else{ + return $sl >> 4; } } @@ -170,18 +170,18 @@ class Chunk extends BaseFullChunk{ $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)); - }else{ $this->skyLight{$i} = chr(($old_sl & 0xf0) | ($level & 0x0f)); + }else{ + $this->skyLight{$i} = chr((($level & 0x0f) << 4) | ($old_sl & 0x0f)); } } public function getBlockLight($x, $y, $z){ $l = ord($this->blockLight{($x << 10) + ($z << 6) + ($y >> 1)}); if(($y & 1) === 0){ - return $l >> 4; - }else{ return $l & 0x0F; + }else{ + return $l >> 4; } } @@ -189,9 +189,9 @@ class Chunk extends BaseFullChunk{ $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)); - }else{ $this->blockLight{$i} = chr(($old_l & 0xf0) | ($level & 0x0f)); + }else{ + $this->blockLight{$i} = chr((($level & 0x0f) << 4) | ($old_l & 0x0f)); } } diff --git a/src/pocketmine/level/format/pmf/ChunkSection.php b/src/pocketmine/level/format/pmf/ChunkSection.php deleted file mode 100644 index db5018c62..000000000 --- a/src/pocketmine/level/format/pmf/ChunkSection.php +++ /dev/null @@ -1,151 +0,0 @@ -section = $section; - }else{ - $this->section = str_repeat("\x00\x00\x00\x00\x00\x00\x00\x00", 1024); - } - } - - public function getBlockId($x, $y, $z){ - return $b = ord($this->section{$y + ($x << 5) + ($z << 9)}); - } - - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $i = ($x << 5) + ($z << 9); - $blockId = ord($this->section{$i + $y}); - $meta = ord($this->section{($y >> 1) + self::METADATA_OFFSET}); - } - - public function setBlock($x, $y, $z, $blockId = null, $meta = null){ - $i = ($x << 5) + ($z << 9); - if($blockId !== null){ - $this->section{$i + $y} = chr($blockId); - } - if($meta !== null){ - $i += ($y >> 1) + self::METADATA_OFFSET; - $m = ord($this->section{$i}); - if(($y & 1) === 0){ - $this->section{$i} = chr(($m & 0xf0) | ($meta & 0x0f)); - }else{ - $this->section{$i} = chr((($meta & 0x0f) << 4) | ($m & 0x0f)); - } - } - } - - public function setBlockId($x, $y, $z, $id){ - $this->section{$y + ($x << 5) + ($z << 9)} = chr($id & 0xff); - } - - public function getBlockData($x, $y, $z){ - $m = ord($this->section{($y >> 1) + self::METADATA_OFFSET + ($x << 5) + ($z << 9)}); - if(($y & 1) === 0){ - return $m & 0x0F; - }else{ - return $m >> 4; - } - } - - public function setBlockData($x, $y, $z, $data){ - $i = ($y >> 1) + self::METADATA_OFFSET + ($x << 5) + ($z << 9); - $m = ord($this->section{$i}); - if(($y & 1) === 0){ - $this->section{$i} = chr(($m & 0xf0) | ($data & 0x0f)); - }else{ - $this->section{$i} = chr((($data & 0x0f) << 4) | ($m & 0x0f)); - } - } - - public function getBlockIdColumn($x, $z){ - $column = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; - $i = ($x << 5) + ($z << 9); - for($y = 15; $y >= 0; --$y){ - $column{15 - $y} = $this->section{$i + $y}; - } - - return $column; - } - - public function getBlockDataColumn($x, $z){ - $column = "\x00\x00\x00\x00\x00\x00\x00\x00"; - $i = ($x << 5) + ($z << 9) + self::METADATA_OFFSET; - for($y = 7; $y >= 0; --$y){ - $column{7 - $y} = $this->section{$i + $y}; - } - - return $column; - } - - - public function getBlockLight($x, $y, $z){ - $l = ord($this->section{($y >> 1) + self::LIGHT_OFFSET + ($x << 5) + ($z << 9)}); - if(($y & 1) === 0){ - return $l & 0x0F; - }else{ - return $l >> 4; - } - } - - public function setBlockLight($x, $y, $z, $level){ - $i = ($y >> 1) + self::LIGHT_OFFSET + ($x << 5) + ($z << 9); - $l = ord($this->section{$i}); - if(($y & 1) === 0){ - $this->section{$i} = chr(($l & 0xf0) | ($level & 0x0f)); - }else{ - $this->section{$i} = chr((($level & 0x0f) << 4) | ($l & 0x0f)); - } - } - - public function getBlockSkyLight($x, $y, $z){ - $sl = ord($this->section{($y >> 1) + self::SKYLIGHT_OFFSET + ($x << 5) + ($z << 9)}); - if(($y & 1) === 0){ - return $sl & 0x0F; - }else{ - return $sl >> 4; - } - } - - public function setBlockSkyLight($x, $y, $z, $level){ - $i = ($y >> 1) + self::SKYLIGHT_OFFSET + ($x << 5) + ($z << 9); - $sl = ord($this->section{$i}); - if(($y & 1) === 0){ - $this->section{$i} = chr(($sl & 0xf0) | ($level & 0x0f)); - }else{ - $this->section{$i} = chr((($level & 0x0f) << 4) | ($sl & 0x0f)); - } - } -} \ No newline at end of file