diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index ccfdc8a09..6532caef0 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -268,10 +268,6 @@ class Level implements ChunkManager, Metadatable{ return PHP_INT_SIZE === 8 ? (($x & 0xFFFFFFF) << 36) | (($y & Level::Y_MASK) << 28) | ($z & 0xFFFFFFF) : $x . ":" . $y . ":" . $z; } - public static function chunkBlockHash(int $x, int $y, int $z) : int{ - return ($x << 12) | ($z << 8) | $y; - } - public static function getBlockXYZ($hash, &$x, &$y, &$z){ if(PHP_INT_SIZE === 8){ $x = $hash >> 36; diff --git a/src/pocketmine/level/format/generic/GenericChunk.php b/src/pocketmine/level/format/generic/GenericChunk.php index 2d0dca2f6..4fa9f255c 100644 --- a/src/pocketmine/level/format/generic/GenericChunk.php +++ b/src/pocketmine/level/format/generic/GenericChunk.php @@ -195,14 +195,14 @@ class GenericChunk implements Chunk{ } public function getBlockExtraData(int $x, int $y, int $z) : int{ - return $this->extraData[Level::chunkBlockHash($x, $y, $z)] ?? 0; + return $this->extraData[GenericChunk::chunkBlockHash($x, $y, $z)] ?? 0; } public function setBlockExtraData(int $x, int $y, int $z, int $data){ if($data === 0){ - unset($this->extraData[Level::chunkBlockHash($x, $y, $z)]); + unset($this->extraData[GenericChunk::chunkBlockHash($x, $y, $z)]); }else{ - $this->extraData[Level::chunkBlockHash($x, $y, $z)] = $data; + $this->extraData[GenericChunk::chunkBlockHash($x, $y, $z)] = $data; } $this->hasChanged = true; @@ -703,6 +703,20 @@ class GenericChunk implements Chunk{ return new GenericChunk($provider, $x, $z); } + /** + * Creates a block hash from chunk block coordinates. Used for extra data keys in chunk packets. + * @internal + * + * @param int $x 0-15 + * @param int $y 0-255 + * @param int $z 0-15 + * + * @return int + */ + public static function chunkBlockHash(int $x, int $y, int $z) : int{ + return ($x << 12) | ($z << 8) | $y; + } + /** * Re-orders a byte array (YZX -> XZY and vice versa) *