fangorn/huorn-minecraft
public
ref:main
# Huorn
A Minecraft Java Edition mod that embeds a fully functional [Alacritty](https://github.com/alacritty/alacritty) terminal emulator as an interactive block. Place a terminal block in your world, right-click it, and get a real shell session rendered on the block face.

## Features
- **Real terminal emulation** — powered by `alacritty_terminal` v0.25 (same engine as the Alacritty desktop terminal)
- **Full ANSI color support** — 256 colors + true color, bold, italic, underline, strikethrough
- **In-world rendering** — terminal content rendered as a texture on the block face using `fontdue` font rasterization
- **Full-screen GUI overlay** — press F12 for a larger view
- **Focus mode** — right-click to capture all keyboard input; ESC to exit
- **Cross-loader** — supports both Fabric and Forge via Architectury
- **Local PTY** — spawns a real shell process on the player's machine
## Requirements
- Minecraft Java Edition 1.20.1
- Fabric Loader 0.15+ with Fabric API, or Forge 47.2+
- Architectury API 9.2+
- macOS (aarch64) — other platforms need native library cross-compilation
## Quick Start
### Building
```bash
# Build the Rust native library
cd rust && cargo build --release
# Copy native to mod resources
mkdir -p common/src/main/resources/natives/macos-aarch64
cp rust/target/release/libhuorn_minecraft.dylib common/src/main/resources/natives/macos-aarch64/
# Build the mod (requires Java 21)
export JAVA_HOME=/opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk/Contents/Home
./gradlew build
Running
# Launch Minecraft dev client
./gradlew :fabric:runClient
In-Game Usage
- Open creative inventory → "Huorn" tab
Or use:
/give @s huorn:terminal_block - Place the terminal block — it faces toward you
- Right-click the block to start the terminal and enter focus mode
- Type commands — all keyboard input goes to the terminal
- F12 — opens full-screen terminal overlay
- ESC — exits focus mode (returns to normal Minecraft controls)
- Mouse scroll — scrolls terminal history
Architecture
Shell Process (local PTY)
↓ raw bytes
alacritty_terminal VTE parser → grid cells (char + fg/bg + flags)
↓
fontdue glyph rasterizer + LRU cache (4096 glyphs)
↓
RGBA pixel buffer (Vec<u8> in Rust, ~1MB)
↓ JNI: nativeGetPixelData() → direct ByteBuffer
Java NativeImage → DynamicTexture → OpenGL texture
↓
BlockEntityRenderer (textured quad on block face)
Tests
# Rust tests (46 tests: glyph cache, renderer, key translation, terminal lifecycle)
cd rust && cargo test
# Java compilation verification
./gradlew build
Project Structure
rust/src/ — Native JNI library (Rust)
lib.rs — JNI entry points
terminal.rs — Terminal state, PTY, VTE parsing
renderer.rs — Pixel buffer renderer
glyph_cache.rs — fontdue font rasterization + LRU cache
common/src/ — Shared Minecraft mod code (Architectury)
block/ — TerminalBlock, TerminalBlockEntity, ScreenGroup
nativelib/ — NativeTerminal (JNI), NativeLoader (platform detection)
client/ — Renderer, screen, input handling
mixin/ — KeyboardHandler char input interception
fabric/ — Fabric-specific entrypoint
forge/ — Forge-specific entrypoint