# timas130/playerlocatorplus architecture

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

- Interactive diagram: https://gitdiagram.com/timas130/playerlocatorplus
- Repository: https://github.com/timas130/playerlocatorplus

## Overview

##### Project type and purpose
- Player Locator Plus is a Minecraft Fabric mod (full-stack in the sense of client–server plugin).
- Purpose: track other players’ positions on the in-game experience bar, with client and server logic, configurable behavior, and mixin-based injection into Minecraft.

##### File structure
- Top-level files: build.gradle, settings.gradle, gradlew – standard Gradle build.
- src/client: client-only code (Java/Kotlin) + resource folder for client mixins JSON.
- src/main: shared/server code (Java/Kotlin) + resource folder containing mod metadata (fabric.mod.json), mixins.json, assets, data tags.
- Key packages:
- sh.sit.plp.config – loads/saves TOML config and handles client/server parameters.
- sh.sit.plp.network – defines S2C payload classes (ModConfigS2CPayload, PlayerLocationsS2CPayload).
- sh.sit.plp.mixin – Mixin classes injecting into Minecraft networking, command trees, HUD rendering.
- sh.sit.plp (root) – entrypoint classes (ModInitializers), BarUpdater, HUD logic, command registration.
- Resources: textures, lang files, mixin JSON, tag JSON for hiding equipment.

##### README
- Confirms Fabric API, Cloth Config, Kotlin usage.
- Describes server-side vs client-side config parameters and how server can push config to clients.
- Mentions networking of direction/distance data.

##### Main components
a. Minecraft Engine (Client & Server)
- Fabric Loader & Fabric API
- Game loop & rendering pipeline
b. Player Locator Plus Mod
- Server module (ModInitializer, network, config manager)
- Client module (ModMenu entrypoint, HUD rendering, BarUpdater, config manager)
c. Network Channel
- SimpleChannel instance for S2C messages (ModConfig, PlayerLocations)
d. Configuration subsystem
- File I/O (player-locator-plus.toml)
- Cloth Config UI (client)
- Server override logic
e. Mixin subsystem
- injection into CommandTreeS2CPacket, ArgumentTypes, InGameHud, AutoconfigGuiRegistryAccess
f. Resources
- Texture assets, lang assets, data tags (hiding_equipment.json)

##### Relationships & interactions
- On server tick → Server ModInitializer registers a scheduled task:
- Gathers player positions → constructs PlayerLocationsS2CPayload → sends via SimpleChannel to all clients.
- On client startup:
- Client ModInitializer registers network handlers (ModConfigS2CPayload, PlayerLocationsS2CPayload).
- Loads local TOML config → if acceptServerConfig and server sends config, client config manager merges in.
- BarUpdater listens on client tick/render events to update experience bar.
- Mixin layers:
- AutoconfigGuiRegistryAccessMixin: add mod config screen entry in Mod Menu.
- Config UI (Cloth Config) ↔ ConfigManagerClient.
- Resource assets ←→ HUD renderer (textures & language data).

##### Architectural patterns & design principles
- Event-driven (server tick, client tick, network message callbacks).
- Mixin injection for cross-cutting concerns (no direct edits to MC).
- Separation of concerns: config, network, rendering, utility modules.
- Data packets (DTOs) for network communication.
- Resource-driven: JSON/TOML/asset pipelines.

