mchost / mod/README.md

raw file 2521 bytes
# mchost mods (Fabric)

Two small Fabric mods that turn the mchost tunnel into an in-game experience:

| Mod | Side | What it does |
|-----|------|--------------|
| [`client/`](client) | players | A **Tunnel...** button in the Multiplayer screen: paste an `mchost://` invite and join with a completely vanilla client. Remembers the last invite. |
| [`server/`](server) | host | Shows the tunnel invite **in chat, click-to-copy**: when mchost publishes it, when an operator joins, and on `/mchost`. |

The Rust `mchost` binary stays in charge of the server process, the
Cloudflare tunnel and the WebSocket bridge. The mods are a thin veneer:
the server mod reads the invite from `mchost-address.txt` (written by mchost
in the server directory), and the client mod dials the same `wss://<host>/mc`
endpoint the `mchost connect` CLI helper uses — so mods and CLI are
interchangeable.

## Building

Requires JDK 25+ and network access (Loom downloads Minecraft on first build).
Gradle wrappers are included:

```sh
cd mod/client && ./gradlew build     # -> build/libs/mchost-client-0.1.0.jar
cd mod/server && ./gradlew build     # -> build/libs/mchost-server-0.1.0.jar
```

If `./gradlew` is missing, run `gradle wrapper --gradle-version 9.8.1` once with
any recent Gradle. Target: Minecraft 26.3, Fabric Loader 0.19.5, Fabric API
0.162.0+26.3 (see each project's `gradle.properties`).

## Installing

- **Players**: drop `mchost-client-*.jar` + Fabric API into `mods/` of a Fabric
  client. Then Multiplayer → **Tunnel...** → paste the invite → Join.
- **Host**: drop `mchost-server-*.jar` + Fabric API into the Fabric server's
  `mods/`. Run your server under `mchost` as usual; operators get the invite in
  chat automatically.

## Playing together

The host runs:

```sh
mchost server.jar --bridge-secret hunter2
# ...and shares the printed invite:
#   mchost://noble-royal-ronald.trycloudflare.com/mc?s=hunter2
```

A player pastes that invite into the mod's Tunnel screen (or into
`mchost connect <invite>` on the CLI) and joins `127.0.0.1` in their vanilla
client. Operators see the same invite in-game via the server mod — click it,
paste it to your friends, done.

## Notes

- Both mods target the exact Minecraft version in `gradle.properties`; bump it
  (and Fabric API) to port them.
- The client mod does one WebSocket session per game connection; several
  players behind one installation each join through their own session.
- The server mod only *announces* the invite; it never touches networking.