diff --git a/classes/API/LevelAPI.php b/classes/API/LevelAPI.php index 8fb82883..43f213ea 100644 --- a/classes/API/LevelAPI.php +++ b/classes/API/LevelAPI.php @@ -109,19 +109,25 @@ class LevelAPI{ return array(str_repeat("\x00", 256)); } $ordered = array(); - for($i = 0;$i < 0xff; ){ - $ordered[$i] = str_repeat("\x00", $i); - for($j = 0; $j < $columnsPerPacket; ++$j){ - if(($i + $j) > 0xff){ - break; + $i = 0; + $cnt = 0; + $ordered[$i] = ""; + for($z = 0; $z < 16; ++$z){ + for($x = 0; $x < 16; ++$x){ + if($cnt >= $columnsPerPacket){ + ++$i; + $ordered[$i] = str_repeat("\x00", $i * $columnsPerPacket); + $cnt = 0; } $ordered[$i] .= "\xff"; + $block = $this->map->getChunkColumn($X, $Z, $x, $z, 0); + $meta = $this->map->getChunkColumn($X, $Z, $x, $z, 1); for($k = 0; $k < 8; ++$k){ - $ordered[$i] .= substr($c[0][$i+$j], $k << 4, 16); //Block data - $ordered[$i] .= substr($c[1][$i+$j], $k << 3, 8); //Meta data + $ordered[$i] .= substr($block, $k << 4, 16); + $ordered[$i] .= substr($meta, $k << 3, 8); } + ++$cnt; } - $i += $columnsPerPacket; } return $ordered; } diff --git a/classes/ChunkParser.class.php b/classes/ChunkParser.class.php index 28c6d393..eb0e088f 100644 --- a/classes/ChunkParser.class.php +++ b/classes/ChunkParser.class.php @@ -74,7 +74,7 @@ class ChunkParser{ } private function getOffset($X, $Z, $sectors = 21){ - return 0x1000 + (($Z * $sectors) << 12) + (($X * $sectors) << 16); + return 0x1000 + (($X * $sectors) << 12) + (($Z * $sectors) << 16); } private function getOffsetLocation($X, $Z){ @@ -162,7 +162,7 @@ class ChunkParser{ $Z = $z >> 4; $aX = $x - ($X << 4); $aZ = $z - ($Z << 4); - $index = $aX + ($aZ << 4); + $index = $aZ + ($aX << 4); $block = ord($this->map[$X][$Z][0][$index]{$y}); $meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); if(($y & 1) === 0){ @@ -173,6 +173,11 @@ class ChunkParser{ return array($block, $meta); } + public function getChunkColumn($X, $Z, $x, $z, $type = 0){ + $index = $z + ($x << 4); + return $this->map[$X][$Z][$type][$index]; + } + public function setBlock($x, $y, $z, $block, $meta = 0){ $x = (int) $x; $y = (int) $y; @@ -181,7 +186,7 @@ class ChunkParser{ $Z = $z >> 4; $aX = $x - ($X << 4); $aZ = $z - ($Z << 4); - $index = $aX + ($aZ << 4); + $index = $aZ + ($aX << 4); $this->map[$X][$Z][0][$index]{$y} = chr($block); $old_meta = ord($this->map[$X][$Z][1][$index]{$y >> 1}); if(($y & 1) === 0){ diff --git a/classes/Session.class.php b/classes/Session.class.php index e7b64c26..eaf45274 100644 --- a/classes/Session.class.php +++ b/classes/Session.class.php @@ -304,7 +304,7 @@ class Session{ "x" => '.$data["x"].', "z" => '.$data["z"].', "data" => $d, - )); + ), true); } '); console("[INTERNAL] Chunk X ".$data["x"]." Z ".$data["z"]." requested", true, true, 3);