Skip to Content

Overview

AttributeValue
Health10 HP (5 hearts)
Size0.9 x 0.9 blocks
Movement Speed0.25 walk, 0.35 run
DietCarrots, potatoes, beetroots, beetroot soup
Social TypeHerd animal
Maturity Time24000 ticks (20 minutes)

Behaviors

Rooting Behavior

Implementation: PigRootingGoal

Pigs root in soil to find truffles, a valuable food item.

Rootable Blocks and Truffle Chances:

Block TypeTruffle Chance
Grass blocks5%
Mycelium15% (highest)
Podzol12%
Regular dirt0%

Behavior Details:

  • Rooting duration: 40 ticks (2 seconds)
  • Search range: 8 blocks
  • 30% chance to convert grass to dirt after rooting
  • Spawns dirt particles during rooting
  • Plays pig ambient sounds

Truffle Hunting

Pigs can detect and actively pursue truffles.

Truffle Item Properties:

PropertyValue
Nutrition6 hunger points
Saturation0.6
RarityRare (blue item name)

Detection Behaviors:

  • Pigs show heart particles when truffles are within 8 blocks
  • Different soil types affect discovery rates

Truffle Seeking

Implementation: PigTruffleSeekGoal

Pigs actively pursue dropped truffles they detect.

Behavior Details:

  • Detection range: 16 blocks
  • Movement speed: 1.2x normal
  • Cooldown: 30 seconds after seeking
  • Shows sniffing particles while tracking
  • Heart particles when close to truffle
  • High priority (overrides most other behaviors)

Truffle Sniffing

Implementation: PigSniffTrufflesGoal

Pigs pause and sniff when detecting interesting scents.

Detection Targets:

  • Dropped truffle items (highest priority)
  • Nearby food crops
  • Mycelium or podzol blocks

Behavior Details:

  • Detection range: 12 blocks
  • Sniff duration: 3 seconds
  • Cooldown: 10 seconds
  • Pig looks toward scent source
  • Sneeze particle effects and sniffing sounds

Mud Bathing

Implementation: PigMudBathingGoal

Pigs seek out mud, water, or clay to bathe for temperature regulation.

Benefits:

  • Restores condition (+2 per second while bathing)
  • Provides temperature regulation in hot weather
  • Applies visual mud effect (5 minutes / 6000 ticks)

Trigger Conditions:

  • Random chance (5% for adults, 10% for babies)
  • Increased likelihood when health is below 80%
  • Increased likelihood during hot daytime

Behavior Details:

  • Bathing duration: 200 ticks (10 seconds)
  • Search range: 16 blocks
  • Water dripping particle effects
  • Ambient sounds at lower pitch

Social Mud Bathing

Implementation: PigSocialMudBathingGoal

Pigs in mud attract other pigs to join them.

Behavior Details:

  • Attraction range: 12 blocks
  • Chance to attract: 30% per nearby pig
  • Maximum 4 pigs per group bath
  • Social duration: 20 seconds
  • Happy villager particles when group forms

Crop Feeding

Implementation: PigFeedingGoal

Pigs seek out and eat fully grown crops.

Edible Crops:

CropHunger Restoration
Carrots+20
Potatoes+25
Beetroots+15

Behavior Details:

  • Heals 1 HP (0.5 hearts) when eating
  • Eating duration: 30 ticks (1.5 seconds)
  • Destroys the crop block
  • Search range: 12 blocks

Trigger Conditions:

  • Random chance (15% normally, 20% for babies)
  • Increased to 40% when hunger is below 50

Hunger System

ParameterValue
Maximum100
Starting75
Decay Rate0.015 per tick
Starvation Damage1 HP every 10 seconds below 5 hunger

Condition System

ParameterValue
Maximum100
Starting70
EffectAffects breeding success and truffle finding
GainWhen satiated
LossWhen hungry/starving

Social System

ParameterValue
TypeHerd animal
Social Range16 blocks
Decay Rate0.008 per tick when alone
Recovery Rate0.1 per tick near herd
Loneliness Threshold40

Goal Priority System

PriorityGoal
0FloatGoal (vanilla)
3PigTruffleSeekGoal
4WaterAvoidingRandomStrollGoal
5Rooting, MudBathing, SocialMudBathing, Feeding
6Sniffing

Visual Effects

Mud Effect

  • Brown tint overlay when pig has mud effect
  • Alpha fades over 5 minutes
  • Registered in client renderer

Configuration

All pig behaviors use hardcoded scientific constants based on real pig behavior research. Behaviors are implemented via code-based handles in the pig mixin.

Scientific Basis

Truffle Hunting

Based on the real practice of using pigs to find truffles, which exploits their natural rooting behavior and keen sense of smell.

Mud Bathing

Based on thermoregulation behavior in pigs, which lack sweat glands and use mud to cool down and protect their skin.

Rooting

Based on natural foraging behavior where pigs use their snouts to search for food in the soil.

Social Behavior

Based on natural herd dynamics observed in wild and domestic pigs.

See Also

Last updated on