# ice129/engram-horror-mod architecture

> Architecture diagram of the GitHub repository ice129/engram-horror-mod, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ice129/engram-horror-mod
- Repository: https://github.com/ice129/engram-horror-mod

## Overview

##### Project type and purpose
- This is a Java-based Minecraft mod (“ENGRAM”) built on the Fabric mod loader.
- Its purpose is to inject horror mechanics into the vanilla Minecraft experience via custom entities, world events, configuration, networking, and client-side visual/audio hooks.

##### File structure
- Top-level Gradle build files and `settings.gradle` configure the build.
- `src/main/java` contains one package tree (`horror.blueice129`) subdivided into:
- Core mod classes (`HorrorMod129.java`, data generator)
- Client-only code (`client/…` for renderers, model registration, input hooks)
- Command definitions (`command/DebugCommands.java`)
- Configuration (`config/ConfigManager.java`, `ModConfig.java`, `ConfigScreen.java`)
- Data persistence (`data/HorrorModPersistentState.java`)
- Debug utilities (`debug/LineOfSightChecker.java`)
- Entity definitions (`entity/…`), AI goal implementations (`entity/goals/...`)
- Gameplay features (`feature/…`, e.g. `BrightnessChanger`, `SmallStructureEvent`)
- Integration adapters (`integration/ModMenuIntegration.java`)
- Mixin hooks into Minecraft internals (`mixin/ExampleMixin.java`)
- Networking (`network/ModNetworking.java`, packet handlers)
- Scheduled tasks (`scheduler/…`), tied to in-game ticks/world events
- Utility helpers (`utils/…`) for pathfinding, block placement, etc.
- `src/main/resources` delivers assets (textures), Fabric metadata (`fabric.mod.json`), mixin config, and data-pack templates (JSON under `data/…`).

##### README for additional insights
- Confirms it’s a single-mod plugin for Fabric.
- Lists multiplayer support, custom events, progressive horror features, and encourages contributions.

a. Main components
- Fabric Mod Loader
- Core Mod Module (`HorrorMod129`)
- Client Subsystem (renderers, input hooks, UI screens)
- Server Subsystem (world events, schedulers, entity spawning, persistent state)
- Entity & AI Engine (custom entity classes + goal registries)
- Feature Handlers (individual gameplay features)
- Configuration Manager & UI
- Data-Pack Generator (build-time JSON producer)
- Networking Layer (custom packets & channels)
- Mixin Layer (bytecode hooks into vanilla code)
- External Integration (e.g. ModMenu)

b. Relationships & interactions
– Fabric invokes Core Mod Module on game startup → registers event listeners, entities, network channels, data generators.
– Client Subsystem communicates with Core via Fabric’s client lifecycle events; listens for incoming network packets to trigger camera shakes or UI changes.
– Server Subsystem schedules tasks each tick → triggers Feature Handlers (e.g. spawn events), updates PersistentState, enqueues network payloads to clients.
– Entity & AI Engine uses Utils classes for movement, pathfinding, and registers custom AI Goals.
– Config Manager loads/writes `ModConfig` on disk; provides runtime parameters to features and schedulers; UI screens allow in-game editing via ModMenuIntegration.
– Data-Pack Generator runs during the Gradle build → emits JSON under `data/horror_mod_129` for worldgen defaults.
– Mixin Layer patches vanilla methods as needed (e.g. to modify block breaking, camera effects).
– Networking Layer serializes `SettingsTriggerPayload` and other packets → ClientPacketHandler processes them on the client.

c. Architectural patterns & principles
- Event-driven design: Fabric event bus and schedulers
- Separation of concerns: clear split between client vs server behavior, config vs logic, data vs code
- Modular features: each horror effect encapsulated in its own class + scheduler
- Data-oriented setup: data generators and JSON templates for world changes
- Decorator/Adapter via Mixins to modify vanilla behavior without core forks

