# odtheking/odin architecture

> Architecture diagram of the GitHub repository odtheking/odin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/odtheking/odin
- Repository: https://github.com/odtheking/odin

## Overview

##### Main Components
- Mod Core / Entry Points:
- OdinMain (src/main/kotlin/me/odinmain) – Main mod initialization, command registration, updater, and configuration.
- Odin (odin) and OdinClient (odinclient) – Separate builds which contain their own mixins, commands, features, and UI enhancements.
- Event System:
- EventDispatcher and its associated event implementations (see packages “events/impl”).
- Feature Manager:
- Modules for different aspects (dungeons, floor7, skyblock, nether). These are further divided into subcomponents (commands, puzzles, renderers, etc.).
- Mixin Integration:
- Packages under “mixin” and “mixin/mixins” for both Odin and OdinClient show how core Minecraft classes are modified.
- UI/Rendering:
- UI directories (clickgui, hud, waypoint panels, animations, etc.) representing the user interface layer that interacts with the player.
- Command Handler:
- Directories under “commands” in both OdinMain and OdinClient that encapsulate command logic (invoked through chat commands such as /od or /odinclient).
- Configuration & Settings:
- Settings packages that manage configuration objects, storing user preferences (see “features/settings” and “config”).
- Gradle Multi-Project Build:
- Recognize that gradle files (build.gradle.kts, settings.gradle.kts) and the multi-project structure ensure these modules are built and deployed as two separate versions while sharing common code where applicable.

##### Relationships and Interactions
- The mod core initialization (OdinMain and ModCore.kt files) bootstrap the system, load configurations, and register events.
- The event system (dispatcher, events implementations) acts as the communication backbone, triggering Feature modules and UI update calls.
- The command subsystem listens for chat commands (/od, /odin, /odinclient) and in turn triggers actions in the feature components, possibly via the event system.
- UI Elements and Render modules subscribe to events (or are directly invoked by features) to update the in-game overlay or click GUI.

##### Architectural Patterns and Design Principles
- Modularity: The clear separation between modules (commands, events, mixins, features, config, UI) helps keep concerns separated.
- Multi-Project Structure: Using Gradle’s multi-project setup to build different versions (odin vs odinclient) ensures isolation and specialization.
- Mixin-based Injection: This is the key design pattern to modify Minecraft’s internals without directly modifying the game’s code.
- Event-Driven Architecture: The system uses an event dispatcher to propagate game events to various components.
- Command Pattern: The handling of multiple in-game commands and their delegation to specialized command classes.
- Modular UI Layer: A dedicated and extensible set of UI components that render HUD elements, click GUI panels, and dynamic overlays.

##### Technologies and Frameworks
- Java and Kotlin are used as primary languages.
- Gradle (with Kotlin DSL) for building the multi-project setup.
- Forge as the Minecraft modding API.
- Mixin framework (used for injecting behavior into the already compiled Minecraft code).
- Logging via Log4j (configuration is present in log4j2.xml).

