From 37ec1193ea58aab19545424842ca45e39ad5032f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 28 Sep 2022 18:34:01 +0100 Subject: [PATCH 01/11] Update PHPStan baselines --- tests/phpstan/configs/actual-problems.neon | 5 ----- tests/phpstan/configs/php-bugs.neon | 2 +- tests/phpstan/configs/phpstan-bugs.neon | 10 ---------- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index 85b261dca..9464ee2e5 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -510,11 +510,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 From 22486dd75ee4ef4be87369296748550e3ac2b1de Mon Sep 17 00:00:00 2001 From: ShockedPlot7560 <66992287+ShockedPlot7560@users.noreply.github.com> Date: Wed, 28 Sep 2022 19:41:23 +0200 Subject: [PATCH 02/11] Mushroom: check the light for placement, unless placed on mycelium or podzol (#5054) The previous behaviour was inconsistent with vanilla. --- src/block/RedMushroom.php | 6 +++++- tests/phpstan/configs/actual-problems.neon | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/block/RedMushroom.php b/src/block/RedMushroom.php index 9be005d17..7e07b83f4 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->getId(); + //TODO: nylium support + if(($lightLevel <= 12 && !$down->isTransparent()) || $downId === BlockLegacyIds::MYCELIUM || $downId === BlockLegacyIds::PODZOL){ return parent::place($tx, $item, $blockReplace, $blockClicked, $face, $clickVector, $player); } diff --git a/tests/phpstan/configs/actual-problems.neon b/tests/phpstan/configs/actual-problems.neon index 9464ee2e5..1121cd134 100644 --- a/tests/phpstan/configs/actual-problems.neon +++ b/tests/phpstan/configs/actual-problems.neon @@ -335,6 +335,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 From fc56c041f32a25d06641852652e4c8b3989297fd Mon Sep 17 00:00:00 2001 From: IvanCraft623 <57236932+IvanCraft623@users.noreply.github.com> Date: Wed, 28 Sep 2022 15:09:07 -0500 Subject: [PATCH 03/11] Correct knockback from explosions (#5161) --- src/world/Explosion.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/Explosion.php b/src/world/Explosion.php index 9f117245c..5ccdc0faa 100644 --- a/src/world/Explosion.php +++ b/src/world/Explosion.php @@ -195,7 +195,7 @@ class Explosion{ } $entity->attack($ev); - $entity->setMotion($motion->multiply($impact)); + $entity->setMotion($entity->getMotion()->addVector($motion->multiply($impact))); } } From 1f9dfa77bf53611599a7fe2941e7dc1b0d773ae8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 28 Sep 2022 21:57:01 +0100 Subject: [PATCH 04/11] PreSpawnPacketHandler: emit a separate debug message for sending creative data --- src/network/mcpe/handler/PreSpawnPacketHandler.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/network/mcpe/handler/PreSpawnPacketHandler.php b/src/network/mcpe/handler/PreSpawnPacketHandler.php index 2814dba4e..e17076608 100644 --- a/src/network/mcpe/handler/PreSpawnPacketHandler.php +++ b/src/network/mcpe/handler/PreSpawnPacketHandler.php @@ -131,9 +131,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())); From ac16378410b9e32b53bac19e26945a4ad283ec6f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 28 Sep 2022 21:57:35 +0100 Subject: [PATCH 05/11] Silence pre-spawn PlayerAuthInputPacket debug spam --- src/network/mcpe/handler/PreSpawnPacketHandler.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/network/mcpe/handler/PreSpawnPacketHandler.php b/src/network/mcpe/handler/PreSpawnPacketHandler.php index e17076608..fbe549189 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; @@ -148,4 +149,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; + } } From 6f68c6d8a0a9d952343ca71885e66d332e39d56e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 28 Sep 2022 23:07:53 +0100 Subject: [PATCH 06/11] Melon: extend Solid instead of Transparent, fixes #5050 --- src/block/Melon.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 [ From 2be527060fc63e633d0b6af289cc426bc9d7a213 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 28 Sep 2022 23:34:08 +0100 Subject: [PATCH 07/11] Sign: Fixed desync of colour and glowing state when using dye on signs fixes #4932 --- src/block/tile/Sign.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/block/tile/Sign.php b/src/block/tile/Sign.php index 3922e1866..383526bd8 100644 --- a/src/block/tile/Sign.php +++ b/src/block/tile/Sign.php @@ -27,6 +27,7 @@ use pocketmine\block\utils\SignText; use pocketmine\math\Vector3; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\StringTag; +use pocketmine\utils\Binary; use pocketmine\world\World; use function array_pad; use function array_slice; @@ -42,6 +43,13 @@ use function sprintf; class Sign extends Spawnable{ public const TAG_TEXT_BLOB = "Text"; public const TAG_TEXT_LINE = "Text%d"; //sprintf()able + public const TAG_TEXT_COLOR = "SignTextColor"; + public const TAG_GLOWING_TEXT = "IgnoreLighting"; + /** + * This tag is set to indicate that MCPE-117835 has been addressed in whatever version this sign was created. + * @see https://bugs.mojang.com/browse/MCPE-117835 + */ + public const TAG_LEGACY_BUG_RESOLVE = "TextIgnoreLegacyBugResolved"; /** * @return string[] @@ -111,5 +119,11 @@ class Sign extends Spawnable{ protected function addAdditionalSpawnData(CompoundTag $nbt) : void{ $nbt->setString(self::TAG_TEXT_BLOB, implode("\n", $this->text->getLines())); + + //the following are not yet used by the server, but needed to roll back any changes to glowing state or colour + //if the client uses dye on the sign + $nbt->setInt(self::TAG_TEXT_COLOR, Binary::signInt(0xff_00_00_00)); + $nbt->setByte(self::TAG_GLOWING_TEXT, 0); + $nbt->setByte(self::TAG_LEGACY_BUG_RESOLVE, 1); } } From cd4bb916764ab336537d4e801b1e32065da7354c Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 29 Sep 2022 00:15:07 +0100 Subject: [PATCH 08/11] Living: alter eye height so the player doesn't drown on the surface of water when swimming fixes #4989 --- src/entity/Living.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/entity/Living.php b/src/entity/Living.php index 58b7c1791..43a1a392d 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -256,8 +256,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())); } From c1fbac412e9f57238ce827a7510dd5531850bf3f Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 7 Oct 2022 11:33:14 +0100 Subject: [PATCH 09/11] event: ensure that modifications to items expected to be readonly have no effect this isn't a very glorious fix, but it's the best I have for now. --- src/event/block/BlockBreakEvent.php | 2 +- src/event/block/BlockPlaceEvent.php | 2 +- src/event/player/PlayerInteractEvent.php | 2 +- src/event/player/PlayerItemHeldEvent.php | 2 +- src/event/player/PlayerItemUseEvent.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/event/block/BlockBreakEvent.php b/src/event/block/BlockBreakEvent.php index 2b83478af..fba60983e 100644 --- a/src/event/block/BlockBreakEvent.php +++ b/src/event/block/BlockBreakEvent.php @@ -72,7 +72,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 28b667573..0c134eb8c 100644 --- a/src/event/block/BlockPlaceEvent.php +++ b/src/event/block/BlockPlaceEvent.php @@ -65,7 +65,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 e697d4fdc..f28391364 100644 --- a/src/event/player/PlayerInteractEvent.php +++ b/src/event/player/PlayerInteractEvent.php @@ -69,7 +69,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; } /** From 10b8dcfdd136c351fd18864e6b7e0c9257ea8a0d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Oct 2022 11:43:39 +0100 Subject: [PATCH 10/11] Bump phpstan/phpstan from 1.8.6 to 1.8.8 (#5324) Bumps [phpstan/phpstan](https://github.com/phpstan/phpstan) from 1.8.6 to 1.8.8. - [Release notes](https://github.com/phpstan/phpstan/releases) - [Changelog](https://github.com/phpstan/phpstan/blob/1.9.x/CHANGELOG.md) - [Commits](https://github.com/phpstan/phpstan/compare/1.8.6...1.8.8) --- updated-dependencies: - dependency-name: phpstan/phpstan dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 957fbb4b1..7b2a8614f 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,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 71e413d01..6a3eca76f 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "29badb76ebb63167718947cad48bd37d", + "content-hash": "8153377a26bfd4a342a9b7101580f1ea", "packages": [ { "name": "adhocore/json-comment", @@ -1506,16 +1506,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": { @@ -1545,7 +1545,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": [ { @@ -1561,7 +1561,7 @@ "type": "tidelift" } ], - "time": "2022-09-23T09:54:39+00:00" + "time": "2022-10-06T12:51:57+00:00" }, { "name": "phpstan/phpstan-phpunit", From 7df2719fce54d10b64a9bfaf352f1954cc32ebb8 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 11 Oct 2022 21:57:22 +0100 Subject: [PATCH 11/11] Update Composer dependencies --- composer.lock | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/composer.lock b/composer.lock index 6a3eca76f..d557c21db 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "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", @@ -245,16 +249,16 @@ }, { "name": "pocketmine/bedrock-data", - "version": "1.11.0+bedrock-1.19.30", + "version": "1.11.1+bedrock-1.19.30", "source": { "type": "git", "url": "https://github.com/pmmp/BedrockData.git", - "reference": "2cca1d48421db20740ffd1ce67b40b91acc61187" + "reference": "9ec9a9645ba19f04dd4e39d6d9bd30b562dfe90c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/2cca1d48421db20740ffd1ce67b40b91acc61187", - "reference": "2cca1d48421db20740ffd1ce67b40b91acc61187", + "url": "https://api.github.com/repos/pmmp/BedrockData/zipball/9ec9a9645ba19f04dd4e39d6d9bd30b562dfe90c", + "reference": "9ec9a9645ba19f04dd4e39d6d9bd30b562dfe90c", "shasum": "" }, "type": "library", @@ -265,9 +269,9 @@ "description": "Blobs of data generated from Minecraft: Bedrock Edition, used by PocketMine-MP", "support": { "issues": "https://github.com/pmmp/BedrockData/issues", - "source": "https://github.com/pmmp/BedrockData/tree/bedrock-1.19.30" + "source": "https://github.com/pmmp/BedrockData/tree/1.11.1+bedrock-1.19.30" }, - "time": "2022-09-20T18:19:22+00:00" + "time": "2022-09-27T22:00:01+00:00" }, { "name": "pocketmine/bedrock-protocol",