mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-20 16:00:20 +00:00
ext-morton is now required and used for World::chunkHash() and World::chunkBlockHash()
This commit is contained in:
parent
2d839db47e
commit
0f9d5f7011
@ -1 +1 @@
|
||||
Subproject commit bc8e1cf0015d9c74feaecdb5bf6c3bf9b9e80489
|
||||
Subproject commit 7da8425e677c68d8884788f2917fee2804f25c5a
|
@ -1 +1 @@
|
||||
Subproject commit 0400f85329092be8ffaaca1b6921a18fae7848e1
|
||||
Subproject commit c8c0557ddf159413352de2a74a013d40fbfe3a69
|
@ -20,6 +20,7 @@
|
||||
"ext-json": "*",
|
||||
"ext-leveldb": "^0.2.1",
|
||||
"ext-mbstring": "*",
|
||||
"ext-morton": "^0.1.0",
|
||||
"ext-openssl": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-phar": "*",
|
||||
|
3
composer.lock
generated
3
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "7fdb5abb5388f1e92229efff1f783d40",
|
||||
"content-hash": "cfc91763774445e65e366642b2efdde1",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/json-comment",
|
||||
@ -3104,6 +3104,7 @@
|
||||
"ext-json": "*",
|
||||
"ext-leveldb": "^0.2.1",
|
||||
"ext-mbstring": "*",
|
||||
"ext-morton": "^0.1.0",
|
||||
"ext-openssl": "*",
|
||||
"ext-pcre": "*",
|
||||
"ext-phar": "*",
|
||||
|
@ -88,6 +88,7 @@ namespace pocketmine {
|
||||
"json" => "JSON",
|
||||
"leveldb" => "LevelDB",
|
||||
"mbstring" => "Multibyte String",
|
||||
"morton" => "morton",
|
||||
"openssl" => "OpenSSL",
|
||||
"pcre" => "PCRE",
|
||||
"phar" => "Phar",
|
||||
|
@ -96,6 +96,9 @@ use function lcg_value;
|
||||
use function max;
|
||||
use function microtime;
|
||||
use function min;
|
||||
use function morton2d_decode;
|
||||
use function morton2d_encode;
|
||||
use function morton3d_encode;
|
||||
use function mt_rand;
|
||||
use function spl_object_id;
|
||||
use function strtolower;
|
||||
@ -268,10 +271,11 @@ class World implements ChunkManager{
|
||||
private $logger;
|
||||
|
||||
public static function chunkHash(int $x, int $z) : int{
|
||||
return (($x & 0xFFFFFFFF) << 32) | ($z & 0xFFFFFFFF);
|
||||
return morton2d_encode($x, $z);
|
||||
}
|
||||
|
||||
public static function blockHash(int $x, int $y, int $z) : int{
|
||||
//TODO: switch this to use morton3d (21 bits each only allows for 2M blocks, but Y would have 12 spare bits)
|
||||
$shiftedY = $y - self::HALF_Y_MAX;
|
||||
if($shiftedY < -512 or $shiftedY >= 512){
|
||||
throw new \InvalidArgumentException("Y coordinate $y is out of range!");
|
||||
@ -283,18 +287,18 @@ class World implements ChunkManager{
|
||||
* Computes a small index relative to chunk base from the given coordinates.
|
||||
*/
|
||||
public static function chunkBlockHash(int $x, int $y, int $z) : int{
|
||||
return ($y << 8) | (($z & 0xf) << 4) | ($x & 0xf);
|
||||
return morton3d_encode($x, $y, $z);
|
||||
}
|
||||
|
||||
public static function getBlockXYZ(int $hash, ?int &$x, ?int &$y, ?int &$z) : void{
|
||||
//TODO: switch this to use morton3d
|
||||
$x = $hash >> 37;
|
||||
$y = ($hash << 27 >> 54) + self::HALF_Y_MAX;
|
||||
$z = $hash << 37 >> 37;
|
||||
}
|
||||
|
||||
public static function getXZ(int $hash, ?int &$x, ?int &$z) : void{
|
||||
$x = $hash >> 32;
|
||||
$z = ($hash & 0xFFFFFFFF) << 32 >> 32;
|
||||
[$x, $z] = morton2d_decode($hash);
|
||||
}
|
||||
|
||||
public static function getDifficultyFromString(string $str) : int{
|
||||
|
@ -55,9 +55,18 @@ before_script:
|
||||
- make
|
||||
- make install
|
||||
- cd ..
|
||||
- |
|
||||
git clone https://github.com/pmmp/ext-morton.git -b 0.1.0 --depth=1
|
||||
cd ext-morton
|
||||
phpize
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
cd ..
|
||||
- echo "extension=pthreads.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
- echo "extension=chunkutils2.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
- echo "extension=leveldb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
- echo "extension=morton.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||
|
||||
cache:
|
||||
- leveldb-mcpe
|
||||
|
Loading…
x
Reference in New Issue
Block a user