##### Elements
- Clear Component Labels: e.g., “Odin Main Mod Core”, “Mixin Patching (Odin & OdinClient)”, “Event Dispatcher & Events”, “Feature Manager (Dungeon, Floor7, Nether, Skyblock)”, “Command Handler”, “UI (ClickGUI, HUD, Waypoints)”, “Configuration & Settings”, and “Gradle Build System”.
- Annotations: Add brief notes on key interactions or repository structure details as necessary.

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Gradle Multi-Project Build System"
        GR1("Root Gradle Files"):::gradle
        GR2("Odin Build File"):::gradle
        GR3("OdinClient Build File"):::gradle
    end

    subgraph "Mod Core / Entry Points"
        OMM("OdinMain Mod Core"):::modCore
        ODN("Odin Mod Core"):::modCore
        ODC("OdinClient Mod Core"):::modCore
    end

    subgraph "Event System"
        ED("EventDispatcher & Events"):::event
    end

    subgraph "Feature Manager"
        FOM("OdinMain Features"):::feature
        FOD("Odin Features"):::feature
        FOC("OdinClient Features"):::feature
    end

    subgraph "Command Handler"
        CMDM("OdinMain Commands"):::commands
        CMDC("OdinClient Commands"):::commands
    end

    subgraph "Mixin Integration"
        MixinO("Odin Mixins"):::mixin
        MixinC("OdinClient Mixins"):::mixin
    end

    subgraph "UI / Rendering Components"
        UI("OdinMain UI (ClickGUI, HUD, Waypoints)"):::ui
        FEAT_RENDER("Feature Render Modules"):::ui
    end

    subgraph "Configuration & Settings"
        CFG("OdinMain Configuration"):::config
    end

    MB("Minecraft Base Classes"):::external

    %% Connections between Gradle and Mod Core
    GR1 --> OMM
    GR1 --> ODN
    GR1 --> ODC
    GR2 --> ODN
    GR3 --> ODC

    %% Connections from Mod Core
    OMM --> ED
    ODN --> ED
    ODC --> ED
    OMM --> CFG

    %% Event System triggers features and UI updates
    ED --> FOM
    ED --> FOD
    ED --> FOC
    ED --> UI

    %% Command Handler invokes feature actions
    CMDM --> FOM
    CMDC --> FOC

    %% Feature Manager informs UI rendering components
    FOM --> UI
    FOD --> FEAT_RENDER
    FOC --> FEAT_RENDER

    %% Mixin Integration interactions with Minecraft base classes
    MixinO --> MB
    MixinC --> MB

    %% Styling classes definitions
    classDef gradle fill:#E0E0FF,stroke:#000,stroke-width:1px;
    classDef modCore fill:#FFCC00,stroke:#000,stroke-width:1px;
    classDef event fill:#FF6666,stroke:#000,stroke-width:1px;
    classDef feature fill:#66CCFF,stroke:#000,stroke-width:1px;
    classDef commands fill:#CC99FF,stroke:#000,stroke-width:1px;
    classDef mixin fill:#66FF66,stroke:#000,stroke-width:1px;
    classDef ui fill:#FF99CC,stroke:#000,stroke-width:1px;
    classDef config fill:#99CC99,stroke:#000,stroke-width:1px;
    classDef external fill:#B3B3B3,stroke:#000,stroke-width:1px;

    %% Click Events
    click OMM "https://github.com/odtheking/odin/blob/main/src/main/kotlin/me/odinmain/OdinMain.kt"
    click ODN "https://github.com/odtheking/odin/blob/main/odin/src/main/kotlin/me/odin/ModCore.kt"
    click ODC "https://github.com/odtheking/odin/blob/main/odinclient/src/main/kotlin/me/odinclient/ModCore.kt"
    click ED "https://github.com/odtheking/odin/blob/main/src/main/kotlin/me/odinmain/events/EventDispatcher.kt"
    click FOM "https://github.com/odtheking/odin/tree/main/src/main/kotlin/me/odinmain/features"
    click FOD "https://github.com/odtheking/odin/tree/main/odin/src/main/kotlin/me/odin/features"
    click FOC "https://github.com/odtheking/odin/tree/main/odinclient/src/main/kotlin/me/odinclient/features"
    click MixinO "https://github.com/odtheking/odin/tree/main/odin/src/main/java/me/odin/mixin"
    click MixinC "https://github.com/odtheking/odin/tree/main/odinclient/src/main/java/me/odinclient/mixin"
    click UI "https://github.com/odtheking/odin/tree/main/src/main/kotlin/me/odinmain/ui"
    click CMDM "https://github.com/odtheking/odin/tree/main/src/main/kotlin/me/odinmain/commands"
    click CMDC "https://github.com/odtheking/odin/tree/main/odinclient/src/main/kotlin/me/odinclient/commands"
    click CFG "https://github.com/odtheking/odin/tree/main/src/main/kotlin/me/odinmain/config"
    click GR1 "https://github.com/odtheking/odin/blob/main/build.gradle.kts,settings.gradle.kts,gradle.properties"
    click GR2 "https://github.com/odtheking/odin/blob/main/odin/build.gradle.kts"
    click GR3 "https://github.com/odtheking/odin/blob/main/odinclient/build.gradle.kts"
```
