Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor 2020-12-29 18:00:09 +00:00
commit d76883a5f8
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
4 changed files with 38 additions and 7 deletions

View File

@ -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. - Server uptime is now included in crash reports.
- Hoes now take damage when used to break sponges. - Hoes now take damage when used to break sponges.
- Using lava as fuel in a furnace now leaves behind an empty bucket. - 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).

View File

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace pocketmine { namespace pocketmine {
use Composer\InstalledVersions;
use pocketmine\errorhandler\ErrorToExceptionHandler; use pocketmine\errorhandler\ErrorToExceptionHandler;
use pocketmine\thread\ThreadManager; use pocketmine\thread\ThreadManager;
use pocketmine\utils\Filesystem; use pocketmine\utils\Filesystem;
@ -188,6 +189,20 @@ namespace pocketmine {
} }
define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap); define('pocketmine\COMPOSER_AUTOLOADER_PATH', $bootstrap);
require_once(\pocketmine\COMPOSER_AUTOLOADER_PATH); 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')){ if(extension_loaded('parallel')){
\parallel\bootstrap(\pocketmine\COMPOSER_AUTOLOADER_PATH); \parallel\bootstrap(\pocketmine\COMPOSER_AUTOLOADER_PATH);
} }

View File

@ -157,16 +157,20 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
} }
public function consumeObject(Consumable $consumable) : bool{ public function consumeObject(Consumable $consumable) : bool{
if($consumable instanceof FoodSource){ if($consumable instanceof FoodSource && $consumable->requiresHunger() and !$this->hungerManager->isHungry()){
if($consumable->requiresHunger() and !$this->hungerManager->isHungry()){
return false; return false;
} }
return parent::consumeObject($consumable);
}
protected function applyConsumptionResults(Consumable $consumable) : void{
if($consumable instanceof FoodSource){
$this->hungerManager->addFood($consumable->getFoodRestore()); $this->hungerManager->addFood($consumable->getFoodRestore());
$this->hungerManager->addSaturation($consumable->getSaturationRestore()); $this->hungerManager->addSaturation($consumable->getSaturationRestore());
} }
return parent::consumeObject($consumable); parent::applyConsumptionResults($consumable);
} }
public function getXpManager() : ExperienceManager{ public function getXpManager() : ExperienceManager{

View File

@ -269,13 +269,20 @@ abstract class Living extends Entity{
* etc. * etc.
*/ */
public function consumeObject(Consumable $consumable) : bool{ 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){ foreach($consumable->getAdditionalEffects() as $effect){
$this->effectManager->add($effect); $this->effectManager->add($effect);
} }
$consumable->onConsume($this); $consumable->onConsume($this);
return true;
} }
/** /**