d. Key technologies/frameworks
– Java 17, Gradle
– Fabric API (lifecycle events, registry system)
– Fabric Mixin (bytecode injection)
– Minecraft’s built-in networking hooks
– Fabric Data Generators for JSON pack creation
– ModMenu integration (external mod UI)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build Time"
        Gradle["Gradle (build.gradle / settings.gradle)"]:::build
        DataGen["HorrorMod129DataGenerator"]:::build
        Resources["Data-Pack templates"]:::build
    end
    subgraph "Mod Loader"
        Fabric["Fabric Mod Loader"]:::loader
        Core["HorrorMod129"]:::core
    end
    subgraph "Runtime Components"
        subgraph "Client Subsystem"
            ClientMod["HorrorMod129Client"]:::client
            Model["Blueice129EntityModel"]:::client
            Renderer["Blueice129EntityRenderer"]:::client
            Handler["ClientPacketHandler"]:::client
            ConfigScreen["ConfigScreen"]:::client
        end
        subgraph "Server Subsystem"
            OnWorld["OnWorldCreation"]:::server
            Scheduler["HomeEventScheduler"]:::server
            Persistent["HorrorModPersistentState"]:::server
        end
        subgraph "Entity & AI Engine"
            Entity["Blueice129Entity"]:::server
            GoalsReg["GoalProfileRegistry"]:::server
            BaseGoal["BaseBlueice129Goal"]:::server
        end
        subgraph "Feature Handlers"
            Brightness["BrightnessChanger"]:::server
            Structure["SmallStructureEvent"]:::server
            DeathItems["PlayerDeathItems"]:::server
        end
        subgraph "Configuration"
            ConfigMan["ConfigManager"]:::config
            ModConfig["ModConfig"]:::config
        end
        subgraph "Networking"
            Net["ModNetworking"]:::server
            Payload["SettingsTriggerPayload"]:::server
        end
        subgraph "Mixin Layer"
            ExampleMixin["ExampleMixin"]:::mixin
            MixinCfg["horror-mod-129.mixins.json"]:::mixin
        end
        subgraph "Integration & Utilities"
            ModMenu["ModMenuIntegration"]:::integration
            DebugCmd["DebugCommands"]:::utils
            LoS["LineOfSightChecker"]:::utils
            PathVis["PathVisualizer"]:::utils
            EntUtils["EntityUtils"]:::utils
        end
    end

    %% Build-time flows
    Gradle --> DataGen
    DataGen --> Resources

    %% Loader and core
    Fabric -->|onInitialize| Core
    click Fabric "https://github.com/ice129/engram-horror-mod/blob/main/src/main/resources/fabric.mod.json"
    click Core "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/HorrorMod129.java"

    %% Core to subsystems
    Core --> ClientMod
    Core --> OnWorld
    Core --> Net
    Core --> ConfigMan
    Core --> ExampleMixin
    Core --> ModMenu

    %% Client flows
    ClientMod --> Model
    ClientMod --> Renderer
    ClientMod --> Handler
    ClientMod --> ConfigScreen

    %% Server flows
    OnWorld --> Scheduler
    Scheduler --> Brightness
    Scheduler --> Structure
    Scheduler --> DeathItems
    Scheduler --> Persistent

    %% Entity/AI
    Entity --> GoalsReg
    GoalsReg --> BaseGoal
    Brightness --> Entity
    Structure --> Entity

    %% Config interactions
    ConfigMan -->|reads/writes| ModConfig
    ModConfig -->|params| Brightness
    ModConfig -->|params| Structure

    %% Networking
    Net -->|sends| Payload
    Payload -->|to client| Handler
    Handler -->|invokes| ClientMod

    %% Mixin interceptions
    ExampleMixin -.->|patches| ClientMod
    ExampleMixin -.->|patches| OnWorld

    %% Integration & Utils
    ModMenu --> ConfigScreen
    DebugCmd --> ClientMod
    DebugCmd --> OnWorld
    LoS --> BaseGoal
    PathVis --> Entity
    EntUtils --> Structure

    %% Click Events
    click DataGen "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/HorrorMod129DataGenerator.java"
    click ClientMod "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/client/HorrorMod129Client.java"
    click Model "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/client/entity/model/Blueice129EntityModel.java"
    click Renderer "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/client/entity/renderer/Blueice129EntityRenderer.java"
    click OnWorld "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/scheduler/OnWorldCreation.java"
    click Scheduler "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/scheduler/HomeEventScheduler.java"
    click Persistent "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/data/HorrorModPersistentState.java"
    click Entity "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/entity/Blueice129Entity.java"
    click GoalsReg "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/entity/goals/GoalProfileRegistry.java"
    click BaseGoal "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/entity/goals/BaseBlueice129Goal.java"
    click Brightness "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/feature/BrightnessChanger.java"
    click Structure "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/feature/SmallStructureEvent.java"
    click DeathItems "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/feature/PlayerDeathItems.java"
    click ConfigMan "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/config/ConfigManager.java"
    click ModConfig "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/config/ModConfig.java"
    click ConfigScreen "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/config/ConfigScreen.java"
    click Net "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/network/ModNetworking.java"
    click Payload "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/network/SettingsTriggerPayload.java"
    click Handler "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/network/ClientPacketHandler.java"
    click ExampleMixin "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/mixin/ExampleMixin.java"
    click MixinCfg "https://github.com/ice129/engram-horror-mod/blob/main/src/main/resources/horror-mod-129.mixins.json"
    click ModMenu "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/integration/ModMenuIntegration.java"
    click DebugCmd "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/command/DebugCommands.java"
    click LoS "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/debug/LineOfSightChecker.java"
    click PathVis "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/utils/PathVisualizer.java"
    click EntUtils "https://github.com/ice129/engram-horror-mod/blob/main/src/main/java/horror/blueice129/utils/EntityUtils.java"

    %% Styles
    classDef loader fill:#ADD8E6,stroke:#000,color:#000;
    classDef core fill:#87CEFA,stroke:#000,color:#000;
    classDef client fill:#FFA500,stroke:#000,color:#000;
    classDef server fill:#90EE90,stroke:#000,color:#000;
    classDef build fill:#D3D3D3,stroke:#000,color:#000;
    classDef mixin stroke-dasharray: 5 5,fill:#F5F5F5,stroke:#000,color:#000;
    classDef config fill:#DDA0DD,stroke:#000,color:#000;
    classDef integration fill:#FFFFE0,stroke:#000,color:#000;
    classDef utils fill:#F0E68C,stroke:#000,color:#000;
```
