# slexom/animal-feeding-trough architecture

> Architecture diagram of the GitHub repository slexom/animal-feeding-trough, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/slexom/animal-feeding-trough
- Repository: https://github.com/slexom/animal-feeding-trough

## Overview

##### Project type and purpose
- This is a multi-platform Minecraft mod (“Animal Feeding Trough”) that uses the Architectury API to share a common codebase while targeting both Fabric and NeoForge (Forge-compatible) mod loaders.
- Its purpose is to let mobs automatically find and use a feeding trough in world, triggering feed/breed behavior.

##### File structure
- Top-level modules:
- common/ – core Java code and resources shared across platforms
- fabric/ – Fabric-specific entrypoints and metadata
- neoforge/ – NeoForge-specific entrypoints and metadata
- common/src/main/java/slexom/animal_feeding_trough:
- AnimalFeedingTroughMod.java – common mod initializer via Architectury
- block/FeedingTroughBlock.java, block/entity/FeedingTroughBlockEntity.java – block+tile-entity definitions
- inventory/BlockEntityInventory.java – custom inventory logic
- goal/entity/ai/SelfFeedGoal.java – AI goal for mobs
- mixin/… – Mixin classes to inject into Minecraft’s AnimalEntity & GoalSelector
- screen/FeedingTroughScreen(.java) & FeedingTroughScreenHandler.java – GUI and screen handler
- common/src/main/resources:
- assets/… – blockstates, models, textures, lang files
- data/… – recipes, loot tables, advancements
- mixins.animal_feeding_trough.json – Mixin config
- fabric/ and neoforge/ each contain:
- platform entrypoint classes registering the common mod
- loader metadata (fabric.mod.json, neoforge.mods.toml)
- build scripts:
- root build.gradle, settings.gradle, gradle wrapper
- module-specific build.gradle files

##### README for additional insights
- Confirms this is an Architectury mod, versioned 1.1.2, supporting multiple MC versions.

##### Essential architectural elements
- Don’t omit the Mixin mechanism—it’s key to how the mod alters vanilla behavior.
- Resource pipelines (assets, data) feeding into the engine.
- Separate UI (FeedingTroughScreen) from server-side logic (AI goal, block entity).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Mod Loaders"
        FL["Fabric Loader"]:::loader
        NL["NeoForge Loader"]:::loader
    end

    subgraph "Platform Modules"
        FM["Fabric Module"]:::platform
        NM["NeoForge Module"]:::platform
    end

    Arch["Architectury API"]:::arch

    subgraph "Common Module"
        CMInit["Mod Initializer"]:::common
        Blocks["Feeding Trough Block"]:::common
        BlockEntity["Feeding Trough BlockEntity"]:::common
        Inventory["BlockEntityInventory"]:::common
        AI["SelfFeedGoal"]:::common
        Screen["FeedingTroughScreen"]:::common
        ScreenHandler["FeedingTroughScreenHandler"]:::common
        subgraph "Resources"
            Assets["Assets (blockstates, models, textures, lang)"]:::common
            Data["Data (recipes, loot tables, advancements)"]:::common
            MixConfig["mixin configuration"]:::common
        end
    end

    subgraph "Mixin Layer"
        M1["AnimalEntityMixin"]:::mixin
        M2["GoalSelectorAccessor"]:::mixin
        M3["TemptGoalAccessor"]:::mixin
    end

    subgraph "Minecraft Engine"
        GR["Game Registry"]:::engine
        ES["Entity System & AI GoalSelector"]:::engine
        ADL["Asset/Data Loader"]:::engine
        SM["Screen Manager"]:::engine
    end

    FL -->|"loads"| FM
    NL -->|"loads"| NM
    FM -->|"calls entrypoint"| CMInit
    NM -->|"calls entrypoint"| CMInit
    CMInit -->|"registers block"| GR
    Blocks -->|"defines block"| GR
    BlockEntity -->|"defines block entity"| GR
    ScreenHandler -->|"registers GUI"| SM
    Assets -->|"loaded by"| ADL
    Data -->|"loaded by"| ADL
    ES -->|"executes goal"| AI
    AI -->|"queries inventory"| Inventory
    M1 -->|"inject mixin"| ES
    M2 -->|"inject mixin"| ES
    M3 -->|"inject mixin"| ES

    classDef common fill:#cce5ff,stroke:#0066cc,color:#000;
    classDef platform fill:#d4edda,stroke:#218838,color:#000;
    classDef arch fill:#ffe5b4,stroke:#cc7a00,color:#000;
    classDef mixin fill:#fff3b0,stroke:#ccb400,color:#000;
    classDef engine fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef loader fill:#f8d7da,stroke:#721c24,color:#000;

    click CMInit "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/AnimalFeedingTroughMod.java"
    click Blocks "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/block/FeedingTroughBlock.java"
    click BlockEntity "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/block/entity/FeedingTroughBlockEntity.java"
    click Inventory "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/inventory/BlockEntityInventory.java"
    click AI "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/goal/entity/ai/SelfFeedGoal.java"
    click M1 "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/mixin/AnimalEntityMixin.java"
    click M2 "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/mixin/GoalSelectorAccessor.java"
    click M3 "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/mixin/TemptGoalAccessor.java"
    click MixConfig "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/resources/mixins.animal_feeding_trough.json"
    click Screen "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/screen/FeedingTroughScreen.java"
    click ScreenHandler "https://github.com/slexom/animal-feeding-trough/blob/1.21.5/common/src/main/java/slexom/animal_feeding_trough/platform/common/screen/FeedingTroughScreenHandler.java"
    click Assets "https://github.com/slexom/animal-feeding-trough/tree/1.21.5/common/src/main/resources/assets/animal_feeding_trough/"
    click Data "https://github.com/slexom/animal-feeding-trough/tree/1.21.5/common/src/main/resources/data/animal_feeding_trough/"
    click FM "https://github.com/slexom/animal-feeding-trough/tree/1.21.5/fabric/"
    click NM "https://github.com/slexom/animal-feeding-trough/tree/1.21.5/neoforge/"
```
