Minecraft 26.3

CraftGround selects the 26.3 Fabric runtime with mc_version="26.3". The default is still 1.21. The first reset builds and starts the client, downloads Minecraft assets, and creates a world.

Installing from this branch

Use a full JDK 25 and set JAVA_HOME to that JDK so CMake can find the JNI headers. The runtime also needs CMake 3.28 or newer, a C++ toolchain, and OpenGL development libraries. Linux and Windows builds use GLEW. PNG capture requires libpng.

From a checkout with the Python native-extension build dependencies installed, run

python -m pip install ./minecraft/mc121 ./minecraft/mc263 '.[mc263]'

For locally built wheels, put both the core and runtime wheels in the same directory and run python -m pip install --find-links ./dist 'craftground[mc263]==2.9.1'.

Running an episode

import craftground
from craftground.environment.action_space import no_op

env = craftground.make(mc_version="26.3")
try:
    observation, info = env.reset()
    observation, reward, terminated, truncated, info = env.step(no_op())
    print(observation["rgb"].shape)
finally:
    env.close()

Set cleanup_world=False when creating the environment to keep a generated world after closing it. Opening an existing world by display name preserves its save.

Sockets are the default transport and are required on Windows for all supported Minecraft versions. On macOS, pass use_shared_memory=True to craftground.make to exchange actions and observations through POSIX shared memory. Install both the core and the 26.3 runtime from this branch. On Apple Silicon, the integration tests cover RAW, stereo PNG with depth, Metal tensor capture, fast resets, and full Minecraft restarts over shared memory.

Capture modes

On Apple Silicon and Linux with an NVIDIA RTX 6000 Ada, the integration test exercises single-eye RAW and stereo PNG with depth on both OpenGL and Vulkan. It checks player displacement, a camera turn and image change in the same step, distinct stereo images, and depth at the requested resolution. Select the backend when launching Python with CRAFTGROUND_MC263_GRAPHICS_BACKEND=OPENGL or VULKAN.

The same suite targets a poplar plank, breaks it with a Python action, and confirms by raycast that the wall behind it is now visible. It checks the change in depth against the known distances to both surfaces and uses four colors on the wall to check RAW and PNG orientation at 319 × 181.

Apple Silicon supports ScreenEncodingMode.ZEROCOPY_TORCH on Vulkan with any PyTorch 2.x that provides MPS, and the core wheel does not link LibTorch. PyTorch 2.9 and newer import the shared surface through Metal DLPack and clone each frame on the MPS stream. Older releases cannot import Metal DLPack. For them, CraftGround allocates the frame as an MPS tensor and fills its MTLBuffer with a Metal blit, so the frame never passes through the CPU. This path waits for queued MPS work before each copy. Set CRAFTGROUND_MC263_GRAPHICS_BACKEND=VULKAN and add -Dcraftground.enableMetalObjects=true to JAVA_TOOL_OPTIONS. macOS may ask for administrator authorization when Minecraft shares its IOSurface with Python. When both Python and the 26.3 runtime support RGBA IOSurface capture, Vulkan copies the render target into a matching shared image and PyTorch materializes an independent RGB frame. Set CRAFTGROUND_VULKAN_METAL_RGBA=0 to use the BGRA capture path. The live test checks colors, orientation, and retained MPS frames across camera turns and a runtime restart. With JAX installed, select ScreenEncodingMode.ZEROCOPY_JAX to capture through the same IOSurface. Python copies the frame to CPU if JAX cannot import the MPS tensor.

On Linux with NVIDIA, build the core Python extension and the 26.3 runtime with the CUDA toolkit available to CMake, and install a CUDA-enabled PyTorch. Select ScreenEncodingMode.ZEROCOPY_TORCH. OpenGL shares its color texture through CUDA. For Vulkan, add -Dcraftground.enableCudaInterop=true to JAVA_TOOL_OPTIONS before starting Python. 26.2 GPU interop design

With the current CUDA-enabled Python extension on Linux, Vulkan copies RGB from the render target into a single device-local buffer that Python maps directly through CUDA. A private Unix socket transfers the file descriptor once per Minecraft process. This works with either observation transport. If Python cannot import the direct buffer, reset() restarts Minecraft once and uses the earlier CUDA IPC path for the lifetime of that environment. PyTorch returns an independent RGB tensor and can retain earlier frames. Set CRAFTGROUND_VULKAN_CUDA_DIRECT=0 before launching Python to select CUDA IPC from the start.

With SDL’s offscreen video driver, CraftGround skips window-image acquisition and renders observations directly from the game render target. SDL’s Vulkan offscreen driver still needs a Vulkan headless surface implementation. On macOS with Vulkan and SDL Cocoa, CraftGround also skips window-image acquisition while the window is minimized. Restoring the window resumes presentation.

On Ubuntu 24.04 with an RTX 6000 Ada and driver 580.196.07, both backends returned CUDA tensors with the expected colors, orientation, and response to a camera turn. The test checks depth before and after breaking a block, then repeats the scene after restarting Minecraft in the same Python environment.

To run the installed-runtime checks from a checkout with pytest installed, use

CRAFTGROUND_MC263_GRAPHICS_BACKEND=OPENGL python -m pytest tests/python/native_integration/mc263_smoke.py
CRAFTGROUND_MC263_GRAPHICS_BACKEND=VULKAN python -m pytest tests/python/native_integration/mc263_smoke.py

To include the live Metal test on macOS, run

CRAFTGROUND_TEST_METAL=1 python -m pytest tests/python/native_integration/mc263_smoke.py -k metal
CRAFTGROUND_TEST_JAX=1 python -m pytest tests/python/native_integration/mc263_smoke.py -k jax

To run the live CUDA test on a Linux NVIDIA host with a working graphics display, use

CRAFTGROUND_TEST_CUDA=1 CRAFTGROUND_MC263_GRAPHICS_BACKEND=OPENGL python -m pytest tests/python/native_integration/mc263_smoke.py -k cuda
CRAFTGROUND_TEST_CUDA=1 CRAFTGROUND_MC263_GRAPHICS_BACKEND=VULKAN python -m pytest tests/python/native_integration/mc263_smoke.py -k cuda

This site uses Just the Docs, a documentation theme for Jekyll.