# lythom/capsule architecture

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

- Interactive diagram: https://gitdiagram.com/lythom/capsule
- Repository: https://github.com/lythom/capsule

## Overview

##### Main Components

a. Core Module (Central)
- CapsuleMod.java (Main entry point)
- Config.java (Configuration management)
- CapsuleSavedData.java (World data persistence)
- StructureSaver.java (Structure handling)

b. Item System (Right)
- Items package
- CapsuleItem.java (Main capsule functionality)
- CapsuleItems.java (Item registration)
- Enchantments package
- RecallEnchant.java

c. Block System (Left)
- Blocks package
- BlockCapsuleMarker.java
- TileEntityCapture.java
- CaptureTESR.java (Rendering)

d. Network Layer (Bottom)
- Network package
- CapsuleNetwork.java (Network handler)
- Various message handlers for client-server communication

e. Client-Side Systems (Top)
- Client package
- CapsulePreviewHandler.java
- RendererUtils.java

##### Supporting Systems (Around the edges)

f. Recipe System
- Recipes package
- Various recipe handlers for crafting

g. Loot System
- Loot package
- CapsuleLootEntry.java
- StarterLoot.java

h. Plugin Integration
- Plugins package
- JEI integration
- SecurityCraft integration

- Bidirectional communication between Network Layer and Client/Server components
- Data flow from Recipe System to Item System
- Structure saving/loading flow between StructureSaver and file system

##### External Interactions

- Minecraft Forge integration points
- File system interaction for structure storage
- Integration points with other mods (JEI, SecurityCraft)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        CapsuleMod["CapsuleMod (Main Entry)"]:::core
        Config["Configuration"]:::core
        CapsuleSavedData["World Data Persistence"]:::core
        StructureSaver["Structure Saver"]:::core
    end

    subgraph "Item System"
        CapsuleItem["Capsule Item"]:::item
        CapsuleItems["Item Registry"]:::item
        RecallEnchant["Recall Enchantment"]:::item
    end

    subgraph "Block System"
        BlockCapsuleMarker["Capsule Marker"]:::block
        TileEntityCapture["Capture Tile Entity"]:::block
        CaptureTESR["Block Renderer"]:::block
    end

    subgraph "Client Layer"
        CapsulePreviewHandler["Preview Handler"]:::client
        RendererUtils["Renderer Utilities"]:::client
    end

    subgraph "Network Layer"
        CapsuleNetwork["Network Handler"]:::network
        MessageHandlers["Message Handlers"]:::network
    end

    subgraph "Supporting Systems"
        RecipeSystem["Recipe System"]:::support
        LootSystem["Loot System"]:::support
        TemplateManager["Template Manager"]:::support
    end

    subgraph "Plugin Integration"
        JEIPlugin["JEI Plugin"]:::plugin
        SecurityCraftPlugin["SecurityCraft Integration"]:::plugin
    end

    %% Core Connections
    CapsuleMod --> Config
    CapsuleMod --> CapsuleSavedData
    CapsuleMod --> StructureSaver
    CapsuleMod --> CapsuleNetwork

    %% Item System Connections
    CapsuleMod --> CapsuleItems
    CapsuleItems --> CapsuleItem
    CapsuleItem --> RecallEnchant

    %% Block System Connections
    BlockCapsuleMarker --> TileEntityCapture
    TileEntityCapture --> CaptureTESR

    %% Network Connections
    CapsuleNetwork --> MessageHandlers
    CapsuleNetwork --> CapsulePreviewHandler

    %% Client Layer Connections
    CapsulePreviewHandler --> RendererUtils
    CaptureTESR --> RendererUtils

    %% Supporting Systems Connections
    StructureSaver --> TemplateManager
    CapsuleItem --> TemplateManager
    CapsuleItem --> RecipeSystem
    CapsuleItem --> LootSystem

    %% Plugin Connections
    CapsuleItem --> JEIPlugin
    CapsuleItem --> SecurityCraftPlugin

    %% Click Events
    click CapsuleMod "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/CapsuleMod.java"
    click Config "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/Config.java"
    click CapsuleSavedData "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/CapsuleSavedData.java"
    click StructureSaver "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/StructureSaver.java"
    click CapsuleItem "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/items/CapsuleItem.java"
    click CapsuleItems "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/items/CapsuleItems.java"
    click RecallEnchant "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/enchantments/RecallEnchant.java"
    click BlockCapsuleMarker "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/blocks/BlockCapsuleMarker.java"
    click TileEntityCapture "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/blocks/TileEntityCapture.java"
    click CaptureTESR "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/blocks/CaptureTESR.java"
    click CapsuleNetwork "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/network/CapsuleNetwork.java"
    click MessageHandlers "https://github.com/Lythom/capsule/tree/master/src/main/java/capsule/network/"
    click CapsulePreviewHandler "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/client/CapsulePreviewHandler.java"
    click RendererUtils "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/client/RendererUtils.java"
    click RecipeSystem "https://github.com/Lythom/capsule/tree/master/src/main/java/capsule/recipes/"
    click JEIPlugin "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/plugins/jei/CapsulePlugin.java"
    click SecurityCraftPlugin "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/plugins/securitycraft/SecurityCraftOwnerCheck.java"
    click TemplateManager "https://github.com/Lythom/capsule/blob/master/src/main/java/capsule/structure/CapsuleTemplateManager.java"

    %% Styles
    classDef core fill:#a2d2ff,stroke:#333,stroke-width:2px
    classDef item fill:#bde0fe,stroke:#333,stroke-width:2px
    classDef block fill:#ffafcc,stroke:#333,stroke-width:2px
    classDef client fill:#cdb4db,stroke:#333,stroke-width:2px
    classDef network fill:#ffc8dd,stroke:#333,stroke-width:2px
    classDef support fill:#fff1e6,stroke:#333,stroke-width:2px
    classDef plugin fill:#ddd,stroke:#333,stroke-width:2px
```
