API Reference¶
This section provides reference documentation for developers integrating with Better Ecology.
Overview¶
Better Ecology provides APIs for:
- Accessing entity ecology data
- Registering custom behavior handles
- Modifying entity configurations
- Querying spatial data
Core Interfaces¶
EcologyAccess¶
Access ecology components from entities:
EcologyHandle¶
Interface for implementing custom behavior systems:
public interface EcologyHandle {
boolean supports(EcologyProfile profile);
void registerGoals(Mob mob, GoalSelector goals, GoalSelector targets);
void tick(Mob mob);
void readNbt(CompoundTag tag);
void writeNbt(CompoundTag tag);
}
EcologyComponent¶
Per-entity data storage:
// Read handle data
CompoundTag hungerTag = component.getHandleTag("hunger");
float hunger = hungerTag.getFloat("current");
// Write handle data
CompoundTag tag = component.getOrCreateHandleTag("hunger");
tag.putFloat("current", newValue);
Registering Custom Handles¶
Register handles during mod initialization:
Custom handles are automatically enabled for entities whose profiles include the handle's configuration keys.
Spatial Queries¶
Query nearby entities efficiently:
Events¶
Better Ecology fires events at key lifecycle points:
- Profile reload
- Goal registration
- Entity tick
- NBT save/load
Further Documentation¶
- Architecture - System design overview
- Ecology Component - Component details
- Behavior System - Goal and steering system