Use new features in pocketmine/math 1.0.0

This commit is contained in:
Dylan K. Taylor 2023-08-03 16:46:16 +01:00
parent c91c8c2f9e
commit 6ac45526f9
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
5 changed files with 44 additions and 58 deletions

View File

@ -43,7 +43,7 @@
"pocketmine/errorhandler": "^0.6.0",
"pocketmine/locale-data": "~2.19.0",
"pocketmine/log": "^0.4.0",
"pocketmine/math": "^0.4.0",
"pocketmine/math": "~1.0.0",
"pocketmine/nbt": "^0.3.2",
"pocketmine/raklib": "^0.15.0",
"pocketmine/raklib-ipc": "^0.2.0",

58
composer.lock generated
View File

@ -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": "ccd20e7656bc05ec2acd8e28aad9fcf2",
"content-hash": "63ecdcea88960659a6977300a0ea79b3",
"packages": [
{
"name": "adhocore/json-comment",
@ -200,16 +200,16 @@
},
{
"name": "pocketmine/bedrock-protocol",
"version": "23.0.2+bedrock-1.20.10",
"version": "23.0.3+bedrock-1.20.10",
"source": {
"type": "git",
"url": "https://github.com/pmmp/BedrockProtocol.git",
"reference": "69a309a2dd7dcf3ec8c316385b866397e8c2cbfd"
"reference": "e4157c7af3f91e1b08fe21be171eb73dad7029e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/69a309a2dd7dcf3ec8c316385b866397e8c2cbfd",
"reference": "69a309a2dd7dcf3ec8c316385b866397e8c2cbfd",
"url": "https://api.github.com/repos/pmmp/BedrockProtocol/zipball/e4157c7af3f91e1b08fe21be171eb73dad7029e9",
"reference": "e4157c7af3f91e1b08fe21be171eb73dad7029e9",
"shasum": ""
},
"require": {
@ -218,8 +218,8 @@
"php": "^8.0",
"pocketmine/binaryutils": "^0.2.0",
"pocketmine/color": "^0.2.0 || ^0.3.0",
"pocketmine/math": "^0.3.0 || ^0.4.0",
"pocketmine/nbt": "^0.3.0",
"pocketmine/math": "^0.3.0 || ^0.4.0 || ^1.0.0",
"pocketmine/nbt": "^0.3.0 || ^1.0.0",
"ramsey/uuid": "^4.1"
},
"require-dev": {
@ -241,9 +241,9 @@
"description": "An implementation of the Minecraft: Bedrock Edition protocol in PHP",
"support": {
"issues": "https://github.com/pmmp/BedrockProtocol/issues",
"source": "https://github.com/pmmp/BedrockProtocol/tree/23.0.2+bedrock-1.20.10"
"source": "https://github.com/pmmp/BedrockProtocol/tree/23.0.3+bedrock-1.20.10"
},
"time": "2023-07-24T15:35:36+00:00"
"time": "2023-08-03T15:30:52+00:00"
},
{
"name": "pocketmine/binaryutils",
@ -480,16 +480,16 @@
},
{
"name": "pocketmine/math",
"version": "0.4.3",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/pmmp/Math.git",
"reference": "47a243d320b01c8099d65309967934c188111549"
"reference": "dc132d93595b32e9f210d78b3c8d43c662a5edbf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/pmmp/Math/zipball/47a243d320b01c8099d65309967934c188111549",
"reference": "47a243d320b01c8099d65309967934c188111549",
"url": "https://api.github.com/repos/pmmp/Math/zipball/dc132d93595b32e9f210d78b3c8d43c662a5edbf",
"reference": "dc132d93595b32e9f210d78b3c8d43c662a5edbf",
"shasum": ""
},
"require": {
@ -498,7 +498,7 @@
},
"require-dev": {
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "1.8.2",
"phpstan/phpstan": "~1.10.3",
"phpstan/phpstan-strict-rules": "^1.0",
"phpunit/phpunit": "^8.5 || ^9.5"
},
@ -515,9 +515,9 @@
"description": "PHP library containing math related code used in PocketMine-MP",
"support": {
"issues": "https://github.com/pmmp/Math/issues",
"source": "https://github.com/pmmp/Math/tree/0.4.3"
"source": "https://github.com/pmmp/Math/tree/1.0.0"
},
"time": "2022-08-25T18:43:37+00:00"
"time": "2023-08-03T12:56:33+00:00"
},
{
"name": "pocketmine/nbt",
@ -1541,16 +1541,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "10.1.2",
"version": "10.1.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e"
"reference": "be1fe461fdc917de2a29a452ccf2657d325b443d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/db1497ec8dd382e82c962f7abbe0320e4882ee4e",
"reference": "db1497ec8dd382e82c962f7abbe0320e4882ee4e",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/be1fe461fdc917de2a29a452ccf2657d325b443d",
"reference": "be1fe461fdc917de2a29a452ccf2657d325b443d",
"shasum": ""
},
"require": {
@ -1607,7 +1607,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
"security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy",
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.2"
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.3"
},
"funding": [
{
@ -1615,7 +1615,7 @@
"type": "github"
}
],
"time": "2023-05-22T09:04:27+00:00"
"time": "2023-07-26T13:45:28+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -1861,16 +1861,16 @@
},
{
"name": "phpunit/phpunit",
"version": "10.2.6",
"version": "10.2.7",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "1c17815c129f133f3019cc18e8d0c8622e6d9bcd"
"reference": "a215d9ee8bac1733796e4ddff3306811f14414e5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/1c17815c129f133f3019cc18e8d0c8622e6d9bcd",
"reference": "1c17815c129f133f3019cc18e8d0c8622e6d9bcd",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a215d9ee8bac1733796e4ddff3306811f14414e5",
"reference": "a215d9ee8bac1733796e4ddff3306811f14414e5",
"shasum": ""
},
"require": {
@ -1895,7 +1895,7 @@
"sebastian/diff": "^5.0",
"sebastian/environment": "^6.0",
"sebastian/exporter": "^5.0",
"sebastian/global-state": "^6.0",
"sebastian/global-state": "^6.0.1",
"sebastian/object-enumerator": "^5.0",
"sebastian/recursion-context": "^5.0",
"sebastian/type": "^4.0",
@ -1942,7 +1942,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.2.6"
"source": "https://github.com/sebastianbergmann/phpunit/tree/10.2.7"
},
"funding": [
{
@ -1958,7 +1958,7 @@
"type": "tidelift"
}
],
"time": "2023-07-17T12:08:28+00:00"
"time": "2023-08-02T06:46:08+00:00"
},
{
"name": "sebastian/cli-parser",

View File

@ -113,14 +113,15 @@ class MobHead extends Flowable{
* @return AxisAlignedBB[]
*/
protected function recalculateCollisionBoxes() : array{
$collisionBox = AxisAlignedBB::one()->contract(0.25, 0, 0.25)->trim(Facing::UP, 0.5);
return match($this->facing){
Facing::NORTH => [$collisionBox->offset(0, 0.25, 0.25)],
Facing::SOUTH => [$collisionBox->offset(0, 0.25, -0.25)],
Facing::WEST => [$collisionBox->offset(0.25, 0.25, 0)],
Facing::EAST => [$collisionBox->offset(-0.25, 0.25, 0)],
default => [$collisionBox]
};
$collisionBox = AxisAlignedBB::one()
->contract(0.25, 0, 0.25)
->trim(Facing::UP, 0.5);
if($this->facing !== Facing::UP){
$collisionBox = $collisionBox
->offsetTowards(Facing::opposite($this->facing), 0.25)
->offsetTowards(Facing::UP, 0.25);
}
return [$collisionBox];
}
public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{

View File

@ -1906,14 +1906,7 @@ class World implements ChunkManager{
unset($this->blockCollisionBoxCache[$chunkHash][$relativeBlockHash]);
//blocks like fences have collision boxes that reach into neighbouring blocks, so we need to invalidate the
//caches for those blocks as well
foreach([
[0, 0, 1],
[0, 0, -1],
[0, 1, 0],
[0, -1, 0],
[1, 0, 0],
[-1, 0, 0]
] as [$offsetX, $offsetY, $offsetZ]){
foreach(Facing::OFFSET as [$offsetX, $offsetY, $offsetZ]){
$sideChunkPosHash = World::chunkHash(($x + $offsetX) >> Chunk::COORD_BIT_SIZE, ($z + $offsetZ) >> Chunk::COORD_BIT_SIZE);
$sideChunkBlockHash = World::chunkBlockHash($x + $offsetX, $y + $offsetY, $z + $offsetZ);
unset($this->blockCollisionBoxCache[$sideChunkPosHash][$sideChunkBlockHash]);

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine\world\light;
use pocketmine\math\Facing;
use pocketmine\world\format\LightArray;
use pocketmine\world\format\SubChunk;
use pocketmine\world\utils\SubChunkExplorer;
@ -33,15 +34,6 @@ use function max;
//TODO: make light updates asynchronous
abstract class LightUpdate{
private const ADJACENTS = [
[ 1, 0, 0],
[-1, 0, 0],
[ 0, 1, 0],
[ 0, -1, 0],
[ 0, 0, 1],
[ 0, 0, -1]
];
public const BASE_LIGHT_FILTER = 1;
/**
@ -78,7 +70,7 @@ abstract class LightUpdate{
protected function getHighestAdjacentLight(int $x, int $y, int $z) : int{
$adjacent = 0;
foreach(self::ADJACENTS as [$ox, $oy, $oz]){
foreach(Facing::OFFSET as [$ox, $oy, $oz]){
if(($adjacent = max($adjacent, $this->getEffectiveLight($x + $ox, $y + $oy, $z + $oz))) === 15){
break;
}
@ -123,7 +115,7 @@ abstract class LightUpdate{
$touched++;
[$x, $y, $z, $oldAdjacentLight] = $context->removalQueue->dequeue();
foreach(self::ADJACENTS as [$ox, $oy, $oz]){
foreach(Facing::OFFSET as [$ox, $oy, $oz]){
$cx = $x + $ox;
$cy = $y + $oy;
$cz = $z + $oz;
@ -163,7 +155,7 @@ abstract class LightUpdate{
continue;
}
foreach(self::ADJACENTS as [$ox, $oy, $oz]){
foreach(Facing::OFFSET as [$ox, $oy, $oz]){
$cx = $x + $ox;
$cy = $y + $oy;
$cz = $z + $oz;