Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Minecraft.World/FoodConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Minecraft.World/FoodConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
24 changes: 18 additions & 6 deletions Minecraft.World/FoodData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
12 changes: 9 additions & 3 deletions Minecraft.World/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading