diff --git a/Minecraft.World/FoodConstants.cpp b/Minecraft.World/FoodConstants.cpp index a8e024a2b..e4a5e2725 100644 --- a/Minecraft.World/FoodConstants.cpp +++ b/Minecraft.World/FoodConstants.cpp @@ -12,6 +12,7 @@ const float FoodConstants::EXHAUSTION_DROP = 4.0f; // number of game ticks to change health because of food const int FoodConstants::HEALTH_TICK_COUNT = 80; +const int FoodConstants::QUICK_HEALTH_TICK_COUNT = 10; const int FoodConstants::HEAL_LEVEL = 18; const int FoodConstants::STARVE_LEVEL = 0; diff --git a/Minecraft.World/FoodConstants.h b/Minecraft.World/FoodConstants.h index cc4620cb9..84728e717 100644 --- a/Minecraft.World/FoodConstants.h +++ b/Minecraft.World/FoodConstants.h @@ -13,7 +13,7 @@ class FoodConstants // number of game ticks to change health because of food static const int HEALTH_TICK_COUNT; - + static const int QUICK_HEALTH_TICK_COUNT; static const int HEAL_LEVEL; static const int STARVE_LEVEL; diff --git a/Minecraft.World/FoodData.cpp b/Minecraft.World/FoodData.cpp index ab0ced84b..e2452739f 100644 --- a/Minecraft.World/FoodData.cpp +++ b/Minecraft.World/FoodData.cpp @@ -65,16 +65,28 @@ void FoodData::tick(shared_ptr player) } } } - else if (player->level->getGameRules()->getBoolean(GameRules::RULE_NATURAL_REGENERATION) && foodLevel >= FoodConstants::HEAL_LEVEL && player->isHurt()) + else if (player->level->getGameRules()->getBoolean(GameRules::RULE_NATURAL_REGENERATION) && foodLevel >= FoodConstants::MAX_FOOD && player->isHurt()) { tickTimer++; - if (tickTimer >= FoodConstants::HEALTH_TICK_COUNT) - { - player->heal(1); - addExhaustion(FoodConstants::EXHAUSTION_HEAL); - tickTimer = 0; + + if (tickTimer >= FoodConstants::QUICK_HEALTH_TICK_COUNT) { + float spent = min(getSaturationLevel(), 6.0f); + player->heal(spent / 6.0f); + addExhaustion(spent); + tickTimer = 0; } + + } + else if (player->level->getGameRules()->getBoolean(GameRules::RULE_NATURAL_REGENERATION) && foodLevel >= FoodConstants::HEAL_LEVEL && player->isHurt()) { + if (tickTimer >= FoodConstants::HEALTH_TICK_COUNT) + { + player->heal(1); + addExhaustion(FoodConstants::EXHAUSTION_HEAL); + tickTimer = 0; + } + } + else if (foodLevel <= FoodConstants::STARVE_LEVEL) { tickTimer++; diff --git a/Minecraft.World/Player.cpp b/Minecraft.World/Player.cpp index 00c7148e4..8f7e7b982 100644 --- a/Minecraft.World/Player.cpp +++ b/Minecraft.World/Player.cpp @@ -1001,9 +1001,15 @@ void Player::aiStep() { if (jumpTriggerTime > 0) jumpTriggerTime--; - if (level->difficulty == Difficulty::PEACEFUL && getHealth() < getMaxHealth() && level->getGameRules()->getBoolean(GameRules::RULE_NATURAL_REGENERATION)) - { - if (tickCount % 20 * 12 == 0) heal(1); + if (level->getGameRules()->getBoolean(GameRules::RULE_NATURAL_REGENERATION)) { + bool health_OK = getHealth() < getMaxHealth(); + if ((tickCount % 12 == 0) && health_OK) { + FoodData* fd = getFoodData(); + if ((level->difficulty == Difficulty::PEACEFUL)) { + heal(1); + } + + }; } inventory->tick(); oBob = bob;