Welcome to MCPI Recompiled
Relevant source files
The following files were used as context for generating this wiki page:
MCPI Recompiled is a source-reconstruction and native port project for Minecraft: Pi Edition 0.1.1 alpha. Its primary purpose is to reproduce the original game and its programming API natively on modern Linux and Windows x86-64 systems. The project is currently in a bootstrap/research phase, focusing on incremental reconstruction of game systems while maintaining strict compatibility with the original MCPI protocol.
Sources: README.md:1-12, README.md:21-23
The architecture prioritizes a portable C++ build environment (C++20) and a protocol-compatible API test harness. By utilizing a TCP server on port 4711, the project ensures that existing Minecraft Pi scripts and tools can interface with the recompiled version without modification.
Sources: README.md:14-19, CMakeLists.txt:10-12
Project Goals and Roadmap
The development of MCPI Recompiled is structured into distinct phases, beginning with establishing a solid foundation for compatibility before introducing modern features.
Phase 1: Compatibility
- Native builds for Windows and Linux x86-64.
- Implementation of a protocol-compatible API server on TCP port 4711.
- Reconstruction of platform-independent game systems.
- Verification of behavior through documented observations and tests.
Development Roadmap
- Bootstrap: Establishing portable C++ build and CI.
- API Harness: Implementing the protocol parser and server.
- Documentation: Recording original executable and platform assumptions.
- Reconstruction: Building game systems in testable pieces.
- Frontend: Implementing rendering, input, and windowing.
Sources: README.md:14-19, README.md:32-41, src/main.cpp:8-10
API Architecture
The core of the project's current implementation is the API subsystem, which handles communications using the Minecraft Pi protocol. This system consists of a command parser and a multi-threaded TCP server.
Command Parsing Logic
The mcpi::api::parse_command function processes raw strings into structured Command objects. It identifies the command name and extracts arguments enclosed in parentheses, separated by commas.
The parser handles various formats, including zero-argument calls like player.getPos() and text payloads like chat.post(message).
Sources: src/api/Command.cpp:21-55, src/api/Command.hpp:11-14, tests/protocol_tests.cpp:24-42
API Server Component
The ApiServer class provides a multi-threaded listener that accepts TCP connections and processes commands via a registered handler function.
| Feature | Description |
|---|---|
| Default Port | 4711 |
| Concurrency | Uses std::thread and std::atomic for non-blocking operation |
| Platform Support | Cross-platform abstraction for Winsock (Windows) and Berkeley Sockets (Linux) |
| Protocol | Line-based ASCII commands terminated by \n |
Sources: src/api/ApiServer.hpp:16-33, src/api/ApiServer.cpp:115-121, src/api/ApiServer.cpp:200-210
Connection Lifecycle
The following sequence illustrates how the ApiServer interacts with a client and the internal game logic:
Build System and Technical Requirements
The project uses CMake and requires a C++20 compliant compiler. It maintains a clean separation between the core logic (mcpi_core) and the executable.
Dependencies and Libraries
- Threads: Required for the asynchronous API server.
- Winsock2 (ws2_32): Required on Windows platforms.
- C++20: Standardized for modern language features.
Build Configuration
The CMakeLists.txt defines several targets, including the main executable and test suites.
| Target | Type | Description |
|---|---|---|
mcpi_core | Static Library | Contains the API server and command logic |
mcpi-recompiled | Executable | The main game entry point |
mcpi_protocol_tests | Test Executable | Validates the command parser |
mcpi_api_server_tests | Test Executable | Validates TCP communication and integration |
Sources: CMakeLists.txt:1-20, CMakeLists.txt:41-55
Repository Policies
To ensure legal compliance and project integrity, the following policies are enforced:
- No Redistribution: Original
minecraft-piexecutables, textures, sounds, or proprietary assets must not be committed to Git. - Source Reconstruction: Code is written from scratch based on observations and reverse-engineering notes.
- Portability: Code must remain platform-independent where possible, using abstraction layers for system-specific tasks like networking.
Sources: README.md:7-11, README.md:43-46
Summary
MCPI Recompiled establishes a modern foundation for the classic Minecraft: Pi Edition. By focusing on a robust, testable API server and a clean C++20 architecture, the project provides a compatible platform for native execution on modern operating systems while preserving the original programming interface.
Sources: README.md:21-23, src/main.cpp:8-12