##### Relevant technologies & frameworks
- Gradle build system
- Fabric Loader / Fabric API
- Fabric Language Kotlin
- Cloth Config API
- SpongePowered Mixin
- TOML config via KTomlConfigSerializer
- Minecraft’s rendering & networking internals

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    subgraph "External Dependencies"
        MC["Minecraft Engine"]:::external
        FL["Fabric Loader/API"]:::external
        SP["SpongePowered Mixin"]:::external
        GC["Cloth Config API"]:::external
        GR["Gradle"]:::external
    end

    %% Shared Components
    subgraph "Shared"
        SC1["ModConfigS2CPayload"]:::network
        SC2["PlayerLocationsS2CPayload"]:::network
        SC3["RelativePlayerLocation"]:::network
        SCN["SimpleChannel"]:::network
        MXJSON["player-locator-plus.mixins.json"]:::infra
    end

    %% Server Side
    subgraph "Server Side"
        SV1["PlayerLocatorPlus (ModInitializer)"]:::core
        SV2["ConfigManager"]:::core
        SV3["ModConfig"]:::core
        SV4["KTomlConfigSerializer"]:::infra
        PT["Player Position Tracker"]:::core
    end

    %% Client Side
    subgraph "Client Side"
        CL1["ModMenuEntrypoint"]:::infra
        CL2["PlayerLocatorPlusClient (ModInitializer)"]:::core
        CL3["ConfigManagerClient"]:::core
        CL4["BarUpdater"]:::core
        CL5["InGameHudMixin"]:::infra
        CL6["AutoconfigGuiRegistryAccessMixin"]:::infra
    end

    %% Utilities
    subgraph "Utilities"
        U1["ColorUtils"]:::core
        U2["Animatable"]:::core
        U3["MathUtils"]:::core
    end

    %% Resources
    subgraph "Resources"
        R1["Textures & GUI Sprites"]:::external
        R2["Language Files"]:::external
        R3["Data Tags"]:::external
        R4["fabric.mod.json"]:::external
        R5["player-locator-plus.client.mixins.json"]:::infra
    end

    %% Connections
    GR -->|builds| SV1
    FL -->|loads mods| SV1
    SP -->|applies mixins| MXJSON
    SP -->|applies mixins| R5

    SV1 -->|"initializes config"| SV2
    SV2 -->|"loads/saves TOML"| SV3
    SV2 -->|"uses serializer"| SV4
    SV1 -->|"registers tick handler"| PT
    PT -->|"gather player data"| SC2
    SC2 -->|"encapsulated by"| SCN
    SCN -->|"sends to clients"| CL2

    CL2 -->|"registers handler for"| SC1
    CL2 -->|"registers handler for"| SC2
    SC1 -->|"update client config"| CL3
    SC2 -->|"update player data"| CL4

    CL1 -->|"integrates Cloth Config UI"| CL6
    CL6 -->|"injects UI entry"| GC
    CL3 -->|"writes to"| R4
    CL4 -->|"renders using textures"| R1
    CL4 -->|"renders text"| R2
    CL4 -->|"uses HUD mixin"| CL5

    U1 --> SV1
    U1 --> CL4
    U2 --> CL4
    U3 --> CL4

    %% Click Events
    click SV1 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/PlayerLocatorPlus.kt"
    click SV2 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/config/ConfigManager.kt"
    click SV3 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/config/ModConfig.kt"
    click SV4 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/config/KTomlConfigSerializer.kt"
    click SC1 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/network/ModConfigS2CPayload.kt"
    click SC2 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/network/PlayerLocationsS2CPayload.kt"
    click SC3 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/network/RelativePlayerLocation.kt"
    click MXJSON "https://github.com/timas130/playerlocatorplus/blob/main/src/main/resources/player-locator-plus.mixins.json"
    click CL1 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/kotlin/sh/sit/plp/ModMenuEntrypoint.kt"
    click CL2 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/kotlin/sh/sit/plp/PlayerLocatorPlusClient.kt"
    click CL3 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/kotlin/sh/sit/plp/config/ConfigManagerClient.kt"
    click R5 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/resources/player-locator-plus.client.mixins.json"
    click CL5 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/java/sh/sit/plp/mixin/InGameHudMixin.java"
    click CL6 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/java/sh/sit/plp/mixin/AutoconfigGuiRegistryAccessMixin.java"
    click U1 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/kotlin/sh/sit/plp/util/ColorUtils.kt"
    click U2 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/kotlin/sh/sit/plp/util/Animatable.kt"
    click U3 "https://github.com/timas130/playerlocatorplus/blob/main/src/client/kotlin/sh/sit/plp/util/MathUtils.kt"
    click R1 "https://github.com/timas130/playerlocatorplus/tree/main/src/main/resources/assets/player-locator-plus/textures/gui/sprites/hud"
    click R2 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/resources/assets/player-locator-plus/lang/en_us.json"
    click R3 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/resources/data/player-locator-plus/tags/item/hiding_equipment.json"
    click R4 "https://github.com/timas130/playerlocatorplus/blob/main/src/main/resources/fabric.mod.json"

    %% Styles
    classDef core fill:#a8e6a2,stroke:#333,stroke-width:1px
    classDef infra fill:#a2d7e6,stroke:#333,stroke-width:1px
    classDef network fill:#f4b942,stroke:#333,stroke-width:1px
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
```
