Entity Base
All entities inherit from theEntityBase trait providing core functionality.
Entity Lifecycle
pumpkin/src/entity/mod.rs:91-148
Core Entity Properties
- Position & Rotation: Atomic position tracking
- Velocity: Physics-based movement
- Bounding Box: Collision detection
- Metadata: Synced entity data
- Age: Tick counter for entity lifecycle
Entity Types
Pumpkin supports these entity categories:Living Entities
- Players: Human-controlled entities
- Mobs: Hostile and neutral creatures
- Passive Mobs: Animals and friendly creatures
pumpkin/src/entity/living.rs
Projectiles
- Arrows: Shot from bows/crossbows
- Snowballs: Throwable items
- Eggs: Thrown eggs
- Fireballs: Ghast/blaze projectiles
- Wind Charges: Breeze attacks
- Firework Rockets: Elytra propulsion
pumpkin/src/entity/projectile/
Vehicles
- Boats: Water and chest boats
- Minecarts: Rail transport
pumpkin/src/entity/vehicle/
Other Entities
- Items: Dropped items (
ItemEntity) - Experience Orbs: XP drops
- TNT: Primed explosives
- Falling Blocks: Sand, gravel physics
- Armor Stands: Display entities
- Paintings: Decorative art
- End Crystals: End dimension entities
pumpkin/src/entity/
Entity Spawning
Spawn entities using the world interface:EntityType::ZombieEntityType::SkeletonEntityType::CowEntityType::Arrow
pumpkin-world/src/world.rs:88-92
Entity Metadata
Pumpkin uses tracked data for client synchronization:DATA_BABY: Baby entity flagDATA_CUSTOM_NAME: Entity display nameDATA_HEALTH: Current healthDATA_ARMOR: Armor value
pumpkin/src/entity/mod.rs:122-128
Mob AI System
Pumpkin features a sophisticated AI system for mob behavior.Goal System
Mobs use prioritized goals:Movement Goals
WanderAround: Random explorationFollowParent: Baby animals follow adultsFollowOwner: Tamed animals follow ownerEscapeDanger: Flee from threatsSwim: Prevent drowning
pumpkin/src/entity/ai/goal/
Combat Goals
MeleeAttack: Close-range combatZombieAttack: Zombie-specific attackChasePlayer: Enderman chase behaviorRevenge: Target attackersActiveTarget: Hunt specific entities
pumpkin/src/entity/ai/goal/
Interaction Goals
LookAtEntity: Face nearby entitiesLookAround: Ambient head movementTempt: Follow player holding foodBeg: Wolf begging behaviorBreed: Animal breeding
pumpkin/src/entity/ai/goal/
Special Goals
CreeperIgnite: Creeper explosionEatGrass: Sheep grazingPickUpBlock: Enderman block pickupPlaceBlock: Enderman block placementDestroyEgg: Zombie turtle egg breaking
pumpkin/src/entity/ai/goal/
Pathfinding
Advanced pathfinding for mob navigation:pumpkin/src/entity/ai/pathfinder/
Features:
- A Algorithm*: Efficient pathfinding
- Path Caching: Reuse computed paths
- Block Awareness: Navigate around obstacles
- Jump Detection: Navigate elevation changes
Mob Types
Hostile Mobs
Zombies
- Zombie: Standard undead
- Zombie Villager: Curable zombie
- Husk: Desert variant
- Drowned: Underwater zombie
pumpkin/src/entity/mob/zombie/
Skeletons
- Skeleton: Bow-wielding undead
- Wither Skeleton: Nether variant
- Stray: Snow biome skeleton
- Bogged: Swamp skeleton
- Parched: Desert skeleton
pumpkin/src/entity/mob/skeleton/
Other Hostiles
- Creeper: Explosive mob
- Enderman: Teleporting mob
- Silverfish: Small insect
- Bat: Ambient cave mob
pumpkin/src/entity/mob/
Passive Mobs
- Cow: Milk and beef source
- Pig: Rideable animal
- Sheep: Wool provider
- Chicken: Egg layer
- Cat: Tamed companion
- Wolf: Tamed protector
pumpkin/src/entity/passive/
Utility Mobs
- Iron Golem: Village protector
- Snow Golem: Snowball thrower
pumpkin/src/entity/passive/
Boss Mobs
- Wither: Three-headed boss
pumpkin/src/entity/boss/
Player Entity
Players are special living entities with additional features:pumpkin/src/entity/player.rs
Player-specific features:
- Gamemode: Survival, Creative, Adventure, Spectator
- Inventory: Item storage and hotbar
- Abilities: Flight, invulnerability
- Experience: Levels and points
- Hunger: Food and saturation
- Attributes: Health, speed, reach distance
Entity Attributes
Customizable entity properties:pumpkin/src/entity/attributes.rs
Attributes affect:
- Combat effectiveness
- Movement capabilities
- Survival stats
Entity Effects
Status effects modify entity behavior:- Beneficial: Regeneration, Speed, Strength
- Harmful: Poison, Weakness, Slowness
- Mixed: Invisibility, Glowing
pumpkin/src/entity/effect/
Entity Combat
Combat system with damage types:- Armor reduction
- Enchantment modifiers
- Invulnerability ticks
- Knockback calculation
pumpkin/src/entity/combat.rs
Projectile Deflection
Certain entities can deflect projectiles:pumpkin/src/entity/projectile_deflection.rs
Network Synchronization
Entities are synchronized to clients via packets:CSpawnEntity: Initial entity spawnCUpdateEntityPos: Position updatesCUpdateEntityPosRot: Position and rotationCUpdateEntityRot: Rotation onlyCSetEntityMetadata: Metadata changesCSetPassengers: Vehicle mountingCTeleportEntity: Teleportation
pumpkin-protocol/src/java/client/play/
Performance Optimizations
- Atomic Operations: Lock-free position/rotation updates
- Async Ticking: Non-blocking entity updates
- Spatial Partitioning: Efficient entity queries
- Packet Batching: Combine nearby entity updates
