# Fabric kit (Minecraft as a Fusion guest)

Our fork of SkyCraft's Fabric mod (MIT, see `THIRD-PARTY-NOTICES.md` at the repo root). It started
as an exact copy of `third_party/skycraft/fabric` (commit `bfcaf17`) in BUILD.md step 1.2. How
SkyCraft works: [`docs/skycraft-notes.md`](https://steonmod.com/docs/skycraft-notes).

**Since step 1.3b it speaks the Fusion protocol** ([`docs/protocol.md`](https://steonmod.com/docs/protocol)) with game id `minecraft`,
like every other kit. The mod's own code still calls `dev.skycraft.link.SkyLink` as it did when it
talked to Skyrim; `SkyLink` now translates:

| The mod's side | The Fusion protocol |
|---|---|
| Skyrim's state (viewport, where the player looks, where it stands) | the camera slot (size), `InputState.yaw/pitch` (possess), `Teleport` |
| the player's state | the `pose` slot (feet) and the `view` slot (eyes, F5 camera, FOV, flags) |
| the input ring | `RawInput` messages (same numbers: SDL scancodes = USB HID usages) |
| Skyrim's collision ring | Fusion's 16 m `CollisionChunk`s; `world/TriVoxels` turns their triangles into the 8x8x8 sub-voxel masks Minecraft's block physics needs |
| the overlay triple buffer | a CPU picture layer (`LayerFlags::CPU \| BOTTOM_UP`), the hand + HUD |
| the render ring (atlas, sections, body, entities, block lights) | a mesh layer (`MeshTexture`, `MeshPart`, `MeshLights`, `MeshClear`) through a bulk stream |
| (new) | `EntityList`s of the mobs near the player (`client/EntityExporter`), `Spawn` and the `remove` `Action` (`link/FusionSpawns`) |

The protocol's rules (discovery, heartbeats, seqlocks, rings, layer buffers, bulk streams) are the
shared Java runtime in `kits/common/java/fusion/kit`, compiled into the mod with the generated
`FusionProtocol.java` (see `build.gradle`).

Changes from upstream:
- the link to the host (above);
- dropped: Discord presence, the e4mc dependency, Skyrim skill training (smithing, armor, block);
- `gradle/wrapper/gradle-wrapper.properties`: pinned `distributionSha256Sum` (Gradle 9.7.1);
- `gradle.properties`: Gradle heap 2 GB instead of 4 GB (the dev PC has little free RAM); version 0.2.0.

Not sent to Fusion yet: dropped items, arrows and block cracks (SkyCraft's "world entities"), the
targeted-block outline, water from the host's world, other games' NPCs as hittable stand-ins (that
comes with Fusion's Proxy Manager).

Build (JDK 25):

    set JAVA_HOME=%USERPROFILE%\AppData\Local\Programs\Eclipse Adoptium\jdk-25.0.2.10-hotspot
    gradlew build          -> build\libs\skycraft-<version>.jar (24 tests)
    gradlew --stop         frees the Gradle daemon's memory afterwards

Install into the Prism instance used by Fusion (Prism and Minecraft closed; remove older
`skycraft-*.jar` files there first):

    copy build\libs\skycraft-0.2.0.jar %APPDATA%\PrismLauncher\instances\Fusion-MC-26.3\minecraft\mods\

The instance's JVM arguments are `--enable-native-access=ALL-UNNAMED -Dskycraft.startHidden=true`.
Minecraft quits about 5 s after the Fusion it linked to closes (`-Dskycraft.quitWithSkyrim=false`
keeps it running); it reconnects to the next Fusion that expects `minecraft`.
