diff options
| author | Loki Rautio <lokirautio@gmail.com> | 2026-03-04 03:56:03 -0600 |
|---|---|---|
| committer | Loki Rautio <lokirautio@gmail.com> | 2026-03-04 03:56:03 -0600 |
| commit | 42aec6dac53dffa6afe072560a7e1d4986112538 (patch) | |
| tree | 0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/FoodData.cpp | |
| parent | c9d58eeac7c72f0b3038e084667b4d89a6249fce (diff) | |
| parent | ef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff) | |
Merge branch 'main' into pr/win64-world-saves
# Conflicts:
# Minecraft.Client/MinecraftServer.cpp
# README.md
Diffstat (limited to 'Minecraft.World/FoodData.cpp')
| -rw-r--r-- | Minecraft.World/FoodData.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Minecraft.World/FoodData.cpp b/Minecraft.World/FoodData.cpp index 79ef0fc1..ab0ced84 100644 --- a/Minecraft.World/FoodData.cpp +++ b/Minecraft.World/FoodData.cpp @@ -13,9 +13,9 @@ FoodData::FoodData() exhaustionLevel = 0; tickTimer = 0; - this->foodLevel = FoodConstants::MAX_FOOD; - this->lastFoodLevel = FoodConstants::MAX_FOOD; - this->saturationLevel = FoodConstants::START_SATURATION; + foodLevel = FoodConstants::MAX_FOOD; + lastFoodLevel = FoodConstants::MAX_FOOD; + saturationLevel = FoodConstants::START_SATURATION; } void FoodData::eat(int food, float saturationModifier) @@ -50,9 +50,9 @@ void FoodData::tick(shared_ptr<Player> player) } } - // 4J Added - Allow host to disable using hunger. We don't deplete the hunger bar due to exhaustion - // but I think we should deplete it to heal - if(player->isAllowedToIgnoreExhaustion()) + // 4J: Added - Allow host to disable using hunger. We don't deplete the hunger bar due to exhaustion + // but I think we should deplete it to heal. Don't heal if natural regen is disabled + if(player->isAllowedToIgnoreExhaustion() && player->level->getGameRules()->getBoolean(GameRules::RULE_NATURAL_REGENERATION)) { if(foodLevel > 0 && player->isHurt()) { @@ -65,12 +65,13 @@ void FoodData::tick(shared_ptr<Player> player) } } } - else if (foodLevel >= FoodConstants::HEAL_LEVEL && player->isHurt()) + else if (player->level->getGameRules()->getBoolean(GameRules::RULE_NATURAL_REGENERATION) && foodLevel >= FoodConstants::HEAL_LEVEL && player->isHurt()) { tickTimer++; if (tickTimer >= FoodConstants::HEALTH_TICK_COUNT) { player->heal(1); + addExhaustion(FoodConstants::EXHAUSTION_HEAL); tickTimer = 0; } } @@ -145,15 +146,15 @@ float FoodData::getSaturationLevel() void FoodData::setFoodLevel(int food) { - this->foodLevel = food; + foodLevel = food; } void FoodData::setSaturation(float saturation) { - this->saturationLevel = saturation; + saturationLevel = saturation; } void FoodData::setExhaustion(float exhaustion) { - this->exhaustionLevel = exhaustion; + exhaustionLevel = exhaustion; }
\ No newline at end of file |
