How clockworklabs/spacetimedb-minecraft works
The project is a specialized Minecraft server implementation written in Rust that runs on SpacetimeDB. It is split into two main applications:
• A SpacetimeDB module (located in crates/mc173-module and also partly in crates/module) that encapsulates the core game logic (such as handling biomes, blocks, entities, world simulation, terrain generation, and more)—essentially all the server-side mechanics of Minecraft.
• A Minecraft Proxy Server (in crates/mc173-server) that acts as a bridge between the Minecraft client and the SpacetimeDB module, because SpacetimeDB cannot interface directly with the client.
Main Components
– Minecraft Client: Represents the end-user client connecting to the game server.
– Minecraft Proxy Server: Handles network communication with the client. Inside this component, include subsystems such as network handling, command processing, protocol conversion (note the “autogen” files), and player management.
– SpacetimeDB Module: Hosted on SpacetimeDB; responsible for the internal game rules and simulation logic. This divides further into various submodules, for example:
• Block handling (with files for different block types such as bed, button, door, etc.),
• Block entity management (chest, dispenser, furnace, jukebox, etc.),
• World and chunk management (world, chunk, storage, etc.),
• Entity and physics handling (entity, tick logic, random generation, etc.),
• World generation and terrain processing (cave, dungeon, nether, noise, etc.).
– External Service: SpacetimeDB itself (the cloud or external service platform where the module is deployed), which will be integrated via the SpacetimeDB CLI or API endpoints.
Architectural Patterns and Internal Structure
– Emphasize the clear separation of concerns: the Proxy Server handles protocol-level and network communication concerns, while the Module encapsulates core game logic and simulation.
– Highlight use of auto-generated code in the mc173-server (under “autogen”), which likely represents protocol definitions or data conversion utilities that support client and server communication.
Relevant Technologies and Frameworks
– Rust and Cargo as the primary technology stack.
– SpacetimeDB as the deployment platform for the game logic module.
– The design should also reference internal libraries for network I/O, game simulation, and protocol handling (e.g., items, block logic, world tick processing).