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
5 changed files with 44 additions and 58 deletions

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;