Skip to Content
DocsSystemsHunger & Condition

Hunger System

Overview

The hunger system tracks how fed an animal is and affects its behavior priorities.

Parameters

ParameterTypeDescription
maxfloatMaximum hunger value
currentfloatCurrent hunger level
decay_ratefloatHunger lost per tick
starvation_thresholdfloatLevel below which starvation occurs
starvation_damagefloatDamage dealt when starving

Hunger Effects

Hunger LevelEffect
70-100%Normal behavior
40-70%Increased food seeking
10-40%Priority food seeking
0-10%Starvation damage

Hunger Restoration

Different food sources restore different amounts:

SourceRestorationExample
Grazing+25Sheep eating grass
Crops+15-25Pig eating carrots
Prey+40Wolf eating meat
ItemsVariableFed by player

Configuration

{ "hunger": { "enabled": true, "max": 100, "starting": 75, "decay_rate": 0.01, "starvation_threshold": 10, "starvation_damage": 1, "starvation_interval": 200 } }

NBT Storage

BetterEcology.hunger -> { current: 75.0, last_damage_tick: 0 }

Condition System

Overview

Condition represents overall health and well-being beyond just HP.

Parameters

ParameterTypeDescription
maxfloatMaximum condition value
currentfloatCurrent condition level

Condition Factors

Condition is affected by:

  • Hunger level (well-fed = condition gain)
  • Starvation (condition loss)
  • Mud bathing (condition restoration for pigs)
  • Social needs (isolation = condition loss)
  • Weather/temperature

Condition Effects

Condition LevelEffect
80-100%Optimal behavior, premium outputs
50-80%Normal behavior
20-50%Reduced breeding success
0-20%Impaired behavior, poor outputs

Output Quality

Condition affects output quality:

OutputHigh ConditionLow Condition
WoolPremium dropsReduced drops
BreedingHigher successLower success
Truffle findingBetter oddsWorse odds

Configuration

{ "condition": { "enabled": true, "max": 100, "starting": 70, "hunger_gain_rate": 0.02, "starvation_loss_rate": 0.05 } }

Social System

Overview

Social needs track how lonely or content an animal is with its social environment.

Parameters

ParameterTypeDescription
decay_ratefloatLoneliness increase when alone
recovery_ratefloatLoneliness decrease near herd
thresholdfloatLevel at which distress behaviors trigger

Social Needs by Animal Type

Animal TypeSocial Preference
Herd (cow, sheep, pig)Needs nearby herd
Pack (wolf)Needs pack members
Flock (chicken, parrot)Needs flock
Solitary (fox, bat)Minimal social needs

Social Effects

Loneliness LevelEffect
0-40Content, normal behavior
40-70Seeking company
70-100Distress behaviors, condition loss

Configuration

{ "social": { "enabled": true, "herd_radius": 16.0, "min_herd_size": 3, "decay_rate": 0.008, "recovery_rate": 0.1, "loneliness_threshold": 40 } }

Energy System

Overview

Energy tracks stamina for high-intensity activities like fleeing.

Energy Consumption

ActivityEnergy Cost
WalkingLow
RunningMedium
FleeingHigh
SprintingVery High

Energy Recovery

  • Resting: Fast recovery
  • Walking: Slow recovery
  • Eating: Moderate recovery

System Interactions

Hunger -> Condition

if (hunger > 70%) { condition += gain_rate; } else if (hunger < starvation_threshold) { condition -= loss_rate; }

Condition -> Behavior

if (condition < 50%) { breeding_success *= 0.5; output_quality *= condition / 100.0; }

Social -> Condition

if (loneliness > threshold) { condition -= social_loss_rate; triggerDistressBehaviors(); }

Accessing System Data

Reading Values

EcologyComponent component = entity.getComponent(); CompoundTag hungerTag = component.getHandleTag("hunger"); float currentHunger = hungerTag.getFloat("current"); float hungerPercent = currentHunger / hungerTag.getFloat("max");

Modifying Values

CompoundTag tag = component.getOrCreateHandleTag("hunger"); float current = tag.getFloat("current"); tag.putFloat("current", Math.min(current + restoration, max));

See Also

Last updated on