Files
hearth/script/wowmine-client-info/README.md
T

122 lines
6.0 KiB
Markdown

# wowmine Client Info
Tiny client-only addon, version 1.0.0, for Minecraft 1.21.1 and NeoForge
21.1.250. Java 21 required. Uses NeoForge's built-in Mixin support and the
Minecraft-provided Gson library; no bundled libraries or extra runtime mods.
## Build
From this directory:
```sh
GRADLE_USER_HOME="$PWD/.gradle-home" sh gradlew --console=plain build
```
Windows: `gradlew.bat --console=plain build` with Java 21 on `PATH`.
The official Gradle 9.2.1 wrapper downloads its distribution and verifies the
pinned SHA-256. ModDevGradle 2.0.148 prepares the pinned NeoForge dependencies.
The first build needs network access.
Outputs:
- `build/libs/wowmine-client-info-1.0.0.jar`: install in the client's `mods`.
- `build/libs/wowmine-client-info-1.0.0-sources.jar`: Java source/resources.
The repository directory also contains the complete build definition and
wrapper. Keep those files with the sources to rebuild; the sources JAR alone
is not a build project.
## Pack metadata contract
The pack builder owns `<game directory>/config/wowmine-version.json`.
It must generate this UTF-8 JSON object from the same mrpack manifest used
for the release:
| Required string | Manifest source |
| --- | --- |
| `name` | `name` |
| `version` | `versionId` |
| `minecraft` | `dependencies.minecraft` |
| `neoforge` | `dependencies.neoforge` |
The release manifest's `name` must be exactly lower-case `wowmine` for the
window title and local login message to show the intended branding. The addon
continues to display the manifest name rather than hardcoding a release name.
All four values must be strings, nonblank, and contain no control characters.
Extra properties are ignored. No pack release version is compiled into this
addon. The displayed Minecraft and NeoForge versions come from this metadata,
so the builder must ensure they match the installed runtime.
Metadata is read once, on the first game title computation, before a network
login. Restart after changing it. Missing, unreadable, malformed, or incomplete
metadata gives `unknown pack unknown | Minecraft unknown | NeoForge unknown`
and a warning in the client log. No fallback claims a current release.
## Behavior and API evidence
The client mixin injects at every RETURN of
`net.minecraft.client.Minecraft#createTitle()Ljava/lang/String;`, private,
instance, no arguments, returning `String`. It prefixes the metadata display
and retains the original title, including Minecraft's connection context.
It does not depend on a player, world, mod constructor, or successful login.
The client-only mixin list prevents application on a dedicated server.
The `@Mod(..., dist = Dist.CLIENT)` constructor registers one
`ClientPlayerNetworkEvent.LoggingIn` listener on `NeoForge.EVENT_BUS`.
For a network connection, it adds `CLIENT: <metadata display>` directly to
`Minecraft.getInstance().gui.getChat().addMessage(Component.literal(...))`.
This only changes the local chat HUD. No packets, commands, channels, payload
registrations, or server messages are created. Integrated singleplayer's
in-memory connection is excluded.
NeoForge fires `LoggingIn` from the login packet handling path. Respawn and
dimension changes use the separate respawn/Clone path, so no tick flag or
dimension tracking is needed. Each fresh network login gets one message.
The JAR has no dedicated-server entrypoint; its dependency declarations have
`side="CLIENT"`. On dedicated servers its client entrypoint and client mixin
are inactive. Installing it on a server is unnecessary. No server-side addon
or handshake channel is required.
Official references consulted:
- https://docs.neoforged.net/docs/1.21.1/gettingstarted/modfiles/
- https://docs.neoforged.net/docs/1.21.1/concepts/sides/
- https://github.com/NeoForgeMDKs/MDK-1.21.1-ModDevGradle/blob/main/build.gradle
- https://github.com/neoforged/NeoForge/blob/1.21.1/patches/net/minecraft/client/Minecraft.java.patch
- https://github.com/neoforged/NeoForge/blob/1.21.1/patches/net/minecraft/client/multiplayer/ClientPacketListener.java.patch
- https://github.com/neoforged/NeoForge/blob/1.21.1/src/main/java/net/neoforged/neoforge/client/event/ClientPlayerNetworkEvent.java
The pinned build's generated Minecraft source and NeoForge 21.1.250 sources
provide the final signature and call-site evidence; see `BUILD-EVIDENCE.md`.
## Runtime acceptance plan
Runtime QA belongs to the main pack task and is not claimed by a compile:
1. Install only the addon on a Java 21 / Minecraft 1.21.1 / NeoForge 21.1.250
client. Supply the generated metadata from the exact exported manifest.
2. Cold-start the client. Capture the game window title on initial loading and
the title screen, before joining. Verify all four metadata values appear.
The separate NeoForge bootstrap window before Minecraft exists is outside
the `Minecraft.createTitle` hook.
3. Attempt a connection rejected before login (for example, whitelist denial).
Capture the rejection screen and window title. The title must retain the
same pack and runtime metadata. No `CLIENT:` login message should appear.
4. Join a server without this JAR. Verify exactly one `CLIENT:` metadata line
in the local HUD. A second connected client must see no such line; the
server console must receive no addon chat, command, or payload.
5. Change dimensions and respawn. Verify no additional metadata line.
6. Disconnect and reconnect. Verify exactly one new local `CLIENT:` line.
Verify title metadata persists across disconnect, menus, and reconnection.
7. Open an integrated singleplayer world. Verify no network-login line.
8. Restart with metadata absent; then malformed JSON; then missing field;
then a non-string/blank value. Each must show `unknown` visibly in title
and on successful network login, with a log warning and no crash.
9. Change just the manifest-derived pack version, regenerate metadata, restart.
Verify the new pack version appears while addon version stays 1.0.0.
10. Optional dedicated-server compatibility check: start a disposable server
with the JAR present. Verify client code/mixin remain inactive and the
server starts. Do not install on production for this test.