How thedarkcolour/kotlinforforge works
Main Components
• Modules for each function:
• kfflang (Kotlin Language Loader): Provides support classes (such as KotlinLanguageProvider, KotlinModContainer, KotlinModLoadingContext) and integration with Forge’s mod loading system.
• kfflib (Kotlin Library): Contains utility functions and integration utilities like event bus helpers, vector math utilities, logging, and deferred registration.
• kffmod (Kotlin Mod API): Acts as the bridge between your custom mod code and the Forge mod loader.
• Variants by Loader:
• The “forge” directory houses the standard Forge implementation.
• The “neoforge” directory houses the variant for NeoForge.
• Additional Combined/Integrated projects: The “combined” folder (and its own sub-modules) shows how one might merge modules for unified distribution.
Relationships & Interactions
• The build system (Gradle) orchestrates the multi-module structure.
• kfflang uses or exposes capabilities that allow object declarations to be recognized as mods/events by interacting with the underlying Forge API.
• kfflib provides utility functions (e.g., vector utilities, deferred register helpers) that are needed by kfflang and kffmod.
• kffmod leverages both kfflang and kfflib to simplify the mod development process.
• External Interaction: The system integrates with external dependencies such as the Kotlin standard library, Kotlin reflection, JSON serialization libraries, and the Minecraft Forge API.
• There is a clear separation between the code for different mod loader variants (Forge vs. NeoForge). Each variant’s directory contains parallel structures (kfflang, kfflib, kffmod) with subtle differences regarding how the integration with the specific mod loader is performed.
Important Architectural Patterns and Design Principles
• Modular Architecture: The project is broken into independent but interrelated submodules. This allows for individual modules (language support, utility functions, mod API) to be updated or extended independently.
• Abstraction & Separation of Concerns: Each module has a single focus – language loading, supporting utilities, or mod integration. This is reinforced in the README by how integration instructions are separated into distinct Gradle dependencies based on mod loader variants.
• Extensibility: The library is designed to be merged into existing projects. The modularized approach makes it easier for developers to integrate only the parts they need.
Relevant Technologies & Frameworks
• Gradle (build system) – as seen with numerous build.gradle.kts files.
• Kotlin (the primary language), including its standard library, reflection, coroutine, and serialization features.
• Minecraft Forge API – for mod loading.
• Optional components for NeoForge integration.
• A “Gradle Build System” block that connects to all modules indicating build dependency and organization.
• kfflang provides language extension support to kffmod.
• kfflib supports both kfflang and kffmod with utility functions.
• Including a side-by-side comparison showing how the “forge” and “neoforge” directories mirror one another yet target different mod loading interfaces.
Final Touches
• Do not over-simplify by just lumping modules together; even small submodules (such as “Forging utilities” in kfflib) can be grouped under their parent module.
– The Gradle build system orchestrating the project.
– External blocks for Kotlin and Forge APIs.