# zugfritze/pipez architecture

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

- Interactive diagram: https://gitdiagram.com/zugfritze/pipez
- Repository: https://github.com/zugfritze/pipez

## Overview

Based on our analysis of the file tree and the README, “Pipez” is a Minecraft mod that adds configurable and performance-optimized piping for the transfer of items, fluids, energy, and gases. The project is written in Java (using Gradle for build management) and follows a fairly modular structure where each functionality is divided into its own package (such as blocks, tile entities, GUI, network communication, integration, recipes, and data modeling).

##### Project’s Main Components
- Core Mod Entry Point & Configuration – This includes Main.java, client/server configuration classes (ClientConfig.java, ServerConfig.java), and mod initialization.
- Pipe Blocks – There are multiple types: item pipes, fluid pipes, gas pipes, energy pipes, and the universal pipe. Look at the “blocks” package with various PipeBlock classes as well as shared superclasses (PipeBlock.java, UniversalPipeBlock.java).
- Tile Entities – These represent the dynamic, stateful parts of the pipes. There are corresponding tile entity classes for each pipe type (e.g., ItemPipeTileEntity, FluidPipeTileEntity, etc.) and additional logic controllers (PipeLogicTileEntity).
- GUI & Container Components – These classes (in the gui and gui.containerfactory packages) cover the interactive aspects for configuring the pipes, filters, and upgrades. They manage things like filter screens and upgrade slots.
- Networking – The “net” package contains message classes (e.g., CycleDistributionMessage, EditFilterMessage) which enable client-server communication to synchronize pipe interactions (such as switching modes and transferring data).
- Integration Layers – There is an “integration” package that provides compatibility with external mods or systems (for example, JEI, TheOneProbe, and Waila integrations).
- Data Components & Filters – These classes (under datacomponents and filter classes) manage the pipe filtering logic, including NBT matching, multiple filters, destination settings with a filter destination tool, and caching configurations.
- Assets and Data Resources – All the resources (such as block models, textures, lang files, recipes, loot tables, and tags) in the “src/main/resources” folder support the visual representation and in-game behavior.

##### Relationships and Interactions
- The core mod layer (Main.java & configuration) initializes the mod by registering components including blocks, tile entities, network handlers, and integrations.
- Pipe Blocks on placement are linked with their corresponding Tile Entities that handle dynamic states (such as extraction, transfer speeds, and filter configurations). Each pipe type’s block is paired with a tile entity for logic processing.
- The GUI system interacts with both the tile entities (to fetch and update configuration) and the network layer (sends messages such as Filter updates or extraction mode changes).
- The Network/Net package provides the bridge for changes executed on either the client or the server, using a series of messages that update tile entities and configurations.
- Integration components ensure that the mod can display relevant information via external mods (JEI, TheOneProbe, and Waila) by interfacing with the corresponding hooks provided by those mods.

##### Important Architectural Patterns and Design Principles
- Modularity and Separation of Concerns: Each area (block representation, tile entity logic, GUI management, network operations, integrations) is decoupled into its own package.
- Event-driven Communication: The mod appears to make extensive use of events (as seen in the events package), empowering reactive behavior on changes.
- Factory Patterns and Caching: Container factories (like PipeContainerFactory) are used for dynamic creation of GUI components. Caching mechanisms (e.g., DistributionCache, FilterCache) improve performance.
- Client-Server Synchronization: Emphasis is placed on client-server interactions (especially via the net package) with clear message classes for updating game state.

##### Final Recommendations
- Clearly split out both static (resources, configuration files) and dynamic (runtime tile entities, events) components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Business/Logic Layer"
        A["Mod Core & Initialization"]:::core
        B["Pipe Blocks"]:::game
        C["Tile Entities & Logic"]:::game
        D["Data Components & Filters"]:::game
        F["Networking"]:::network
    end

    subgraph "Presentation/UI Layer"
        E["GUI & Container Components"]:::gui
    end

    subgraph "Integration Layer"
        G["Integration Modules"]:::integration
    end

    subgraph "Data & Resource Layer"
        H["Assets & Data Resources"]:::resource
    end

    A -->|"registers"| B
    A -->|"registers"| C
    A -->|"initializes"| F
    A -->|"loadsIntegrations"| G
    B -->|"associatesWith"| C
    C -->|"utilizes"| D
    E -->|"sendsData"| F
    F -->|"updates"| C
    E -->|"fetchesConfig"| C
    H -.->|"providesAssetsTo"| B
    H -.->|"providesAssetsTo"| E
    H -.->|"supports"| G

    classDef core fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef gui fill:#98fb98,stroke:#000,stroke-width:1px;
    classDef game fill:#ffa07a,stroke:#000,stroke-width:1px;
    classDef network fill:#dda0dd,stroke:#000,stroke-width:1px;
    classDef integration fill:#dda0dd,stroke:#000,stroke-width:1px;
    classDef resource fill:#fdfd96,stroke:#000,stroke-width:1px,stroke-dasharray: 5,5;

    click A "https://github.com/zugfritze/pipez/blob/master/src/main/java/de/maxhenkel/pipez/Main.java"
    click A "https://github.com/zugfritze/pipez/blob/master/src/main/java/de/maxhenkel/pipez/ClientConfig.java"
    click A "https://github.com/zugfritze/pipez/blob/master/src/main/java/de/maxhenkel/pipez/ServerConfig.java"

    click B "https://github.com/zugfritze/pipez/tree/master/src/main/java/de/maxhenkel/pipez/blocks"
    
    click C "https://github.com/zugfritze/pipez/tree/master/src/main/java/de/maxhenkel/pipez/blocks/tileentity"
    
    click E "https://github.com/zugfritze/pipez/tree/master/src/main/java/de/maxhenkel/pipez/gui"
    click E "https://github.com/zugfritze/pipez/tree/master/src/main/java/de/maxhenkel/pipez/gui/containerfactory"
    
    click F "https://github.com/zugfritze/pipez/tree/master/src/main/java/de/maxhenkel/pipez/net"
    
    click G "https://github.com/zugfritze/pipez/tree/master/src/main/java/de/maxhenkel/pipez/integration"
    
    click D "https://github.com/zugfritze/pipez/tree/master/src/main/java/de/maxhenkel/pipez/datacomponents"
    
    click H "https://github.com/zugfritze/pipez/tree/master/src/main/resources/assets/pipez"
    click H "https://github.com/zugfritze/pipez/tree/master/src/main/resources/data/pipez"
```
