How festivaldev/webstone works
Main Components
• Mod Loader / Minecraft Environment:
– Represent the overall Minecraft client/server environment where the Forge mod is installed.
– Show Forge as the mod loader that integrates this mod into Minecraft.
• Webstone Core Module:
– This includes the main package “tf.festival.webstone” and its subcomponents.
– Components include block and entity registration (WebstoneBlocks, WebstoneBlockEntities, WebstoneItems, and the Registry class), configuration (WebstoneConfig), and command handling (WebstoneCommand).
• WebSocket Server:
– Represent the dedicated WebSocket server module (classes like WebstoneSocketServer and WebstoneSocketServerMessages) which listens on port 4321.
– This component manages connections to external WebSocket clients (e.g., a remote web UI).
• Data & Business Logic:
– Include the data model layer represented by classes in the “data” package (WebstoneBlock, WebstoneBlockGroup) and the “block” and “blockentity” packages (WebstoneRemoteBlock and WebstoneRemoteBlockEntity).
– This layer handles game-specific logic and the state representation of remote controllable blocks.
• External Client/Web UI:
– Represent remote control clients (like the one hosted at http://webstone.festival.tf or the one available in the GitHub webui repo) which connect via WebSocket.
• Configuration and Security:
– Include the configuration file structure (described in README and located in a specific mod configuration folder) and the security options (passphrase and TLS configuration) that influence how the WebSocket server accepts connections.
Relationships and Data Flows
– The WebSocket Server to External Clients, indicating two-way communication and broadcast of state changes.
– The Webstone Core Module to the WebSocket Server (e.g., via WebstoneSocketServer) to show that events from the mod (such as block toggles) are sent over the network.
– The Mod Loader (Forge) to the Webstone components, indicating that Forge initializes and manages registration and events.
– The configuration module (WebstoneConfig) feeding parameters (passphrase, port, security options) into the WebSocket Server.
– The Data & Business Logic layer interacting with both the mod’s in-game events and the external WebSocket communication (i.e., block update notifications).
Architectural Patterns & Design Principles
• The design follows a layered approach where Minecraft integration, networking, and game logic are separated.
• Notice the event-driven communication between the WebSocket Server and connected clients (broadcast updates when a block’s state changes).
• Secure communication is optionally enforced via TLS and passphrase authentication.
• The project uses a modular structure to ease registration of blocks and commands within Minecraft’s Forge modding framework.
Relevant Technologies and Frameworks
• Java and the Forge Mod Loader for Minecraft.
• Gradle as the build system (indicated by build.gradle, settings.gradle, gradle wrapper files).
• WebSockets for network communication (using core Java networking libraries or custom WebSocket implementations).
• JSON as a data exchange format for API calls between server and clients.
• Configuration via TOML file (as specified for Webstone).