diff --git a/src/block/tile/ContainerTrait.php b/src/block/tile/ContainerTrait.php index 76ebacf31..f76944a6a 100644 --- a/src/block/tile/ContainerTrait.php +++ b/src/block/tile/ContainerTrait.php @@ -96,7 +96,7 @@ trait ContainerTrait{ $pos = $this->getPos(); foreach($inv->getContents() as $k => $item){ - $pos->world->dropItem($pos->add(0.5, 0.5, 0.5), $item); + $pos->getWorldNonNull()->dropItem($pos->add(0.5, 0.5, 0.5), $item); } $inv->clearAll(); } diff --git a/src/block/utils/FallableTrait.php b/src/block/utils/FallableTrait.php index c1a081703..b398dabe7 100644 --- a/src/block/utils/FallableTrait.php +++ b/src/block/utils/FallableTrait.php @@ -47,9 +47,9 @@ trait FallableTrait{ public function onNearbyBlockChange() : void{ $pos = $this->getPos(); - $down = $pos->world->getBlock($pos->getSide(Facing::DOWN)); + $down = $pos->getWorldNonNull()->getBlock($pos->getSide(Facing::DOWN)); if($down->getId() === BlockLegacyIds::AIR or $down instanceof Liquid or $down instanceof Fire){ - $pos->world->setBlock($pos, VanillaBlocks::AIR()); + $pos->getWorldNonNull()->setBlock($pos, VanillaBlocks::AIR()); $nbt = EntityFactory::createBaseNBT($pos->add(0.5, 0, 0.5)); $nbt->setInt("TileID", $this->getId()); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index cacca686c..6a9923830 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -1337,7 +1337,7 @@ abstract class Entity{ return false; } - if($pos instanceof Position and $pos->world !== null and $pos->world !== $this->getWorld()){ + if($pos instanceof Position and $pos->isValid() and $pos->getWorldNonNull() !== $this->getWorld()){ if(!$this->switchWorld($pos->getWorldNonNull())){ return false; } diff --git a/tests/phpstan/configs/l8-baseline.neon b/tests/phpstan/configs/l8-baseline.neon index 5a522407c..f5211c84b 100644 --- a/tests/phpstan/configs/l8-baseline.neon +++ b/tests/phpstan/configs/l8-baseline.neon @@ -65,106 +65,26 @@ parameters: count: 1 path: ../../../src/block/tile/Chest.php - - - message: "#^Cannot call method dropItem\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/tile/Chest.php - - message: "#^Argument of an invalid type pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 path: ../../../src/block/tile/BrewingStand.php - - - message: "#^Cannot call method dropItem\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/tile/BrewingStand.php - - message: "#^Argument of an invalid type pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 path: ../../../src/block/tile/Furnace.php - - - message: "#^Cannot call method dropItem\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/tile/Furnace.php - - message: "#^Argument of an invalid type pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null supplied for foreach, only iterables are supported\\.$#" count: 1 path: ../../../src/block/tile/Hopper.php - - - message: "#^Cannot call method dropItem\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/tile/Hopper.php - - message: "#^Parameter \\#1 \\$nbt of method pocketmine\\\\block\\\\tile\\\\Tile\\:\\:readSaveData\\(\\) expects pocketmine\\\\nbt\\\\tag\\\\CompoundTag, pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null given\\.$#" count: 1 path: ../../../src/block/tile/Tile.php - - - message: "#^Cannot call method getBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/Anvil.php - - - - message: "#^Cannot call method setBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/Anvil.php - - - - message: "#^Cannot call method getBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/ConcretePowder.php - - - - message: "#^Cannot call method setBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/ConcretePowder.php - - - - message: "#^Cannot call method getBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Cannot call method setBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/DragonEgg.php - - - - message: "#^Cannot call method getBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/Gravel.php - - - - message: "#^Cannot call method setBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/Gravel.php - - - - message: "#^Cannot call method getBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/Sand.php - - - - message: "#^Cannot call method setBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/Sand.php - - - - message: "#^Cannot call method getBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/SnowLayer.php - - - - message: "#^Cannot call method setBlock\\(\\) on pocketmine\\\\world\\\\World\\|null\\.$#" - count: 1 - path: ../../../src/block/SnowLayer.php - - message: "#^Parameter \\#2 \\$replace of function str_replace expects array\\|string, string\\|null given\\.$#" count: 1