feat: wowmine: more abilites to debug version
This commit is contained in:
+54
-4
@@ -21,9 +21,13 @@ Official workflow: https://packwiz.infra.link/tutorials/installing/packwiz-insta
|
||||
## Publishing a tested update
|
||||
|
||||
Keep authoritative `.mrpack` revisions as separate files in Storage Box.
|
||||
The current source is `minecraft/pack/WorldOfSosal-v5-optimizations.mrpack`,
|
||||
SHA-256 `d3ec9d8725fbaaaa1e14ced3404a1fb904417ab45b1f632861d8e495e7846211`.
|
||||
V5 adds five optimizers and Nowheel, with separate client/server Lithium
|
||||
The current source is `minecraft/pack/WorldOfSosal-v6-version-display.mrpack`,
|
||||
SHA-256 `dfa815bf61ecd0374dfa8c52db9112b55652189aa253c5b359a748d0dba05818`.
|
||||
V6 adds a client-only version indicator; all v5 mods and configuration remain
|
||||
unchanged. The game window and local login chat show the manifest version;
|
||||
the server MOTD shows the selected release. Downloads from the page use
|
||||
`WorldOfSosal-<version>.mrpack`, while `latest.mrpack` remains a compatibility URL.
|
||||
V5 added five optimizers and Nowheel, with separate client/server Lithium
|
||||
compatibility settings. V4's removal of Dynamic Height and its Sable addon is
|
||||
retained. Minecraft/NeoForge versions are unchanged. For a server update, upload a new
|
||||
revision and set its path and SHA-256 in `nixos/system/neuro/minecraft/world-of-sosal.nix`,
|
||||
@@ -33,7 +37,7 @@ it incompatible with the running server.
|
||||
|
||||
```sh
|
||||
# Test the client and deploy the matching server release first.
|
||||
python3 script/build-prism-pack.py WorldOfSosal-v5-optimizations.mrpack \
|
||||
python3 script/build-prism-pack.py WorldOfSosal-v6-version-display.mrpack \
|
||||
prism-export --server store.hectic-lab.com:25568
|
||||
python3 script/publish-prism-pack.py prism-export hectic-lab
|
||||
```
|
||||
@@ -65,6 +69,52 @@ If Minecraft/NeoForge versions change, update and test both the server pin and
|
||||
client pack. packwiz-installer 0.5.14 understands NeoForge components in Prism's
|
||||
`mmc-pack.json`; a launcher restart/relaunch may be necessary after changing them.
|
||||
|
||||
## Client version information
|
||||
|
||||
Source and build instructions: `script/worldofsosal-client-info/README.md`.
|
||||
The addon version is 1.0.0; it is independent of the pack release.
|
||||
`config/worldofsosal-version.json` is generated from the mrpack's `name`,
|
||||
`versionId`, and Minecraft/NeoForge dependencies. An existing metadata override
|
||||
must match that manifest or the builder rejects the release. When preparing
|
||||
a new source archive, regenerate its client metadata from its updated manifest.
|
||||
|
||||
The title appears before login and remains on connection failures. After each
|
||||
successful multiplayer login, `CLIENT: WorldOfSosal <version> | Minecraft
|
||||
<version> | NeoForge <version>` is added only to that client's chat. Dimension
|
||||
changes do not add another line. The early NeoForge bootstrap window is
|
||||
separate from the Minecraft game window.
|
||||
|
||||
The immutable download name and its checksum are included in publication;
|
||||
previous named archives are retained. The selected release's MOTD is declared
|
||||
in `world-of-sosal.nix` alongside its archive path.
|
||||
|
||||
## Verification: v6 on 2026-11-12
|
||||
|
||||
- Java 21 addon build passed against NeoForge 21.1.250, with no extra runtime
|
||||
libraries and no server installation.
|
||||
- The actual game window showed v6 before joining and after whitelist denial;
|
||||
the rejected login added no success message.
|
||||
- Successful multiplayer login showed the full local chat line. Dimension
|
||||
change kept one line; disconnect/reconnect produced exactly one new line.
|
||||
- A real packwiz update from the published 598-entry v5 snapshot to the
|
||||
600-entry v6 snapshot installed the addon and metadata and preserved custom
|
||||
`options.txt`. A mismatched manifest/metadata release was rejected.
|
||||
- Chromium downloaded `WorldOfSosal-v6-version-display.mrpack`; its bytes matched
|
||||
the source archive. Desktop and phone-width page captures were inspected.
|
||||
- Public Minecraft status returned `WorldOfSosal v6-version-display`; live
|
||||
view and simulation distance remained 32, with the previous Java/start command.
|
||||
- Storage Box upload/download comparison passed; older versions remain.
|
||||
|
||||
One additional Quick Play QA startup failed in existing Puffish Skills 0.19.0:
|
||||
`ConcurrentModificationException` in `RewardRegistry.register`, followed by a
|
||||
secondary Sodium configuration error. Normal menu-based startups and joins
|
||||
worked. That startup failure was not repaired by this version-display change;
|
||||
reproduction without the addon has not been established.
|
||||
|
||||
Targeted server activation preserves the current platform: the existing
|
||||
`50-distances.conf` pre-start override now uses the v6 properties template.
|
||||
Reconcile that override on a future full server configuration activation.
|
||||
|
||||
## Verification: v5 on 2026-11-12
|
||||
|
||||
- Published `v5-optimizations` on hectic-lab; immutable web release
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
{ config, ... }:
|
||||
|
||||
let
|
||||
packVersion = "v6-version-display";
|
||||
in
|
||||
{
|
||||
sops.secrets."minecraft/storage-box-pack-key" = {
|
||||
sopsFile = ../../../../sus/neuro-minecraft.yaml;
|
||||
@@ -13,10 +16,10 @@
|
||||
serverName = "wowMineMap";
|
||||
remoteHost = "u664722.your-storagebox.de";
|
||||
remoteUser = "u664722";
|
||||
remotePath = "minecraft/pack/WorldOfSosal-v5-optimizations.mrpack";
|
||||
remotePath = "minecraft/pack/WorldOfSosal-${packVersion}.mrpack";
|
||||
archiveName = "WorldOfSosal.mrpack";
|
||||
cacheDir = "/var/lib/minecraft-modpacks/worldOfSosal";
|
||||
archiveSha256 = "d3ec9d8725fbaaaa1e14ced3404a1fb904417ab45b1f632861d8e495e7846211";
|
||||
archiveSha256 = "dfa815bf61ecd0374dfa8c52db9112b55652189aa253c5b359a748d0dba05818";
|
||||
expectedDependencies = {
|
||||
minecraft = "1.21.1";
|
||||
neoforge = "21.1.250";
|
||||
@@ -25,6 +28,9 @@
|
||||
hostPublicKey = "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5EB5p/5Hp3hGW1oHok+PIOH9Pbn7cnUiGmUEBrCVjnAw+HrKyN8bYVV0dIGllswYXwkG/+bgiBlE6IVIBAq+JwVWu1Sss3KarHY3OvFJUXZoZyRRg/Gc/+LRCE7lyKpwWQ70dbelGRyyJFH36eNv6ySXoUYtGkwlU5IVaHPApOxe4LHPZa/qhSRbPo2hwoh0orCtgejRebNtW5nlx00DNFgsvn8Svz2cIYLxsPVzKgUxs8Zxsxgn+Q/UvR7uq4AbAhyBMLxv7DjJ1pc7PJocuTno2Rw9uMZi1gkjbnmiOh6TTXIEWbnroyIhwc8555uto9melEUmWNQ+C+PwAK+MPw==";
|
||||
};
|
||||
|
||||
services.minecraft-servers.servers.wowMineMap.serverProperties.motd =
|
||||
"WorldOfSosal ${packVersion} — World of Warcraft";
|
||||
|
||||
# Import the map before writing modpack configuration into the same server.
|
||||
systemd.services.minecraft-modpack-import-worldOfSosal = {
|
||||
after = [ "minecraft-world-import-wowMineMap.service" ];
|
||||
|
||||
@@ -75,9 +75,8 @@
|
||||
online-mode = false;
|
||||
enable-rcon = true;
|
||||
"rcon.port" = 25575;
|
||||
view-distance = 12;
|
||||
simulation-distance = 8;
|
||||
motd = "WorldOfSosal — World of Warcraft";
|
||||
view-distance = 32;
|
||||
simulation-distance = 32;
|
||||
level-name = "world";
|
||||
pause-when-empty-seconds = 0;
|
||||
};
|
||||
|
||||
Executable → Regular
+26
-4
@@ -5,6 +5,7 @@ Upload the pack directory to an immutable release, then atomically switch curren
|
||||
Publish only releases tested with the server, including Minecraft/NeoForge upgrades.
|
||||
"""
|
||||
import argparse
|
||||
from dataclasses import dataclass
|
||||
import hashlib
|
||||
import html
|
||||
import io
|
||||
@@ -20,6 +21,14 @@ import zipfile
|
||||
BOOTSTRAP_URL = 'https://github.com/packwiz/packwiz-installer-bootstrap/releases/download/v0.0.3/packwiz-installer-bootstrap.jar'
|
||||
BOOTSTRAP_SHA256 = 'a8fbb24dc604278e97f4688e82d3d91a318b98efc08d5dbfcbcbcab6443d116c'
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Arguments:
|
||||
mrpack: Path
|
||||
output: Path
|
||||
base_url: str
|
||||
server: str | None
|
||||
bootstrap: Path | None
|
||||
|
||||
def digest(data):
|
||||
return hashlib.sha256(data).hexdigest()
|
||||
|
||||
@@ -39,7 +48,7 @@ def main():
|
||||
ap.add_argument('--base-url', default='https://store.hectic-lab.com/minecraft/world-of-sosal/')
|
||||
ap.add_argument('--server', help='optional initial multiplayer server address')
|
||||
ap.add_argument('--bootstrap', type=Path)
|
||||
args = ap.parse_args()
|
||||
args = Arguments(**vars(ap.parse_args()))
|
||||
base = args.base_url.rstrip('/') + '/'
|
||||
if not base.startswith('https://'):
|
||||
ap.error('--base-url must use HTTPS')
|
||||
@@ -64,6 +73,15 @@ def main():
|
||||
deps = manifest['dependencies']
|
||||
if manifest['formatVersion'] != 1 or manifest['game'] != 'minecraft' or set(deps) != {'minecraft', 'neoforge'}:
|
||||
raise ValueError('Expected a Minecraft NeoForge mrpack v1')
|
||||
pack_info: dict[str, str] = {
|
||||
'name': manifest['name'],
|
||||
'version': manifest['versionId'],
|
||||
'minecraft': deps['minecraft'],
|
||||
'neoforge': deps['neoforge'],
|
||||
}
|
||||
download_name = str(safe_path(f'{manifest["name"]}-{manifest["versionId"]}.mrpack'))
|
||||
if '/' in download_name:
|
||||
raise ValueError('Pack name and version must form a filename')
|
||||
for f in manifest['files']:
|
||||
path = safe_path(f['path'])
|
||||
if f.get('env', {}).get('client') == 'unsupported':
|
||||
@@ -85,11 +103,14 @@ def main():
|
||||
continue
|
||||
name = item.filename[len(prefix):]
|
||||
safe_path(name)
|
||||
if name == 'config/worldofsosal-version.json' and json.loads(z.read(item)) != pack_info:
|
||||
raise ValueError('Client version metadata disagrees with mrpack manifest')
|
||||
if not (name.startswith(('config/', 'mods/', 'resourcepacks/', 'shaderpacks/')) or name == 'options.txt'):
|
||||
raise ValueError('Review unexpected override: ' + name)
|
||||
if name in destinations:
|
||||
raise ValueError('Override duplicates downloaded mod: ' + name)
|
||||
write(name, z.read(item), preserve=name == 'options.txt')
|
||||
write('config/worldofsosal-version.json', (json.dumps(pack_info, indent=2) + '\n').encode())
|
||||
index = 'hash-format = "sha256"\n'
|
||||
for entry in sorted(entries.values(), key=lambda e: e['file']):
|
||||
index += '\n[[files]]\n'
|
||||
@@ -104,6 +125,7 @@ def main():
|
||||
tomllib.loads(pack)
|
||||
(root / 'pack.toml').write_text(pack)
|
||||
(args.output / 'latest.mrpack').write_bytes(archive)
|
||||
(args.output / download_name).write_bytes(archive)
|
||||
# Prism otherwise uses its legacy INI parser and corrupts quoted commands.
|
||||
cfg = '\n'.join(['[General]', 'ConfigVersion=1.2', 'InstanceType=OneSix', 'name=WorldOfSosal Auto Update', 'iconKey=default', 'OverrideCommands=true', 'PreLaunchCommand=' + quote(f'"$INST_JAVA" -jar packwiz-installer-bootstrap.jar {base}current/pack.toml'), 'OverrideMemory=true', 'MinMemAlloc=1024', 'MaxMemAlloc=8192', ''])
|
||||
mmc = {'formatVersion': 1, 'components': [{'uid':'net.minecraft', 'version':deps['minecraft'], 'important':True}, {'uid':'net.neoforged', 'version':deps['neoforge'], 'important':True}]}
|
||||
@@ -123,12 +145,12 @@ def main():
|
||||
page = f'''<!doctype html><html lang="ru"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>WorldOfSosal</title>
|
||||
<h1>WorldOfSosal — автоматическое обновление</h1>
|
||||
<p>Один раз скачайте <a href="WorldOfSosal-Prism.zip">инстанс для Prism Launcher</a>, затем выберите «Добавить сборку → Импорт из zip». Разрешите команду перед запуском: она устанавливает и обновляет моды через packwiz.</p>
|
||||
<p>Minecraft {html.escape(deps['minecraft'])} · NeoForge {html.escape(deps['neoforge'])} · Java 21 · память 8 ГБ.</p>
|
||||
<p>Сборка {html.escape(pack_info['version'])} · Minecraft {html.escape(deps['minecraft'])} · NeoForge {html.escape(deps['neoforge'])} · Java 21 · память 8 ГБ.</p>
|
||||
<p>{'Сервер: <code>' + html.escape(args.server) + '</code>.' if args.server else 'Адрес игрового сервера будет сообщён отдельно.'}</p>
|
||||
<p>Моды и конфигурация сборки обновляются при каждом запуске. Личные настройки options.txt сохраняются. При смене Minecraft или NeoForge может потребоваться повторный запуск после обновления версии.</p>
|
||||
<p><a href="latest.mrpack">Обычный mrpack без автообновлений</a> · <a href="SHA256SUMS">Контрольные суммы</a></p></html>'''
|
||||
<p><a href="{urllib.parse.quote(download_name)}" download="{html.escape(download_name, quote=True)}">Обычный mrpack без автообновлений</a> · <a href="SHA256SUMS">Контрольные суммы</a></p></html>'''
|
||||
(args.output / 'index.html').write_text(page)
|
||||
files = ['WorldOfSosal-Prism.zip', 'latest.mrpack', 'pack/pack.toml']
|
||||
files = ['WorldOfSosal-Prism.zip', download_name, 'latest.mrpack', 'pack/pack.toml']
|
||||
(args.output / 'SHA256SUMS').write_text(''.join(f'{digest((args.output/f).read_bytes())} {f.replace("pack/", "current/")}\n' for f in files))
|
||||
print(json.dumps({'release':release, 'minecraft':deps['minecraft'], 'neoforge':deps['neoforge'], 'managed_files':len(entries), 'server':args.server}))
|
||||
|
||||
|
||||
Executable → Regular
+13
-2
@@ -19,8 +19,10 @@ release = hashlib.sha256((root / 'pack/pack.toml').read_bytes()).hexdigest()
|
||||
with tempfile.TemporaryDirectory(prefix='prism-publish-') as temporary:
|
||||
archive = Path(temporary) / 'publish.tar.gz'
|
||||
with tarfile.open(archive, 'w:gz') as tar:
|
||||
for name in ['pack', 'WorldOfSosal-Prism.zip', 'latest.mrpack', 'SHA256SUMS', 'index.html']:
|
||||
for name in ['pack', 'WorldOfSosal-Prism.zip', 'SHA256SUMS', 'index.html']:
|
||||
tar.add(root / name, arcname=name)
|
||||
for path in root.glob('*.mrpack'):
|
||||
tar.add(path, arcname=path.name)
|
||||
remote = f'/tmp/prism-publish-{release}.tar.gz'
|
||||
subprocess.run(['scp', '-o', 'BatchMode=yes', str(archive), f'{host}:{remote}'], check=True)
|
||||
script = '''set -eu
|
||||
@@ -38,7 +40,16 @@ if test -d "$base/releases/$release"; then
|
||||
else
|
||||
mv "$stage/pack" "$base/releases/$release"
|
||||
fi
|
||||
for name in WorldOfSosal-Prism.zip latest.mrpack SHA256SUMS index.html; do
|
||||
for source in "$stage"/*.mrpack; do
|
||||
name=$(basename "$source")
|
||||
if test "$name" != latest.mrpack && test -e "$base/$name"; then
|
||||
cmp "$source" "$base/$name"
|
||||
fi
|
||||
done
|
||||
for source in "$stage"/*.mrpack; do
|
||||
mv "$source" "$base/$(basename "$source")"
|
||||
done
|
||||
for name in WorldOfSosal-Prism.zip SHA256SUMS index.html; do
|
||||
mv "$stage/$name" "$base/$name"
|
||||
done
|
||||
ln -s "releases/$release" "$stage/current"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.gradle/
|
||||
.gradle-home/
|
||||
build/
|
||||
@@ -0,0 +1,129 @@
|
||||
# Build evidence
|
||||
|
||||
Observed on 2026-11-12 in `/home/yukkop/pj/hearth/script/worldofsosal-client-info`.
|
||||
This records an actual successful build, not a proposed command.
|
||||
|
||||
## Command and result
|
||||
|
||||
After fetching the official Gradle v9.2.1 wrapper scripts and wrapper JAR:
|
||||
|
||||
```sh
|
||||
GRADLE_USER_HOME="$PWD/.gradle-home" sh gradlew --console=plain build
|
||||
```
|
||||
|
||||
The asynchronous monitor was `mon_849BYA5S2BE0FF47`, with underlying
|
||||
terminal session `bash_5`. Its completion notification reported
|
||||
`watcher completed (exit code 0)`. A subsequent result receipt through
|
||||
`bash_output` on that monitor reported `status: completed exit_code: 0`.
|
||||
|
||||
Observed output:
|
||||
|
||||
```text
|
||||
> Task :compileJava
|
||||
> Task :processResources
|
||||
> Task :classes
|
||||
> Task :jarJar NO-SOURCE
|
||||
> Task :jar
|
||||
> Task :sourcesJar
|
||||
> Task :assemble
|
||||
> Task :compileTestJava NO-SOURCE
|
||||
> Task :processTestResources NO-SOURCE
|
||||
> Task :testClasses UP-TO-DATE
|
||||
> Task :test NO-SOURCE
|
||||
> Task :check UP-TO-DATE
|
||||
> Task :build
|
||||
|
||||
BUILD SUCCESSFUL in 4m 49s
|
||||
5 actionable tasks: 5 executed
|
||||
```
|
||||
|
||||
Toolchain: OpenJDK `21.0.7+6-nixos`, Gradle `9.2.1`,
|
||||
ModDevGradle `2.0.148`, NeoForge `21.1.250`,
|
||||
NeoForm `1.21.1-20240808.144430`.
|
||||
The wrapper verifies the Gradle distribution SHA-256 pinned in its properties.
|
||||
There was one build invocation; no subsequent rebuild.
|
||||
|
||||
## Artifacts inspected
|
||||
|
||||
```text
|
||||
build/libs/worldofsosal-client-info-1.0.0.jar
|
||||
SHA-256 841c6976fe9cdf783ecd4d48295f6ef042dff9cb65274bb6e1c917be31474a0f
|
||||
|
||||
build/libs/worldofsosal-client-info-1.0.0-sources.jar
|
||||
SHA-256 be451a549dc70377f2c04eac90b5e80adb0eb08ea9ce6ab92a79c65125034dc9
|
||||
```
|
||||
|
||||
`jar tf` confirmed the installable JAR contains:
|
||||
|
||||
- `PackInfo.class` and its lazy-loading holder;
|
||||
- `WorldOfSosalClientInfo.class`;
|
||||
- `mixin/MinecraftTitleMixin.class`;
|
||||
- `worldofsosal-client-info.mixins.json`;
|
||||
- `META-INF/neoforge.mods.toml`.
|
||||
|
||||
No dependency libraries or server/network payload classes are bundled.
|
||||
`javap -v` on the compiled mixin confirmed Java class major version `65`
|
||||
(Java 21), the exact `createTitle()Ljava/lang/String;` injection selector,
|
||||
and `CallbackInfoReturnable` interaction in the compiled constant pool.
|
||||
|
||||
## Exact API and control-flow inspection
|
||||
|
||||
The build generated `build/moddev/artifacts/neoforge-21.1.250-sources.jar`
|
||||
and `neoforge-21.1.250.jar`. Selected official sources were extracted into
|
||||
ignored `build/api-source/` for inspection. These are generated verification
|
||||
inputs, not addon sources.
|
||||
|
||||
In the generated `net/minecraft/client/Minecraft.java`:
|
||||
|
||||
- Line 467 passes `this.createTitle()` directly to `virtualScreen.newWindow`
|
||||
in the constructor. The hook therefore covers the first Minecraft window
|
||||
title, before joining a server.
|
||||
- Lines 716-720 define `updateTitle()` and the private, no-argument
|
||||
`String createTitle()` method. The original implementation handles a null
|
||||
connection, so no successful login is required.
|
||||
- Line 1064 updates the title during screen changes. Rejected connections
|
||||
can show a disconnect screen while retaining the injected metadata.
|
||||
- Lines 2134-2184 show disconnect teardown, including
|
||||
`updateScreenAndTick(...)` and `updateLevelInEngines(null)`.
|
||||
Line 2242 updates the title from `updateLevelInEngines`.
|
||||
|
||||
In generated `net/minecraft/client/multiplayer/ClientPacketListener.java`:
|
||||
|
||||
- `handleLogin` begins at line 394; line 432 calls `ClientHooks.firePlayerLogin`
|
||||
after player initialization. Inspection through the end of that method
|
||||
found no subsequent chat clearing.
|
||||
- `handleRespawn` begins at line 1102; line 1171 uses `firePlayerRespawn`.
|
||||
Dimension changes and respawn therefore do not use the login event.
|
||||
|
||||
The downloaded official `neoforge-21.1.250-sources.jar` confirms
|
||||
`ClientHooks.firePlayerLogin` posts `LoggingIn` at lines 722-723, while
|
||||
`firePlayerRespawn` posts `Clone` at lines 730-731. The
|
||||
`ClientPlayerNetworkEvent` source documents the main NeoForge event bus and
|
||||
logical-client side, and provides `getConnection()`.
|
||||
|
||||
Generated `ChatComponent.java`, lines 178-185, confirms `addMessage(Component)`
|
||||
adds a local GUI message through its display queues and local log; it does
|
||||
not call a network sender. The addon calls that HUD API directly.
|
||||
|
||||
Official NeoForge 1.21.1 documentation was also read through Context7 and
|
||||
the official site for `@Mod(dist = Dist.CLIENT)`, side isolation,
|
||||
`[[mixins]]`, and client-side dependency declarations. References and the
|
||||
exact metadata schema are in `README.md`.
|
||||
|
||||
## Scope and remaining runtime QA
|
||||
|
||||
Only `script/worldofsosal-client-info/**` was edited. No commits, production
|
||||
changes, server installation, publication, or pack metadata generation were
|
||||
performed.
|
||||
|
||||
No GUI runtime tests or automated unit tests were run. Gradle reports
|
||||
`test NO-SOURCE`; successful compilation is not gameplay evidence. Java and
|
||||
JSON editor diagnostics were unavailable because `jdtls` and `biome` are
|
||||
not installed; the actual Java compiler and resource packaging succeeded.
|
||||
|
||||
Main task owns the runtime acceptance plan in `README.md`: cold startup,
|
||||
pre-login rejection/disconnect title, one local network-login message,
|
||||
reconnection, no dimension/respawn duplication, no remote/server chat,
|
||||
missing/invalid metadata, and optional disposable dedicated-server no-op
|
||||
verification. The separate NeoForge bootstrap window before Minecraft is
|
||||
constructed is outside this Minecraft title hook.
|
||||
@@ -0,0 +1,117 @@
|
||||
# WorldOfSosal 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/worldofsosal-client-info-1.0.0.jar`: install in the client's `mods`.
|
||||
- `build/libs/worldofsosal-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/worldofsosal-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` |
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,35 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'net.neoforged.moddev' version '2.0.148'
|
||||
}
|
||||
|
||||
group = 'net.worldofsosal'
|
||||
version = '1.0.0'
|
||||
|
||||
base {
|
||||
archivesName = 'worldofsosal-client-info'
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
neoForge {
|
||||
version = '21.1.250'
|
||||
mods {
|
||||
worldofsosal_client_info {
|
||||
sourceSet(sourceSets.main)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = 21
|
||||
}
|
||||
|
||||
tasks.withType(AbstractArchiveTask).configureEach {
|
||||
preserveFileTimestamps = false
|
||||
reproducibleFileOrder = true
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.daemon=false
|
||||
org.gradle.workers.max=4
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
distributionSha256Sum=72f44c9f8ebcb1af43838f45ee5c4aa9c5444898b3468ab3f4af7b6076c5bc3f
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,8 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven { url = 'https://maven.neoforged.net/releases' }
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'worldofsosal-client-info'
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package net.worldofsosal.clientinfo;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.mojang.logging.LogUtils;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import net.neoforged.fml.loading.FMLPaths;
|
||||
|
||||
public record PackInfo(String name, String version, String minecraft, String neoforge) {
|
||||
private static final PackInfo UNKNOWN = new PackInfo("unknown pack", "unknown", "unknown", "unknown");
|
||||
|
||||
private static final class Loaded {
|
||||
private static final PackInfo INFO = read();
|
||||
}
|
||||
|
||||
public static PackInfo current() {
|
||||
return Loaded.INFO;
|
||||
}
|
||||
|
||||
private static PackInfo read() {
|
||||
Path path = FMLPaths.CONFIGDIR.get().resolve("worldofsosal-version.json");
|
||||
try (Reader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
|
||||
JsonReader jsonReader = new JsonReader(reader)) {
|
||||
JsonElement json = new Gson().getAdapter(JsonElement.class).read(jsonReader);
|
||||
if (jsonReader.peek() != JsonToken.END_DOCUMENT) {
|
||||
throw new JsonParseException("Metadata must contain one JSON object");
|
||||
}
|
||||
if (!json.isJsonObject()) {
|
||||
throw new JsonParseException("Metadata must be an object");
|
||||
}
|
||||
JsonObject object = json.getAsJsonObject();
|
||||
return new PackInfo(
|
||||
field(object, "name"), field(object, "version"),
|
||||
field(object, "minecraft"), field(object, "neoforge"));
|
||||
} catch (IOException | JsonParseException exception) {
|
||||
LogUtils.getLogger().warn("Pack metadata missing or invalid at {}; displaying unknown", path, exception);
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
private static String field(JsonObject object, String key) {
|
||||
JsonElement value = object.get(key);
|
||||
if (value == null || !value.isJsonPrimitive() || !value.getAsJsonPrimitive().isString()) {
|
||||
throw new JsonParseException("Metadata field must be a string: " + key);
|
||||
}
|
||||
String text = value.getAsString();
|
||||
if (text.isBlank() || text.codePoints().anyMatch(Character::isISOControl)) {
|
||||
throw new JsonParseException("Metadata field must be nonblank and single-line: " + key);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public String display() {
|
||||
return name + " " + version + " | Minecraft " + minecraft + " | NeoForge " + neoforge;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package net.worldofsosal.clientinfo;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
import net.neoforged.neoforge.client.event.ClientPlayerNetworkEvent;
|
||||
import net.neoforged.neoforge.common.NeoForge;
|
||||
|
||||
@Mod(value = "worldofsosal_client_info", dist = Dist.CLIENT)
|
||||
public final class WorldOfSosalClientInfo {
|
||||
public WorldOfSosalClientInfo() {
|
||||
NeoForge.EVENT_BUS.addListener(WorldOfSosalClientInfo::onLogin);
|
||||
}
|
||||
|
||||
private static void onLogin(ClientPlayerNetworkEvent.LoggingIn event) {
|
||||
if (!event.getConnection().isMemoryConnection()) {
|
||||
Minecraft.getInstance().gui.getChat().addMessage(
|
||||
Component.literal("CLIENT: " + PackInfo.current().display()));
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package net.worldofsosal.clientinfo.mixin;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.worldofsosal.clientinfo.PackInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public abstract class MinecraftTitleMixin {
|
||||
@Inject(method = "createTitle()Ljava/lang/String;", at = @At("RETURN"), cancellable = true)
|
||||
private void worldofsosalClientInfo$title(CallbackInfoReturnable<String> callback) {
|
||||
callback.setReturnValue(PackInfo.current().display() + " | " + callback.getReturnValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
modLoader="javafml"
|
||||
loaderVersion="[4,)"
|
||||
license="All Rights Reserved"
|
||||
|
||||
[[mods]]
|
||||
modId="worldofsosal_client_info"
|
||||
version="1.0.0"
|
||||
displayName="WorldOfSosal Client Info"
|
||||
description='''Local pack information in the window title and client chat.'''
|
||||
|
||||
[[mixins]]
|
||||
config="worldofsosal-client-info.mixins.json"
|
||||
|
||||
[[dependencies.worldofsosal_client_info]]
|
||||
modId="neoforge"
|
||||
type="required"
|
||||
versionRange="[21.1.250]"
|
||||
ordering="NONE"
|
||||
side="CLIENT"
|
||||
|
||||
[[dependencies.worldofsosal_client_info]]
|
||||
modId="minecraft"
|
||||
type="required"
|
||||
versionRange="[1.21.1]"
|
||||
ordering="NONE"
|
||||
side="CLIENT"
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "net.worldofsosal.clientinfo.mixin",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"client": [
|
||||
"MinecraftTitleMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user