# k-4u/hydraulicraft architecture

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

- Interactive diagram: https://gitdiagram.com/k-4u/hydraulicraft
- Repository: https://github.com/k-4u/hydraulicraft

## Overview

##### Project Type and Purpose
- Project Type: A Minecraft mod (a game modding project) that focuses on fluids and hydraulics.
- Purpose: Introduce hydraulic systems into Minecraft, providing fluid mechanics, recipe registration, block and tile entity management, network communications, and integration with third-party mods.

##### Main Architectural Components
- API Layer:
– Contains the “api” folder with interfaces and classes (e.g., CoFHAPIProps, EnergyStorage, FluidShapedOreRecipe, etc.). This layer defines how external mods or systems interface with Hydraulicraft’s functionality.
– Recipe registration via HCApi (and methods like getRecipeHandler()).
- Core Mod Logic:
– Located in the “java/k4unl/minecraft/Hydraulicraft” package, which contains the main mod classes (Hydraulicraft.java, HydraulicraftAPI.java) along with business logic for blocks, items, fluids, tile entities, and event handling.
- Block and Tile Entity Management:
– Blocks: A large number of block classes represent different machines (assemblers, crushers, pumps, etc.) and their associated behaviors.
– Tile Entities: Organized under tileEntities for consumers, generators, and more.
- Client/Rendering and Proxy:
– Client-side folders such as “client”, “client/GUI”, “client/renderers” that handle rendering, model management, and GUI components.
– Proxy classes (ClientProxy and CommonProxy) manage side-specific logic for the mod.
- Networking and Event Handling:
– Network communication (under “network” and “network/packets”) facilitates data exchange between client and server.
– The “events” package handles user input, tick events, and other game events.
- Third-Party Integrations:
– A dedicated “thirdParty” folder includes integrations (for BuildCraft, IndustrialCraft, JEI, NEI, RF, etc.) which show how Hydraulicraft interacts with other mods.
- Build and Deployment:
– Gradle build scripts and wrapper directories are included for project automation.
- Assets and Resources:
– The “resources” directory holds all game assets (textures, models, blockstate configurations, language files and wiki texts) essential for in-game rendering and localization.

##### Establish Relationships and Data Flow
- API calls from user mods or internal components trigger the core mod logic (recipe registration, block instantiation, etc.) via HCApi.
- The core mod then updates game state by instantiating blocks, tile entities, and items, driving both server- and client-side processes.
- Client components subscribe to events via the Event system and update GUIs accordingly.
- Network components handle communication between the client and server, ensuring consistency in hydraulic operations.
- Third-party integration modules listen for or provide specific hooks to allow smooth interoperability with external mods.

##### Architectural Patterns and Design Principles
- Modular Design: Separation of the API, core logic, client-side, server-side, and third-party integrations.
- Proxy Pattern: Clear separation between client (rendering) and common (server) behavior.
- Event-Driven Mechanism: Use of event handlers and network packets for real-time communication.
- Use of Interfaces and Abstract Classes: For flexibility in crafting recipes, handling energy and fluid operations, and implementing third-party integration points.

##### Additional Notes
- Be detailed: Include as many components as possible, especially subdividing key parts like blocks, recipe handling, and network communication.
- Also, capture the integration points for third-party mod support and external APIs.

## Diagram (Mermaid)

```mermaid
graph TD
    %% API Layer
    subgraph "API Layer"
        API["API Module"]:::api
    end

    %% Core Engine
    subgraph "Core Engine"
        Core["Core Mod Engine"]:::core
        Proxy["Proxy Classes"]:::proxy
    end

    %% Blocks & Tile Entities
    subgraph "Blocks & Tile Entities"
        Blocks["Blocks"]:::blocks
        Tiles["Tile Entities"]:::tiles
    end

    %% Client-Side / Rendering
    subgraph "Client Layer"
        Client["Client Base"]:::client
        GUI["Client GUI"]:::gui
        Renderers["Client Renderers"]:::renderers
    end

    %% Networking & Event Handling
    subgraph "Networking & Events"
        Network["Network"]:::network
        Events["Events"]:::events
    end

    %% Third-Party Integrations
    subgraph "Third-Party Integrations"
        ThirdParty["Third-Party Integrations"]:::thirdparty
    end

    %% Build and Deployment
    subgraph "Build System"
        Build["Build System"]:::build
    end

    %% Assets and Resources
    subgraph "Assets"
        Assets["Assets & Resources"]:::assets
    end

    %% Relationships
    API -->|"calls"| Core
    Core -->|"instantiates"| Blocks
    Core -->|"instantiates"| Tiles
    Core -->|"sendsPackets"| Network
    Network -->|"triggers"| Events
    Events -->|"updates"| Client
    Core -->|"usesProxy"| Proxy
    Proxy -->|"handlesLogic"| Client
    Client -->|"rendersGUI"| GUI
    Client -->|"rendersModels"| Renderers
    Core -->|"integratesWith"| ThirdParty
    Build -->|"builds"| Core
    Assets -->|"supplies"| Core
    Assets -->|"supplies"| Client

    %% Click Events
    click API "https://github.com/k-4u/hydraulicraft/tree/1.9/api"
    click Core "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft"
    click Blocks "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/blocks"
    click Tiles "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/tileEntities"
    click Client "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/client"
    click GUI "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/client/GUI"
    click Renderers "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/client/renderers"
    click Network "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/network"
    click Events "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/events"
    click Proxy "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/proxy"
    click ThirdParty "https://github.com/k-4u/hydraulicraft/tree/1.9/java/k4unl/minecraft/Hydraulicraft/thirdParty"
    click Build "https://github.com/k-4u/hydraulicraft/blob/1.9/build.gradle"
    click Assets "https://github.com/k-4u/hydraulicraft/tree/1.9/resources"

    %% Styles
    classDef api fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef blocks fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef tiles fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef client fill:#FFB6C1,stroke:#8B0000,stroke-width:2px;
    classDef gui fill:#FFA07A,stroke:#CD5C5C,stroke-width:2px;
    classDef renderers fill:#FF69B4,stroke:#B22222,stroke-width:2px;
    classDef network fill:#E6E6FA,stroke:#4B0082,stroke-width:2px;
    classDef events fill:#F0E68C,stroke:#BDB76B,stroke-width:2px;
    classDef thirdparty fill:#DDA0DD,stroke:#800080,stroke-width:2px;
    classDef build fill:#F5DEB3,stroke:#A0522D,stroke-width:2px;
    classDef assets fill:#98FB98,stroke:#2E8B57,stroke-width:2px;
    classDef proxy fill:#FFC0CB,stroke:#FF69B4,stroke-width:2px;
```
