diff --git a/composer.json b/composer.json index d4425e158..069821e87 100644 --- a/composer.json +++ b/composer.json @@ -55,7 +55,7 @@ "webmozart/path-util": "^2.3" }, "require-dev": { - "phpstan/phpstan": "1.8.6", + "phpstan/phpstan": "1.8.8", "phpstan/phpstan-phpunit": "^1.1.0", "phpstan/phpstan-strict-rules": "^1.2.0", "phpunit/phpunit": "^9.2" diff --git a/composer.lock b/composer.lock index d9381fe18..8ac56d931 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5a893a5cf9cd6e4c8f70b332cbde4a2d", + "content-hash": "76009ed4482b5d406cac5d9cd83e1ec4", "packages": [ { "name": "adhocore/json-comment", - "version": "1.1.2", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/adhocore/php-json-comment.git", - "reference": "fc2f76979f0a44a5f5bc2a2b600d0762fe0e78e7" + "reference": "651023f9fe52e9efa2198cbaf6e481d1968e2377" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/adhocore/php-json-comment/zipball/fc2f76979f0a44a5f5bc2a2b600d0762fe0e78e7", - "reference": "fc2f76979f0a44a5f5bc2a2b600d0762fe0e78e7", + "url": "https://api.github.com/repos/adhocore/php-json-comment/zipball/651023f9fe52e9efa2198cbaf6e481d1968e2377", + "reference": "651023f9fe52e9efa2198cbaf6e481d1968e2377", "shasum": "" }, "require": { @@ -51,15 +51,19 @@ ], "support": { "issues": "https://github.com/adhocore/php-json-comment/issues", - "source": "https://github.com/adhocore/php-json-comment/tree/1.1.2" + "source": "https://github.com/adhocore/php-json-comment/tree/1.2.1" }, "funding": [ { "url": "https://paypal.me/ji10", "type": "custom" + }, + { + "url": "https://github.com/adhocore", + "type": "github" } ], - "time": "2021-04-09T03:06:06+00:00" + "time": "2022-10-02T11:22:07+00:00" }, { "name": "brick/math", @@ -276,12 +280,12 @@ "source": { "type": "git", "url": "https://github.com/pmmp/BedrockData.git", - "reference": "1ca9241ce66358cdfb2dbde65d609eb9c185c515" + "reference": "e6a51075e600b0494f8fb57574c4b0e77c344475" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/1ca9241ce66358cdfb2dbde65d609eb9c185c515", - "reference": "1ca9241ce66358cdfb2dbde65d609eb9c185c515", + "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/e6a51075e600b0494f8fb57574c4b0e77c344475", + "reference": "e6a51075e600b0494f8fb57574c4b0e77c344475", "shasum": "" }, "type": "library", @@ -294,7 +298,7 @@ "issues": "https://github.com/pmmp/BedrockData/issues", "source": "https://github.com/pmmp/BedrockData/tree/modern-world-support" }, - "time": "2022-09-21T13:59:15+00:00" + "time": "2022-09-28T20:32:25+00:00" }, { "name": "pocketmine/bedrock-item-upgrade-schema", @@ -1560,16 +1564,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.8.6", + "version": "1.8.8", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618" + "reference": "08310ce271984587e2a4cda94e1ac66510a6ea07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c386ab2741e64cc9e21729f891b28b2b10fe6618", - "reference": "c386ab2741e64cc9e21729f891b28b2b10fe6618", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/08310ce271984587e2a4cda94e1ac66510a6ea07", + "reference": "08310ce271984587e2a4cda94e1ac66510a6ea07", "shasum": "" }, "require": { @@ -1599,7 +1603,7 @@ ], "support": { "issues": "https://github.com/phpstan/phpstan/issues", - "source": "https://github.com/phpstan/phpstan/tree/1.8.6" + "source": "https://github.com/phpstan/phpstan/tree/1.8.8" }, "funding": [ { @@ -1615,7 +1619,7 @@ "type": "tidelift" } ], - "time": "2022-09-23T09:54:39+00:00" + "time": "2022-10-06T12:51:57+00:00" }, { "name": "phpstan/phpstan-phpunit", diff --git a/src/block/Melon.php b/src/block/Melon.php index 6f4e62571..42d54c0ab 100644 --- a/src/block/Melon.php +++ b/src/block/Melon.php @@ -27,7 +27,7 @@ use pocketmine\item\Item; use pocketmine\item\VanillaItems; use function mt_rand; -class Melon extends Transparent{ +class Melon extends Opaque{ public function getDropsForCompatibleTool(Item $item) : array{ return [ diff --git a/src/block/RedMushroom.php b/src/block/RedMushroom.php index 9be005d17..553957fe6 100644 --- a/src/block/RedMushroom.php +++ b/src/block/RedMushroom.php @@ -43,7 +43,11 @@ class RedMushroom extends Flowable{ public function place(BlockTransaction $tx, Item $item, Block $blockReplace, Block $blockClicked, int $face, Vector3 $clickVector, ?Player $player = null) : bool{ $down = $this->getSide(Facing::DOWN); - if(!$down->isTransparent()){ + $position = $this->getPosition(); + $lightLevel = $position->getWorld()->getFullLightAt($position->x, $position->y, $position->z); + $downId = $down->getTypeId(); + //TODO: nylium support + if(($lightLevel <= 12 && !$down->isTransparent()) || $downId === BlockTypeIds::MYCELIUM || $downId === BlockTypeIds::PODZOL){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/src/entity/Living.php b/src/entity/Living.php index 7485af2bb..26e387217 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -240,8 +240,7 @@ abstract class Living extends Entity{ $size = $this->getInitialSizeInfo(); if($this->isSwimming() || $this->isGliding()){ $width = $size->getWidth(); - //we don't actually know an appropriate eye height for a swimming mob, but 2/3 should be good enough. - $this->setSize((new EntitySizeInfo($width, $width, $width * 2 / 3))->scale($this->getScale())); + $this->setSize((new EntitySizeInfo($width, $width, $width * 0.9))->scale($this->getScale())); }else{ $this->setSize($size->scale($this->getScale())); } diff --git a/src/event/block/BlockBreakEvent.php b/src/event/block/BlockBreakEvent.php index 442a81155..c876d2727 100644 --- a/src/event/block/BlockBreakEvent.php +++ b/src/event/block/BlockBreakEvent.php @@ -64,7 +64,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{ * Returns the item used to destroy the block. */ public function getItem() : Item{ - return $this->item; + return clone $this->item; } /** diff --git a/src/event/block/BlockPlaceEvent.php b/src/event/block/BlockPlaceEvent.php index 5e3f7e89c..eeb6a7dbc 100644 --- a/src/event/block/BlockPlaceEvent.php +++ b/src/event/block/BlockPlaceEvent.php @@ -56,7 +56,7 @@ class BlockPlaceEvent extends BlockEvent implements Cancellable{ * Gets the item in hand */ public function getItem() : Item{ - return $this->item; + return clone $this->item; } public function getBlockReplaced() : Block{ diff --git a/src/event/player/PlayerInteractEvent.php b/src/event/player/PlayerInteractEvent.php index c56952b04..5560f9d19 100644 --- a/src/event/player/PlayerInteractEvent.php +++ b/src/event/player/PlayerInteractEvent.php @@ -59,7 +59,7 @@ class PlayerInteractEvent extends PlayerEvent implements Cancellable{ } public function getItem() : Item{ - return $this->item; + return clone $this->item; } public function getBlock() : Block{ diff --git a/src/event/player/PlayerItemHeldEvent.php b/src/event/player/PlayerItemHeldEvent.php index 3b0392d4c..3e69298dd 100644 --- a/src/event/player/PlayerItemHeldEvent.php +++ b/src/event/player/PlayerItemHeldEvent.php @@ -60,6 +60,6 @@ class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{ * Returns the item in the slot that the player is trying to equip. */ public function getItem() : Item{ - return $this->item; + return clone $this->item; } } diff --git a/src/event/player/PlayerItemUseEvent.php b/src/event/player/PlayerItemUseEvent.php index 3cd1dfa46..f8abfcd9c 100644 --- a/src/event/player/PlayerItemUseEvent.php +++ b/src/event/player/PlayerItemUseEvent.php @@ -47,7 +47,7 @@ class PlayerItemUseEvent extends PlayerEvent implements Cancellable{ * Returns the item used. */ public function getItem() : Item{ - return $this->item; + return clone $this->item; } /** diff --git a/src/network/mcpe/handler/PreSpawnPacketHandler.php b/src/network/mcpe/handler/PreSpawnPacketHandler.php index 19db3f434..04c51d3fb 100644 --- a/src/network/mcpe/handler/PreSpawnPacketHandler.php +++ b/src/network/mcpe/handler/PreSpawnPacketHandler.php @@ -30,6 +30,7 @@ use pocketmine\network\mcpe\convert\GlobalItemTypeDictionary; use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\network\mcpe\InventoryManager; use pocketmine\network\mcpe\NetworkSession; +use pocketmine\network\mcpe\protocol\PlayerAuthInputPacket; use pocketmine\network\mcpe\protocol\RequestChunkRadiusPacket; use pocketmine\network\mcpe\protocol\StartGamePacket; use pocketmine\network\mcpe\protocol\types\BlockPosition; @@ -132,9 +133,11 @@ class PreSpawnPacketHandler extends PacketHandler{ $this->session->getLogger()->debug("Sending inventory"); $this->inventoryManager->syncAll(); - $this->inventoryManager->syncCreative(); $this->inventoryManager->syncSelectedHotbarSlot(); + $this->session->getLogger()->debug("Sending creative inventory data"); + $this->inventoryManager->syncCreative(); + $this->session->getLogger()->debug("Sending crafting data"); $this->session->sendDataPacket(CraftingDataCache::getInstance()->getCache($this->server->getCraftingManager())); @@ -147,4 +150,10 @@ class PreSpawnPacketHandler extends PacketHandler{ return true; } + + public function handlePlayerAuthInput(PlayerAuthInputPacket $packet) : bool{ + //the client will send this every tick once we start sending chunks, but we don't handle it in this stage + //this is very spammy so we filter it out + return true; + } } diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 5f2c2da5c..fbe5541a3 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -187,7 +187,7 @@ class Explosion{ } $entity->attack($ev); - $entity->setMotion($motion->multiply($impact)); + $entity->setMotion($entity->getMotion()->addVector($motion->multiply($impact))); } } diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index cff6d9623..638885452 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -350,6 +350,21 @@ parameters: count: 3 path: ../../../src/block/Mycelium.php + - + message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" + count: 1 + path: ../../../src/block/RedMushroom.php + + - + message: "#^Parameter \\#2 \\$y of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" + count: 1 + path: ../../../src/block/RedMushroom.php + + - + message: "#^Parameter \\#3 \\$z of method pocketmine\\\\world\\\\World\\:\\:getFullLightAt\\(\\) expects int, float\\|int given\\.$#" + count: 1 + path: ../../../src/block/RedMushroom.php + - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockLightAt\\(\\) expects int, float\\|int given\\.$#" count: 1 @@ -525,11 +540,6 @@ parameters: count: 1 path: ../../../src/crash/CrashDump.php - - - message: "#^Parameter \\#1 \\$index of method pocketmine\\\\inventory\\\\BaseInventory\\:\\:setItem\\(\\) expects int, int\\|string given\\.$#" - count: 1 - path: ../../../src/entity/ExperienceManager.php - - message: "#^Parameter \\#1 \\$x of method pocketmine\\\\world\\\\World\\:\\:getBlockAt\\(\\) expects int, float\\|int given\\.$#" count: 1 diff --git a/tests/phpstan/configs/php-bugs.neon b/tests/phpstan/configs/php-bugs.neon index c70ef1ecb..4475ec468 100644 --- a/tests/phpstan/configs/php-bugs.neon +++ b/tests/phpstan/configs/php-bugs.neon @@ -1,6 +1,6 @@ parameters: ignoreErrors: - - message: "#^Property pocketmine\\\\network\\\\mcpe\\\\handler\\\\StupidJsonDecodeTest\\:\\:\\$stupidJsonDecodeFunc \\(Closure\\(string, bool=\\)\\: mixed\\) does not accept Closure\\|null\\.$#" + message: "#^Property pocketmine\\\\network\\\\mcpe\\\\handler\\\\StupidJsonDecodeTest\\:\\:\\$stupidJsonDecodeFunc \\(Closure\\(string, bool\\=\\)\\: mixed\\) does not accept Closure\\|null\\.$#" count: 1 path: ../../phpunit/network/mcpe/handler/StupidJsonDecodeTest.php diff --git a/tests/phpstan/configs/phpstan-bugs.neon b/tests/phpstan/configs/phpstan-bugs.neon index b9e3e76b8..e50532cfd 100644 --- a/tests/phpstan/configs/phpstan-bugs.neon +++ b/tests/phpstan/configs/phpstan-bugs.neon @@ -10,16 +10,6 @@ parameters: count: 1 path: ../../../src/console/ConsoleCommandSender.php - - - message: "#^Method pocketmine\\\\crafting\\\\CraftingManager\\:\\:getDestructorCallbacks\\(\\) should return pocketmine\\\\utils\\\\ObjectSet\\ but returns pocketmine\\\\utils\\\\ObjectSet\\\\|pocketmine\\\\utils\\\\ObjectSet\\\\.$#" - count: 1 - path: ../../../src/crafting/CraftingManager.php - - - - message: "#^Property pocketmine\\\\crafting\\\\CraftingManager\\:\\:\\$destructorCallbacks \\(pocketmine\\\\utils\\\\ObjectSet\\\\|null\\) does not accept pocketmine\\\\utils\\\\ObjectSet\\\\.$#" - count: 1 - path: ../../../src/crafting/CraftingManager.php - - message: "#^Call to function assert\\(\\) with false and 'unknown hit type' will always evaluate to false\\.$#" count: 1