# guiymour/mindustry-extra-utilities-mod architecture

> Architecture diagram of the GitHub repository guiymour/mindustry-extra-utilities-mod, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/guiymour/mindustry-extra-utilities-mod
- Repository: https://github.com/guiymour/mindustry-extra-utilities-mod

## Overview

##### Main Components
- Assets: This folder holds all the non-code content such as bundles (language/localization), maps (with .msav format), scripts (organized by category like blocks, effects, power, production, turrets, etc.), shaders, and sprites. This represents the game’s resource layer and visual content.
- Source Code: Under the “src/ExtraUtilities” directory, the Java source files are organized by functionality. Notable sub-packages include:
– ai: Contains artificial intelligence logic (e.g., DefenderHealAI, MinerPointAI)
– content: Defines game elements (blocks, items, sounds, tech trees, status effects, etc.)
– graphics: Contains renderers and shader management
– input: Handles user interaction
– net: Manages network packets and synchronization for multiplayer
– ui: User interface components for displaying custom lists, images, and mod-specific menus
– worlds: Contains further subdivision into blocks (by function: distribution, effect, heat, power, production, turret, unit, etc.), consumers, drawers (for drawing world elements), and entity related classes (abilities, bullets, units, weapons, animations, etc.)
- Build and Configuration: Files like build.gradle, gradle.properties, and the Gradle wrapper indicate the build system in use. The mod configuration file (mod.hjson) and GitHub workflows (.github/workflows) support development practices and CI/CD.

##### Relationships and Interactions
- Core Mod Integration: At the heart, the ExtraUtilitiesMod.java likely acts as the entry point. It integrates with Mindustry’s mod loading system.
- Game Engine Integration: The mod interacts with the Mindustry game engine by adding new game objects (units, blocks, turrets, etc.) that are defined in both the Java code and referenced in the assets (sprites, maps, scripts).
- Internal Modules: Inside the mod code, there are clear separation and interactions between modules:
- AI and Unit Behavior: “ai” and “worlds/entity/unit/” manage game unit logic.
- Game Content Definition: “content” combines definitions for blocks, items, bullets, and routes new functionality (like turrets & power production).
- World and Graphics Handling: Modules under “worlds/drawer”, “graphics”, and “worlds/entity” coordinate to render effects and implement animations.
- Network Sync: The “net” package oversees any packets (e.g., CtrlMissileSyncPacket) to keep data in sync during multiplayer sessions.
- Assets and Configuration Linkage: The assets folder provides the static resources that are pulled into the game mod to visually represent or script behaviors (for example, the various scripts in assets/scripts that correlate to functionalities implemented in Java under “worlds/blocks” or “worlds/entity”).

##### Architectural Patterns and Design Principles
- Modular Organization: The project is organized by functionality (AI, content, net, UI, worlds, etc.), suggesting a modular structure with clear separation of concerns.
- Resource Separation: All assets (graphics, maps, scripts, translations) are kept separate from the source code. This separation makes it easier to update or replace visual game elements independently of game logic.
- Extendability: The code is designed to extend the original game’s capabilities, as evinced by packages for abilities, turrets, and extra units. The design supports adding new game elements without major rework.

##### Relevant Technologies and Tools
- Java: Main development language used in the “src” directory for mod development.
- Gradle: The build automation is managed via Gradle (as evidenced by build.gradle and gradle wrapper files).
- GitHub CI: There is a workflow setup in the .github/workflows directory for automating builds or tests.
- Mindustry API: The mod integrates with the Mindustry game engine through defined APIs (hooks for blocks, units, etc.).

##### Final Recommendations
- You capture each crucial component by creating separate nodes for:
- The Game Engine (Mindustry)
- The Mod Core and Initialization (ExtraUtilitiesMod)
- Source Code Modules: AI, Content, Graphics, Input, Network, UI, Worlds (further subdivided into blocks, entities, drawers, etc.)
- Assets: Bundles, Maps, Scripts, Shaders, Sprites
- Build and Configuration components (Gradle, GitHub workflows, mod.hjson)
- Detail interactions, such as how user inputs are handled in “input” and “ui”, how game events use the network modules for multiplayer, and how the graphics renderer pulls shaders and sprite data from assets.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External System
    MGE["Mindustry Game Engine"]:::external

    %% Mod Core
    ECU["ExtraUtilitiesMod (Mod Core)"]:::core

    %% Assets Layer
    AST["Assets (Bundles,Maps,Scripts,Shaders,Sprites)"]:::assets

    %% Java Source Code Modules
    subgraph "Java Source Code Modules"
        AI["AI Module (Unit Behaviors)"]:::java
        Cont["Content Module (Game Elements)"]:::java
        GW["Worlds Module (Blocks,Entities,Effects)"]:::java
        GR["Graphics Module (Renderers,Shaders)"]:::java
        UI["UI Module (Menus,Interfaces)"]:::java
        IN["Input Module (User Interaction)"]:::java
        NET["Network Module (Sync,Packets)"]:::java
    end

    %% Build and Configuration
    BC["Build & Config (Gradle,mod.hjson,Workflows)"]:::build

    %% Connections and Data Flow
    MGE -->|"integrates_with"| ECU
    ECU -->|"loads"| AST
    ECU -->|"initializes"| AI
    ECU -->|"initializes"| Cont
    ECU -->|"initializes"| GW
    ECU -->|"initializes"| GR
    ECU -->|"initializes"| UI
    ECU -->|"initializes"| IN
    ECU -->|"initializes"| NET
    IN -->|"sendsInput"| UI
    UI -->|"triggers"| NET
    GR -->|"renders"| GW
    NET -->|"syncs_with"| MGE
    ECU -->|"uses"| BC

    %% Click Event Mappings
    click AST "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//assets"
    click ECU "https://github.com/guiymour/mindustry-extra-utilities-mod/blob/main//src/ExtraUtilities/ExtraUtilitiesMod.java"
    click AI "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//src/ExtraUtilities/ai"
    click Cont "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//src/ExtraUtilities/content"
    click GR "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//src/ExtraUtilities/graphics"
    click IN "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//src/ExtraUtilities/input"
    click NET "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//src/ExtraUtilities/net"
    click UI "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//src/ExtraUtilities/ui"
    click GW "https://github.com/guiymour/mindustry-extra-utilities-mod/tree/main//src/ExtraUtilities/worlds"
    click BC "https://github.com/guiymour/mindustry-extra-utilities-mod/blob/main//build.gradle"

    %% Styles
    classDef external fill:#f9c,stroke:#333,stroke-width:2px;
    classDef core fill:#ff9,stroke:#333,stroke-width:2px;
    classDef assets fill:#ccf,stroke:#333,stroke-width:2px;
    classDef java fill:#cfc,stroke:#333,stroke-width:2px;
    classDef build fill:#fc9,stroke:#333,stroke-width:2px;
```
