Re-located Code

co-author helped me match the code to the Java decomp. Works perfectly in parity with Java.

Co-Authored-By: Alexandra-Myers <78748498+alexandra-myers@users.noreply.github.com>
This commit is contained in:
arsenicviscera 2026-03-11 22:35:08 -07:00
parent 5b16ced306
commit 15f555025a
4 changed files with 20 additions and 12 deletions

View file

@ -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;

View file

@ -13,7 +13,7 @@ public:
// 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;

View file

@ -65,16 +65,28 @@ void FoodData::tick(shared_ptr<Player> 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++;

View file

@ -1008,11 +1008,6 @@ void Player::aiStep()
if ((level->difficulty == Difficulty::PEACEFUL)) {
heal(1);
}
//Quick-Regen from saturation (must have full hunger and have at least 3 saturation)
else if (fd->getSaturationLevel() > 3 && fd->getFoodLevel() == 20) {
heal(1);
fd->setSaturation(fd->getSaturationLevel() - 3);
}
};
}