Skip to Content

Overview

AttributeValue
Health4 HP (2 hearts)
Movement Speed0.25
DietSeeds (wheat, melon, pumpkin, beetroot, torchflower, pitcher pod)
Social TypeFlock animal
Egg LayingYes (hunger-dependent)
PredatorsFox, Wolf, Cat, Ocelot

Behaviors

Pecking Behavior

Implementation: ChickenPeckingGoal

Chickens peck at the ground to find seeds and grubs.

Behavior Details:

ParameterValue
Animation Duration30 ticks (1.5 seconds)
Cooldown (normal)100-400 ticks
Cooldown (hungry)60-200 ticks
Find Food Chance30% (50% when hungry)

Peckable Surfaces:

  • Grass blocks
  • Dirt and coarse dirt
  • Farmland

Food Discovery:

  • 40% chance: Wheat seeds
  • 30% chance: Beetroot seeds
  • 15% chance: Melon seeds
  • 15% chance: Pumpkin seeds

Dust Bathing

Implementation: ChickenDustBathingGoal

Chickens perform dust bathing for feather maintenance and parasite control.

Trigger Conditions:

  • Standing on suitable surface (sand, gravel, dirt)
  • Not currently fleeing from predators
  • Random chance activation

Benefits:

  • Feather maintenance
  • Parasite removal simulation
  • Natural behavior enrichment

Roosting Behavior

Implementation: ChickenRoostingGoal

Chickens seek elevated perches at night for safety.

Behavior Details:

  • Activates during night time
  • Seeks fence posts, walls, or elevated blocks
  • Provides protection from ground predators
  • Highest goal priority at night

Enhanced Egg Laying

Implementation: EnhancedEggLayingGoal

Replaces vanilla egg laying with hunger-dependent system.

Requirements:

  • Hunger must be above threshold
  • Adult chickens only
  • Replaces vanilla random egg timing

Configuration: Vanilla egg laying is completely disabled via mixin injection that resets eggTime to prevent random egg drops.

Fleeing Behavior

Implementation: FleeFromPredatorGoal

Chickens flee from multiple predator types.

Flee Parameters:

ParameterValue
Speed Multiplier1.6x (fast when scared)
Detection Range12 blocks
Flee Distance20 blocks

Predators:

  • Fox
  • Wolf
  • Cat
  • Ocelot

Parent-Offspring Behaviors

Follow Parent: FollowParentGoal

Chicks follow adult chickens closely.

Separation Distress: SeparationDistressGoal

ParameterValue
Safe Distance6 blocks
Distress Range24 blocks
Speed Modifier1.3x

Mother Protection: MotherProtectBabyGoal

ParameterValue
Follow Range8 blocks
Protection Range12 blocks
Speed Modifier1.2x

Goal Priority System

PriorityGoalCondition
0ChickenDustBathingGoalOn dust bath surface
0ChickenRoostingGoalNight time
1FleeFromPredatorGoalPredator detected
2MotherProtectBabyGoalAdult with nearby chicks
3SeekWaterGoalThirsty
3SeekFoodGoalHungry
5ChickenPeckingGoalRandom interval
5FollowParentGoalChicks only
5SeparationDistressGoalSeparated from flock
6EnhancedEggLayingGoalAdult, fed
6BreedingBehaviorGoalIn love mode

Integration

Mixin Registration

Goals are registered via ChickenMixin:

@Mixin(Chicken.class) public abstract class ChickenMixin { @Inject(method = "registerGoals", at = @At("TAIL")) private void betterEcology$registerGoals(CallbackInfo ci) { Chicken chicken = (Chicken) (Object) this; var goalSelector = ((MobAccessor) chicken).getGoalSelector(); // Flee from predators goalSelector.addGoal( AnimalThresholds.PRIORITY_FLEE, new FleeFromPredatorGoal( chicken, 1.6, 12, 20, Fox.class, Wolf.class, Cat.class, Ocelot.class ) ); // Seek seeds when hungry goalSelector.addGoal( AnimalThresholds.PRIORITY_NORMAL, new SeekFoodGoal( chicken, 1.0, 12, SeekFoodGoal.FoodMode.ITEM_SEEKER, ChickenMixin::isValidChickenFood ) ); // Additional goals... } }

Pecking Goal Implementation

public class ChickenPeckingGoal extends Goal { private static final int PECKING_ANIMATION_TICKS = 30; private static final double FIND_FOOD_CHANCE = 0.3; private static final double HUNGRY_FIND_FOOD_CHANCE = 0.5; @Override public boolean canUse() { if (this.peckingCooldown > 0) { this.peckingCooldown--; return false; } return findPeckableGround() != null; } private void tryFindFood() { boolean isHungry = AnimalNeeds.isHungry(this.chicken); double findChance = isHungry ? HUNGRY_FIND_FOOD_CHANCE : FIND_FOOD_CHANCE; if (this.chicken.getRandom().nextDouble() < findChance) { ItemStack foundFood = determineFoodFound(); float hungerRestore = calculateHungerRestore(foundFood); AnimalNeeds.modifyHunger(this.chicken, hungerRestore); } } }

Food Validation

private static boolean isValidChickenFood(ItemStack stack) { if (stack.is(Items.WHEAT_SEEDS)) return true; if (stack.is(Items.MELON_SEEDS)) return true; if (stack.is(Items.PUMPKIN_SEEDS)) return true; if (stack.is(Items.BEETROOT_SEEDS)) return true; if (stack.is(Items.TORCHFLOWER_SEEDS)) return true; if (stack.is(Items.PITCHER_POD)) return true; return false; }

NBT Data

Chicken ecology state is stored in the standard ecology component:

/data get entity @e[type=chicken,limit=1] better-ecology

Expected output:

{ "hunger": 75.0, "thirst": 80.0, "last_damage_tick": 0 }

Configuration

Chicken behaviors use hardcoded scientific constants. Key parameters in ChickenPeckingGoal:

ConstantValuePurpose
PECKING_ANIMATION_TICKS30Duration of pecking animation
PECKING_COOLDOWN_MIN100Minimum ticks between pecks
PECKING_COOLDOWN_MAX400Maximum ticks between pecks
FIND_FOOD_CHANCE0.3Base chance to find food
HUNGRY_FIND_FOOD_CHANCE0.5Find chance when hungry

Scientific Basis

Pecking Behavior

Based on natural chicken foraging patterns. Domestic chickens spend 60-90% of daylight hours foraging and scratching at the ground. Pecking rate increases when hungry, matching the goal’s dynamic cooldown system.

Dust Bathing

Based on research showing dust bathing is an essential maintenance behavior in birds. Chickens dust bathe to remove parasites and excess oil from feathers. Deprivation of dust bathing opportunities causes stress in domestic poultry.

Roosting

Based on natural anti-predator behavior. Wild jungle fowl (ancestors of domestic chickens) roost in trees at night. Elevated sleeping positions reduce predation risk from ground-based predators.

Flocking

Based on research showing chickens maintain small flock groups with complex social hierarchies. Separation from the flock causes measurable stress responses.

Alarm Responses

Based on research showing chickens have distinct alarm calls for aerial vs ground predators. The flee behavior with multiple predator detection reflects this sophisticated threat assessment.

See Also

Last updated on