How mc-wiki/minecraft-mod-heywiki works
Project’s Main Type and Purpose
• Project Type: A Minecraft client mod that extends game functionality.
• Purpose: To allow players to press a key (default “H”) to retrieve wiki pages (or search results) for blocks, items, or entities they are interacting with. The mod provides several commands (like /wiki, /whatbiome, etc.), integrates with external APIs (wiki endpoints, in-game browser support with MCBrowser/MCEF), and supports configurable behaviors.
• Key Technologies: It is built using Java with Gradle, employs mixins to modify Minecraft behavior, uses Fabric and NeoForge mod loaders, and integrates with external mod APIs (Architectury API, Cloth Config, Mod Menu, etc.).
And Break Down the File Structure
• Top-Level Modules:
• common: Contains the shared business logic, core classes (HeyWikiClient, config, command handling, resource management, mixins, GUI screens, etc.)
• fabric: Fabric-specific integration and entry point (HeyWikiFabric), Fabric mixins, and gametests.
• neoforge: NeoForge-specific integration (HeyWikiNeoForge) and resources for NeoForge.
• Directory Patterns Indicating Architecture:
• Use of “src/main/java/wiki/minecraft/heywiki” across modules points to a layered design:
• Entry point and initialization classes handle startup.
• Command packages deal with user interactions via commands.
• GUI and widget packages implement in-game UI elements.
• Mixins are used to inject/modify behavior in Minecraft’s existing classes.
• Resource and extension packages support localization and API integration for external wikis.
• Presence of Gradle build scripts, GitHub workflows, and resource directories indicates a robust build, deployment, and continuous integration system.
a. Main Components:
• Minecraft Client: The platform on which the mod operates.
• Common Module:
• Core Business Logic: Contains key classes (HeyWikiClient, command classes, suggestion providers, and utilities such as HttpUtil, CachedDebouncer).
• Command Handler: Implements commands like /wiki, /imfeelinglucky, etc.
• GUI Manager: Handles custom screens, widgets, and GUI pop-ups (e.g., WikiSearchScreen, ConfirmWikiPageScreen).
• Mixins: Modify Minecraft’s existing screens and behavior to integrate mod functionality (e.g., ChatScreenMixin, GameMenuScreenMixin).
• Resource Management: Loads assets including language files and wiki family JSON configurations.
• Fabric Integration Module:
• Fabric-specific Initialization: Entry classes (HeyWikiFabric) and fabric mixins.
• Gametest: Module for verifying mod behaviors.
• Interactions with Fabric API (for mod configuration and lifecycle management).
• NeoForge Integration Module:
• NeoForge-specific Initialization: Entry classes (HeyWikiNeoForge).
• Resources required by NeoForge (pack.mcmeta, mods.toml).
• External Services/APIs:
• Minecraft Wiki and other supported wikis (via URL APIs for search and random article).
• External mod integrations: Architectury API, Cloth Config, Mod Menu, REI/JEI/EMI integration.
• (Optional) In-game browsing via MCBrowser/MCEF.
b. Relationships and Interactions:
• That the mod’s entry components (from Fabric or NeoForge modules) delegate to the common module for core functionality.
• That GUI components interact with the resource management system to load asset files (language JSON files, wiki family configurations).
• Command handler pathways: the processing of key events (e.g., H key or commands typed into chat) flows into the command subsystem which fetches wiki information and displays it via the GUI.
• How mixins modify base game screens and inject mod functionality.
c. Architectural Patterns and Design Principles:
• Modular Layering: Separation between the common (business logic) and platform-specific (integration) layers.
• Aspect-Oriented Programming: Use of mixins to inject or alter Minecraft’s original behavior.
• Dependency Injection/Delegation: Integration modules instantiate or call upon common functionality and share configuration setups.
• Resource-driven Customization: Separate resource files (assets, localization, configuration JSONs) that externalize and drive mod behavior.
d. Technologies, Frameworks, and Libraries:
• Java, Gradle, and architectural tools (Architectury API) for cross-mod loader compatibility.
• Fabric API and NeoForge APIs as the primary modding frameworks.
• Mixins for runtime bytecode manipulation.
• Cloth Config and Mod Menu for configuration management.
• External wiki APIs that support HTTP requests and response handling within classes like HttpUtil.
• Minecraft Client (base game)
• Common Module (with sub-components: Command Handler, GUI Manager, Mixins, Resource Manager)
• Fabric Module (entry point, Fabric-specific mixins, gametests)
• NeoForge Module (entry point, platform-specific resources)
• External Services (wiki APIs, configuration and dependency services)
• Core logic components (could be rectangles),
• Integration or platform-specific components (e.g., rounded rectangles),