diff --git a/changelogs/3.17.md b/changelogs/3.17.md index 577990168..0e710dbed 100644 --- a/changelogs/3.17.md +++ b/changelogs/3.17.md @@ -21,3 +21,8 @@ Plugin developers should **only** update their required API to this version if y - Server uptime is now included in crash reports. - Hoes now take damage when used to break sponges. - Using lava as fuel in a furnace now leaves behind an empty bucket. + +# 3.17.2 +- Fixed region header corruption when chunks with larger-than-expected lengths are found. These chunks are now treated as corrupted, instead of automatically attempting to salvage them (which usually fails anyway). +- `RegionLoader->removeChunk()` now allows the space used by the removed chunk to be reused by future region saves. +- Extracted `Living->applyConsumptionResults()` from `Living->consumeObject()` (preparation for a future bug fix). diff --git a/src/PocketMine.php b/src/PocketMine.php index 857256990..c97474a3f 100644 --- a/src/PocketMine.php +++ b/src/PocketMine.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace pocketmine { + use Composer\InstalledVersions; use pocketmine\errorhandler\ErrorToExceptionHandler; use pocketmine\thread\ThreadManager; use pocketmine\utils\Filesystem; @@ -188,6 +189,20 @@ namespace pocketmine { } define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap); require_once(\pocketmine\COMPOSER_AUTOLOADER_PATH); + + $composerGitHash = InstalledVersions::getReference('pocketmine/pocketmine-mp'); + if($composerGitHash !== null){ + //we can't verify dependency versions if we were installed without using git + $currentGitHash = explode("-", VersionInfo::getGitHash())[0]; + if($currentGitHash !== $composerGitHash){ + critical_error("Composer dependencies and/or autoloader are out of sync."); + critical_error("- Current revision is $currentGitHash"); + critical_error("- Composer dependencies were last synchronized for revision $composerGitHash"); + critical_error("Out-of-sync Composer dependencies may result in crashes and classes not being found."); + critical_error("Please synchronize Composer dependencies before running the server."); + exit(1); + } + } if(extension_loaded('parallel')){ \parallel\bootstrap(\pocketmine\COMPOSER_AUTOLOADER_PATH); } diff --git a/src/entity/Human.php b/src/entity/Human.php index daac796a2..88321e834 100644 --- a/src/entity/Human.php +++ b/src/entity/Human.php @@ -157,16 +157,20 @@ class Human extends Living implements ProjectileSource, InventoryHolder{ } public function consumeObject(Consumable $consumable) : bool{ - if($consumable instanceof FoodSource){ - if($consumable->requiresHunger() and !$this->hungerManager->isHungry()){ - return false; - } + if($consumable instanceof FoodSource && $consumable->requiresHunger() and !$this->hungerManager->isHungry()){ + return false; + } + return parent::consumeObject($consumable); + } + + protected function applyConsumptionResults(Consumable $consumable) : void{ + if($consumable instanceof FoodSource){ $this->hungerManager->addFood($consumable->getFoodRestore()); $this->hungerManager->addSaturation($consumable->getSaturationRestore()); } - return parent::consumeObject($consumable); + parent::applyConsumptionResults($consumable); } public function getXpManager() : ExperienceManager{ diff --git a/src/entity/Living.php b/src/entity/Living.php index 08890698e..8db76c63b 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -269,13 +269,20 @@ abstract class Living extends Entity{ * etc. */ public function consumeObject(Consumable $consumable) : bool{ + $this->applyConsumptionResults($consumable); + return true; + } + + /** + * Applies effects from consuming the object. This shouldn't do any can-consume checks (those are expected to be + * handled by the caller). + */ + protected function applyConsumptionResults(Consumable $consumable) : void{ foreach($consumable->getAdditionalEffects() as $effect){ $this->effectManager->add($effect); } $consumable->onConsume($this); - - return true; } /**