Instruction file imported from jacoblontoc/better-ecology (
.github/instructions/Better Ecology.instructions.md). Copyright stays with the author.
Better Ecology - Coding Instructions
1. Project Architecture (Composition-Based)
Follow this exact file structure for expandability. Do not use deep inheritance; use Traits and Interactions.
Structure: āāā api/ // Interfaces and base classes for other mods to hook into ā āāā trait/ // Base ITrait interfaces ā āāā interaction/ // Base IInteraction interfaces āāā core/ // The "Engine" (Phase 1 logic) ā āāā components/ // The actual Data Attachments (Energy, Sex, NPK) ā āāā seasons/ // Global season and weather logic ā āāā systems/ // Global calculators (The Director AI, Runoff Math) āāā content/ // YOUR SPECIFIC ORGANIZATIONS ā āāā organisms/ ā ā āāā animals/ ā ā ā āāā base/ // Base animal entity classes ā ā ā āāā fox/ ā ā ā āāā FoxEntity.java ā ā ā āāā traits/ // HibernationTrait, ScavengerTrait ā ā ā āāā interactions/ // DigFoxholeInteraction, HuntRabbitInteraction ā ā āāā plants/ ā ā āāā base/ // Base plant/tree logic ā ā āāā oak/ ā ā āāā OakTreeLogic.java ā ā āāā traits/ // HighNitrogenTrait, CanopyTrait ā ā āāā interactions/ // DropLeafLitterInteraction, RootsBreakStoneInteraction ā āāā blocks/ ā āāā soil/ ā ā āāā SoilBlock.java ā ā āāā traits/ // NPKContainerTrait, MoistureTrait ā ā āāā interactions/ // NutrientsLeachInteraction ā āāā carcass/ ā āāā CarcassBlock.java ā āāā interactions/ // RottingInteraction, AttractScavengerInteraction āāā client/ // Rendering, Models, and Particles (Phase 2 visuals) āāā registry/ // Where you tell Minecraft "This block exists"
2. Naming Conventions and Style
- Member Variables: Use the
m_prefix (e.g.,private float m_energyLevel). - Methods: Use standard camelCase.
- Documentation: Every class and public method must have a detailed Javadoc explanation.
- Safety: Use
@Nullableand@Nonnullannotations consistently. Perform null checks on all registry lookups.
3. Data-Driven Logic (JSON Priority)
- All ecological constants (growth rates, scent potency, consumption rates, age limits) must be loaded from JSON configuration files.
- Use a central Configuration Manager to allow real-time adjustments without recompilation.
4. Biological Systems Logic
- Values: Energy, Stress, Nitrogen, Phosphorus, Potassium, Moisture are all floats [0.0 - 100.0].
- Time Continuity: For systems like decomposition or aging, use timestamps (World Time). Upon chunk reload, calculate the delta between
currentTimeandlastUpdateto "catch up" the state (e.g., Fresh Carcass -> Skeletal Carcass). - Entity AI: Use AzureLib for animations. Prioritize POI (Point of Interest) coordinates for "Home" behaviors.
5. Visual Constraints
- Texture Density: Strictly 16x16.
- Geometry: Use Minecraft-native shapes.
- "Slim" logs should use Fence geometry.
- "Chunky" logs should use Wall geometry.
- No curves or smaller-than-pixel sub-models.
6. Soil and Block Logic
- Soil blocks must store NPK/Moisture data using Data Components.
- Implement "Nutrient Runoff" logic where gravity pulls NPK values from higher Y-levels to lower Y-levels during rain events.
7. Interaction Logic
- Traits: Data-only components (e.g., Sex, GeneticPotential).
- Interactions: Action-based components (e.g., HuntInteraction, GrazingInteraction).
- Predators: Pathfind based on "Scent" values. Scent potency of a Carcass must increase over time via JSON-defined curves.