diff --git a/changelogs/4.23.md b/changelogs/4.23.md index 031eaa1cc..750261e4b 100644 --- a/changelogs/4.23.md +++ b/changelogs/4.23.md @@ -49,3 +49,14 @@ Released 1st August 2023. ## Fixes - Fixed exponentially increasing lag when many hundreds of non-mergeable dropped items occupied the same space. This disproportionately affected SkyBlock servers due to large cactus farms using water to collect items together. + +# 4.23.5 +Released 9th August 2023. + +## General +- Updated translation data to [pmmp/Language 2.19.6](https://github.com/pmmp/Language/releases/tag/2.19.6). + +## Fixes +- Fixed `PluginBase->saveResource()` leaking file resources when the data file already exists in the plugin's data folder. This bug existed since 2014 and was only discovered recently. +- Fixed coral blocks becoming dead after calling `getDropsForCompatibleTool()` on them. +- Fixed `BlockDeathEvent->getOldState()` returning a block which is already dead. diff --git a/changelogs/5.4.md b/changelogs/5.4.md index a40fdfcea..bdaec51cb 100644 --- a/changelogs/5.4.md +++ b/changelogs/5.4.md @@ -81,3 +81,29 @@ Consider using the `mcpe-protocol` directive in `plugin.yml` as a constraint if - In addition, this change facilitates the use of the newly introduced `Block->getAdjacentSupportType()` API method, reducing boilerplate support-type checking code. - Bell block code has been simplified and cleaned up. - `TallGrass` and `DoubleTallGrass` now use a shared `TallGrassTrait` to reduce code duplication. + +# 5.4.1 +Released 8th August 2023. + +## General +- Updated translation data to [pmmp/Language 2.19.6](https://github.com/pmmp/Language/releases/tag/2.19.6). +- [`ext-pmmpthread` 6.0.7](https://github.com/pmmp/ext-pmmpthread/releases/tag/6.0.7) is now required (needed for bug fixes). + +## Fixes +- Fixed Podzol not dropping itself when mined with Silk Touch. +- Fixed `World->getSafeSpawn()` not accepting positions below `y=0` (world height limit change). +- Fixed `pocketmine\thread\Thread` and `pocketmine\thread\Worker` instances not logging any information when they crash. +- Fixed `CraftItemEvent` not cloning returned items. + +## Internals +- Foreach by-reference is now disallowed via a custom PHPStan rule. + +# 5.4.2 +Released 9th August 2023. + +## Included releases +- [4.23.5](https://github.com/pmmp/PocketMine-MP/blob/4.23.5/changelogs/4.23.md#4235) - Minor bug fixes + +## Fixes +- Fixed cake accepting candle placement when slices have already been eaten. +- Fixed fire charges not lighting candles. diff --git a/src/VersionInfo.php b/src/VersionInfo.php index 0b40f80e4..bec9638ea 100644 --- a/src/VersionInfo.php +++ b/src/VersionInfo.php @@ -31,7 +31,7 @@ use function str_repeat; final class VersionInfo{ public const NAME = "PocketMine-MP"; - public const BASE_VERSION = "5.4.1"; + public const BASE_VERSION = "5.4.3"; public const IS_DEVELOPMENT_BUILD = true; public const BUILD_CHANNEL = "stable"; diff --git a/src/block/Cake.php b/src/block/Cake.php index 3e26e59b0..81dc7e6e9 100644 --- a/src/block/Cake.php +++ b/src/block/Cake.php @@ -64,7 +64,7 @@ class Cake extends BaseCake{ } public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ - if($item instanceof ItemBlock){ + if($this->bites === 0 && $item instanceof ItemBlock){ $block = $item->getBlock(); $resultBlock = null; if($block->getTypeId() === BlockTypeIds::CANDLE){ diff --git a/src/block/CoralBlock.php b/src/block/CoralBlock.php index 3aaf5b752..5ce58f413 100644 --- a/src/block/CoralBlock.php +++ b/src/block/CoralBlock.php @@ -61,7 +61,7 @@ final class CoralBlock extends Opaque{ } public function getDropsForCompatibleTool(Item $item) : array{ - return [$this->setDead(true)->asItem()]; + return [(clone $this)->setDead(true)->asItem()]; } public function isAffectedBySilkTouch() : bool{ diff --git a/src/block/utils/CandleTrait.php b/src/block/utils/CandleTrait.php index 99e164a84..58a7443a3 100644 --- a/src/block/utils/CandleTrait.php +++ b/src/block/utils/CandleTrait.php @@ -33,6 +33,7 @@ use pocketmine\item\ItemTypeIds; use pocketmine\math\RayTraceResult; use pocketmine\math\Vector3; use pocketmine\player\Player; +use pocketmine\world\sound\BlazeShootSound; use pocketmine\world\sound\FireExtinguishSound; use pocketmine\world\sound\FlintSteelSound; @@ -57,12 +58,16 @@ trait CandleTrait{ /** @see Block::onInteract() */ public function onInteract(Item $item, int $face, Vector3 $clickVector, ?Player $player = null, array &$returnedItems = []) : bool{ - if($item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ + if($item->getTypeId() === ItemTypeIds::FIRE_CHARGE || $item->getTypeId() === ItemTypeIds::FLINT_AND_STEEL || $item->hasEnchantment(VanillaEnchantments::FIRE_ASPECT())){ if($this->lit){ return true; } if($item instanceof Durable){ $item->applyDamage(1); + }elseif($item->getTypeId() === ItemTypeIds::FIRE_CHARGE){ + $item->pop(); + //TODO: not sure if this is intentional, but it's what Bedrock currently does as of 1.20.10 + $this->position->getWorld()->addSound($this->position, new BlazeShootSound()); } $this->position->getWorld()->addSound($this->position, new FlintSteelSound()); $this->position->getWorld()->setBlock($this->position, $this->setLit(true)); diff --git a/src/event/inventory/CraftItemEvent.php b/src/event/inventory/CraftItemEvent.php index 64f285f15..35409f828 100644 --- a/src/event/inventory/CraftItemEvent.php +++ b/src/event/inventory/CraftItemEvent.php @@ -30,6 +30,7 @@ use pocketmine\event\Event; use pocketmine\inventory\transaction\CraftingTransaction; use pocketmine\item\Item; use pocketmine\player\Player; +use pocketmine\utils\Utils; class CraftItemEvent extends Event implements Cancellable{ use CancellableTrait; @@ -74,7 +75,7 @@ class CraftItemEvent extends Event implements Cancellable{ * @return Item[] */ public function getInputs() : array{ - return $this->inputs; + return Utils::cloneObjectArray($this->inputs); } /** @@ -83,7 +84,7 @@ class CraftItemEvent extends Event implements Cancellable{ * @return Item[] */ public function getOutputs() : array{ - return $this->outputs; + return Utils::cloneObjectArray($this->outputs); } public function getPlayer() : Player{ diff --git a/src/plugin/PluginBase.php b/src/plugin/PluginBase.php index e4270de00..6ef4748cf 100644 --- a/src/plugin/PluginBase.php +++ b/src/plugin/PluginBase.php @@ -251,19 +251,19 @@ abstract class PluginBase implements Plugin, CommandExecutor{ return false; } + $out = Path::join($this->dataFolder, $filename); + if(file_exists($out) && !$replace){ + return false; + } + if(($resource = $this->getResource($filename)) === null){ return false; } - $out = Path::join($this->dataFolder, $filename); if(!file_exists(dirname($out))){ mkdir(dirname($out), 0755, true); } - if(file_exists($out) && !$replace){ - return false; - } - $fp = fopen($out, "wb"); if($fp === false) throw new AssumptionFailedError("fopen() should not fail with wb flags");