# reider745/zotecoreloader architecture

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

- Interactive diagram: https://gitdiagram.com/reider745/zotecoreloader
- Repository: https://github.com/reider745/zotecoreloader

## Overview

##### Major architectural domains
- Server Core / Kernel: The main entry point (e.g. the “Main.java” and other key classes in com/reider745) that boots the server, handles bootstrapping and configuration (including reading server.properties and zotecore.yml).
- Mod Loader & Hooks: There is extensive code for hooking into game behavior, instrumenting classes, and processing mods (see com/reider745/api/hooks, modloader directories under com/zhekasmirnov/apparatus and innercore/mod). This component handles loading modpacks, scanning mod directories, and processing custom behavior.
- Network & Protocol Handling: Components in com/reider745/network, as well as Inner Core network adapters and socket handling (reference to socket-server settings and classes like ClientOnly) manage client connections, protocol version checks, and packet processing.
- Game Logic & World Management: Directories such as com/reider745/behavior, block, world, and entity show that in-game object management and environment processing (including dimensions and spawn rules) are key subsystems.
- Scripting and Data-driven Layers: The presence of coreengine scripts, JSON recipe files and config directories in src/main/resources (e.g. innercore/coreengine, innercore/assets) indicates an interpreted/scripting component that allows dynamic modification of gameplay (such as custom recipes and translations).
- Build & Dependency Infrastructure: The Gradle build files, Gradle wrapper and the “iclibs” directory for external libraries (including Nukkit-MOT jar) represent the underlying dependency and build mechanism.

##### How the components interact
- The Server Core initializes the system by loading configuration settings from files (zotecore.yml, server.properties). It then instantiates key subsystems (network, mod loader, game world) in an ordered bootstrapping process.
- The Mod Loader uses hook APIs (in com/reider745/api/hooks) to inject behavior into game engine classes. It works closely with the core engine (Inner Core and apparatus modules) to register mods, custom items, and block behaviors.
- The Network Layer accepts client connections, processes packets, and interacts with modules that send diagnostic or administrative commands (commands like ‘custom_items’, ‘tps’, etc.).
- The Game Logic layer continuously processes world ticks, dimension changes, and entity interactions. It also oversees mod behavior by coordinating with the hook systems.
- Scripting and data-driven assets (recipes, translations, textures) are loaded at startup and are referenced by the game logic and UI modules, ensuring that modpacks and themes can be updated independently.

##### Architectural patterns and design principles used
- Modularity: Code is separated into numerous packages (e.g. behavior, network, hooks, modloader) that isolate concerns.
- Hook/Instrumentation Pattern: The extensive “hooks” and “instrument” packages indicate runtime code modification, supporting dynamic extension or override of native methods.
- Data-Driven Design: Usage of JSON recipe files, configuration YAML files, and external asset packs shows a strong reliance on data driven configuration.
- Dependency Injection/Loose Coupling: The core uses APIs and reflective method calls (see various “Helper,” “Manager,” and “Controller” classes) so that mods can interact safely with the engine.

##### Final checklist
– Include labels for each package and component (e.g., com/reider745 for core, com/zhekasmirnov for engine libraries).
– Add annotations to highlight important design decisions, like the hook/instrumentation pattern and the use of a data-driven mod loading approach.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core & Bootstrapping
    subgraph "Core & Bootstrapping"
        A["Server Core / Kernel"]:::core
        B["Configuration Files"]:::core
    end
    A -->|"loads"| B

    %% Mod Loader & Hooks
    subgraph "Mod Loader & Hooks"
        M1["Hook APIs"]:::modloader
        M2["Mod Loader Implementation"]:::modloader
    end
    A -->|"initiates"| M1
    A -->|"initiates"| M2
    M1 -->|"injects"| G1

    %% Network & Protocol Handling
    subgraph "Network & Protocol Handling"
        N1["Network Components"]:::network
        N2["Socket/Protocol Handling"]:::network
    end
    A -->|"starts"| N1
    A -->|"starts"| N2

    %% Game Logic & World Management
    subgraph "Game Logic & World Management"
        G1["Behavior & Items"]:::gamelogic
        G2["World Management"]:::gamelogic
        G3["Entity Manager"]:::gamelogic
    end
    A -->|"boots"| G1
    A -->|"boots"| G2
    A -->|"boots"| G3
    N1 <-->|"realTime"| G2

    %% Scripting & Data Assets
    subgraph "Scripting & Data Assets"
        S1["Core Engine Scripts"]:::scripting
        S2["Assets & Config Data"]:::scripting
    end
    S2 -->|"feeds"| M2
    S2 -->|"supports"| G1

    %% Build & Dependency Infrastructure
    subgraph "Build & Dependency Infrastructure"
        B1["Gradle Build System"]:::build
        B2["External Libraries"]:::build
    end
    B1 -->|"builds"| A
    B2 -->|"supplies"| A

    %% Click Events
    click A "https://github.com/reider745/zotecoreloader/blob/NukkitMot/src/main/java/com/reider745/Main.java"
    click A "https://github.com/reider745/zotecoreloader/blob/NukkitMot/src/main/java/com/reider745/InnerCoreServer.java"
    click B "https://github.com/reider745/zotecoreloader/blob/NukkitMot/src/main/resources/zotecore.yml"
    click M1 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/java/com/reider745/api/hooks/"
    click M2 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/java/com/zhekasmirnov/apparatus/modloader/"
    click N1 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/java/com/reider745/network/"
    click N2 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/java/com/reider745/network/innercore/"
    click G1 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/java/com/reider745/behavior/"
    click G2 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/java/com/reider745/world/"
    click G3 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/java/com/reider745/entity/"
    click S1 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/resources/innercore/coreengine/"
    click S2 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/src/main/resources/innercore/assets/"
    click B1 "https://github.com/reider745/zotecoreloader/blob/NukkitMot/build.gradle"
    click B2 "https://github.com/reider745/zotecoreloader/tree/NukkitMot/iclibs/"

    %% Class Definitions for Color Coding
    classDef core fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef modloader fill:#ADFF2F,stroke:#333,stroke-width:2px;
    classDef network fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef gamelogic fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef scripting fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef build fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
