From 324e6f75c825c5af1843bbe99fb5df4c82b245ce Mon Sep 17 00:00:00 2001 From: Arigadam Date: Sun, 11 Oct 2026 18:29:07 +0300 Subject: [PATCH] Add ComboCoal client-only Fabric mod for Minecraft 1.21.4 Mobile-game style coal grinding: combo counter and ranks, HUD with popups and confetti, XP/coins/daily quest, dancing client-side pets, Coal Maniac mode, coal ESP and guide arrow (off on multiplayer by default), tool durability warnings and an English lang file. Opt-in online features backed by the Flask server in backend/: leaderboard, shared team combo per server, Help pings and a Help servers list, protected by a one-time captcha token and a proof of work. Includes Docker/Caddy deployment files and Fabric client game tests (single player, team combo and a two-client scenario). Co-Authored-By: Claude Sonnet 5.5 --- .gitattributes | 4 + .gitignore | 8 + README.md | 175 ++++++++++ backend/.dockerignore | 3 + backend/Caddyfile | 4 + backend/Dockerfile | 12 + backend/app.py | 316 ++++++++++++++++++ backend/docker-compose.yml | 25 ++ backend/requirements.txt | 2 + build.gradle | 80 +++++ gradle.properties | 12 + gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 45633 bytes gradle/wrapper/gradle-wrapper.properties | 7 + gradlew | 248 ++++++++++++++ gradlew.bat | 93 ++++++ settings.gradle | 8 + .../gametest/ComboCoalClientGameTest.java | 147 ++++++++ .../gametest/ComboCoalMultiClientTest.java | 125 +++++++ .../combocoal/gametest/ComboCoalTeamTest.java | 106 ++++++ src/gametest/resources/fabric.mod.json | 13 + .../arigadam/combocoal/ComboCoalClient.java | 119 +++++++ .../wihuk/arigadam/combocoal/audio/Sfx.java | 49 +++ .../arigadam/combocoal/combo/CoalBlocks.java | 19 ++ .../combocoal/combo/ComboManager.java | 147 ++++++++ .../wihuk/arigadam/combocoal/combo/Rank.java | 39 +++ .../combocoal/config/ComboCoalConfig.java | 92 +++++ .../combocoal/config/ConfigScreen.java | 116 +++++++ .../wihuk/arigadam/combocoal/esp/CoalEsp.java | 126 +++++++ .../arigadam/combocoal/esp/CoalIndex.java | 247 ++++++++++++++ .../arigadam/combocoal/guide/GuideHud.java | 156 +++++++++ .../arigadam/combocoal/guide/GuideStep.java | 84 +++++ .../arigadam/combocoal/hud/Confetti.java | 72 ++++ .../arigadam/combocoal/hud/HudRenderer.java | 115 +++++++ .../arigadam/combocoal/hud/MobileUI.java | 91 +++++ .../wihuk/arigadam/combocoal/hud/Popups.java | 62 ++++ .../arigadam/combocoal/hud/QuestScreen.java | 88 +++++ .../arigadam/combocoal/maniac/ManiacMode.java | 47 +++ .../wihuk/arigadam/combocoal/pets/PetCat.java | 66 ++++ .../arigadam/combocoal/pets/PetWolf.java | 66 ++++ .../wihuk/arigadam/combocoal/pets/Pets.java | 164 +++++++++ .../arigadam/combocoal/progress/Progress.java | 58 ++++ .../arigadam/combocoal/progress/Quest.java | 63 ++++ .../arigadam/combocoal/progress/SaveData.java | 53 +++ .../combocoal/stats/CaptchaScreen.java | 100 ++++++ .../combocoal/stats/ConsentScreen.java | 77 +++++ .../combocoal/stats/HelpServersScreen.java | 109 ++++++ .../combocoal/stats/LeaderboardScreen.java | 80 +++++ .../arigadam/combocoal/stats/StatsApi.java | 147 ++++++++ .../arigadam/combocoal/stats/StatsClient.java | 132 ++++++++ .../arigadam/combocoal/stats/TeamCombo.java | 101 ++++++ .../combocoal/tools/DurabilityWatcher.java | 91 +++++ .../assets/combocoal/lang/en_us.json | 112 +++++++ src/main/resources/fabric.mod.json | 19 ++ 53 files changed, 4495 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.md create mode 100644 backend/.dockerignore create mode 100644 backend/Caddyfile create mode 100644 backend/Dockerfile create mode 100644 backend/app.py create mode 100644 backend/docker-compose.yml create mode 100644 backend/requirements.txt create mode 100644 build.gradle create mode 100644 gradle.properties create mode 100644 gradle/wrapper/gradle-wrapper.jar create mode 100644 gradle/wrapper/gradle-wrapper.properties create mode 100644 gradlew create mode 100644 gradlew.bat create mode 100644 settings.gradle create mode 100644 src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalClientGameTest.java create mode 100644 src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalMultiClientTest.java create mode 100644 src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalTeamTest.java create mode 100644 src/gametest/resources/fabric.mod.json create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/ComboCoalClient.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/audio/Sfx.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/combo/CoalBlocks.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/combo/ComboManager.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/combo/Rank.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/config/ComboCoalConfig.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/config/ConfigScreen.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalEsp.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalIndex.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideHud.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideStep.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/hud/Confetti.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/hud/HudRenderer.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/hud/MobileUI.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/hud/Popups.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/hud/QuestScreen.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/maniac/ManiacMode.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/pets/PetCat.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/pets/PetWolf.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/pets/Pets.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/progress/Progress.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/progress/Quest.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/progress/SaveData.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/stats/CaptchaScreen.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/stats/ConsentScreen.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/stats/HelpServersScreen.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/stats/LeaderboardScreen.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsApi.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsClient.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/stats/TeamCombo.java create mode 100644 src/main/java/pro/wihuk/arigadam/combocoal/tools/DurabilityWatcher.java create mode 100644 src/main/resources/assets/combocoal/lang/en_us.json create mode 100644 src/main/resources/fabric.mod.json diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..11aed02 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +* text=auto +gradlew text eol=lf +*.bat text eol=crlf +*.jar binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aabcf6c --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.gradle/ +build/ +run/ +.idea/ +*.iml +__pycache__/ +secret.key +*.db diff --git a/README.md b/README.md new file mode 100644 index 0000000..d2b5c15 --- /dev/null +++ b/README.md @@ -0,0 +1,175 @@ +# ComboCoal + +A just-for-fun, **client-only** Fabric mod for Minecraft **1.21.4** that turns coal mining into a +mobile-game grind: a fullscreen combo counter, ranks, popups, confetti, XP, coins, a daily quest, +dancing client-side pets, a step-by-step coal guide with an arrow, and tool-durability warnings. + +Needs only Fabric Loader (0.16+) and Fabric API. Nothing has to be installed on the server. + +> ## Warning: ESP features can get you banned +> +> The **Coal ESP** (highlights coal through walls) and the **coal arrow** (points to the nearest +> coal) are x-ray style helpers. Most multiplayer servers forbid them, and using them can get you +> **banned**. Both are therefore: +> +> * **on by default only in singleplayer**, +> * **off on multiplayer** unless you explicitly set `allowEspOnMultiplayer` / `allowArrowOnMultiplayer` +> to `true`. A warning is printed in chat once per launch when they are active on a server. +> +> Check the rules of the server before enabling them. You are responsible for what you enable. + +## Features + +* **Combo**: +1 for every coal ore broken (coal and deepslate coal). Resets after 5 seconds without coal. +* **Ranks**: C (0+) COAL!, B (10+) NICE VEIN!, A (20+) COAL-ASSAULT!, S (30+) UNSTOPPABLE!, + SSS (50+) COAL MANIAC!!! (rainbow text). Rank-ups fire a sound, confetti and a "RANK UP!" popup. +* **Mobile-style HUD**: elastic combo number, rank label, timer bar, floating popups, confetti, + optional HUD-only screen shake from x25, top bar with level, XP bar and coins. +* **Progress**: XP per coal = 10 + combo, coins = 1 + combo / 10, level threshold = level x 100. + Saved to `config/combocoal_save.json`. +* **Daily quest** ("Mine 50 coal", key `K`): earned by playing, with a pulsing CLAIM! button. + No paid chests, no timers, no monetization tricks. +* **Pets**: one per 5 combo (max 12), alternating wolves and cats with different collars. They orbit + you, hop at 120 BPM and toggle sit/stand on the beat. They exist only in your own client + (never sent to or known by the server), have no AI, collision, sounds or interaction, and are + removed on combo loss, world leave and disconnect. +* **Coal Maniac mode** (off by default): refuses to break ores that are not coal, with the message + "You swore an oath to coal!". Stone, dirt and wood stay breakable. **Strict mode** blocks + everything except coal and logs. +* **Coal ESP**: highlights coal within a radius, brighter for bigger veins, the biggest vein pulses. + Chunks are scanned incrementally and cached, so it is cheap. +* **Coal guide** (key `G`): logs, crafting table, wooden pickaxe, stone pickaxe, find coal, mine the + vein, craft torches. Steps are detected from your inventory. During "find coal" a rotating arrow + and the distance to the nearest coal are shown. +* **Durability warning**: a flashing warning and alarm when the held tool is below 10%. Repairing it + gives a small combo bonus popup. +* **Optional online features** (all opt-in, off by default, see below): leaderboard, a shared **team + combo** for players on the same server, **"Help!" pings** and a **Help servers** list in the + multiplayer screen. + +## Install + +1. Install [Fabric Loader](https://fabricmc.net/use/) for Minecraft 1.21.4. +2. Put [Fabric API](https://modrinth.com/mod/fabric-api) for 1.21.4 into your `mods` folder. +3. Put `combocoal-1.0.0.jar` into the `mods` folder. + +## Build from source + +Requires JDK 21. + +``` +./gradlew build # jar ends up in build/libs/ +./gradlew runClient # dev client +./gradlew runClientGameTest # automated end-to-end test (opens a window for about a minute) +``` + +## Keys + +| Key | Action | +|-----|--------------------------| +| `G` | Show / hide coal guide | +| `K` | Open daily quest | +| `O` | Open ComboCoal settings | + +All keys can be rebound in the controls menu under the *ComboCoal* category. + +## Config + +Edit in game (`O`) or in `config/combocoal.json`: + +| Option | Default | Meaning | +|----------------------------|---------|---------| +| `hapticShake` | `true` | HUD shakes from combo x25 | +| `maniacMode` | `false` | Refuse to break non-coal ores | +| `strictMode` | `false` | With maniac mode: only coal and logs are breakable | +| `esp` | `true` | Coal ESP (singleplayer only, see below) | +| `allowEspOnMultiplayer` | `false` | Allow the ESP on multiplayer servers (**ban risk**) | +| `espRadius` | `32` | ESP and arrow search radius in blocks (8 to 64) | +| `arrow` | `true` | Guide arrow to nearest coal | +| `allowArrowOnMultiplayer` | `false` | Allow the arrow on multiplayer servers (**ban risk**) | +| `pets` | `true` | Dancing pets | +| `sounds` | `true` | Mod sounds (vanilla sounds only) | +| `statsOptIn` | `false` | Enable the online features (stats, team combo, help pings) | +| `statsEndpoint` | `"https://master.combocoal.wihuk.pro"` | https base URL of the stats server | +| `statsConsentShown` | `false` | Set once the first-launch consent screen was answered | +| `statsToken` | `""` | Captcha token, filled in automatically | +| `hudScale` | `1.0` | HUD size, 0.5 to 2.0 | + +The ESP and arrow are active when `esp` / `arrow` is `true` **and** you are in singleplayer, or the +matching `allow...OnMultiplayer` flag is `true`. + +## Online features (opt-in) + +Everything below needs a stats server (see *Example backend*) and is **off by default**. On the first +launch a consent screen explains exactly what is sent. "No thanks" (or closing the screen) keeps +everything off. Nothing is sent unless `statsOptIn` is `true`, `statsEndpoint` is an `https://` URL +**and** you solved the one-time captcha (the consent screen leads you there; later via the settings +button *Verify (captcha)*). + +What is sent, always asynchronously with a 5 second timeout (the game never waits for the network): + +| Feature | When | Data | +|---------|------|------| +| Stats / leaderboard | leaving a world, closing the game, every 5 minutes if coal changed | player name, coal this session, best combo, server address | +| Team combo | about once per second on a multiplayer server | player name, server address, coal broken since the last sync | +| "Help!" ping | multiplayer, pickaxe below 10% durability at combo 20+, at most every 5 minutes | player name, server address, combo | + +Nothing else is sent. The mod never puts your IP address into the data; as with any web request the +receiving server can see it. + +**Team combo.** Players on the same server address who opted in share one combo. Every coal any of them +breaks raises it, and it ends after 5 seconds without a hit from anyone. Your own XP and coins still only +come from coal you break yourself. The HUD shows "TEAM: N players". If the server stops answering, the +mod falls back to your normal personal combo after a few seconds. + +**Help servers.** The multiplayer screen has a *Help servers* button listing servers (marked `[HELP]`) +where players asked for help in the last 10 minutes, with a *Join* button. + +**Captcha and proof of work.** The captcha (a small sum) is solved once and gives a signed token valid for +30 days. Every upload also includes a proof of work (the server sends a challenge and the mod finds a +nonce whose SHA-256 hash has enough leading zero bits; a fraction of a second for stats and help, much +less for the team sync). Both are simple on purpose: they stop casual scripts, not a determined cheater. + +### Example backend + +`backend/app.py` is a small Flask + SQLite server for all of the above: + +``` +cd backend +pip install -r requirements.txt +python app.py # http://127.0.0.1:5000 for local testing +``` + +Endpoints: `GET /captcha`, `POST /captcha`, `GET /pow` (`?scope=team` for the easier team challenge), +`POST /stats`, `GET /leaderboard`, `POST /help`, `GET /help`, `POST /team/sync`. The secret that signs +tokens is read from `COMBOCOAL_SECRET` or created in `backend/secret.key` (shared by all workers). +All state (stats, team combo, used proof-of-work challenges) is stored in SQLite, so the server can run with any +number of worker processes. `backend/Dockerfile`, `docker-compose.yml` and `Caddyfile` are a ready deployment +with automatic HTTPS (edit the domain in the `Caddyfile`). + +The mod only talks https, so put it behind a TLS reverse proxy for real use (or set `COMBOCOAL_TLS_CERT` +and `COMBOCOAL_TLS_KEY` to PEM files to let `app.py` serve https itself for development). Stats are +self-reported; do not treat the leaderboard as trustworthy. + +### Testing against a local backend + +`./gradlew runClientGameTest -PtestTrustStore= -PtestEndpoint=https://localhost:5443` +runs the full online scenario (captcha, team combo with a simulated teammate on a dedicated server, +help ping, stats upload). The truststore must contain your test certificate (password `changeit`). + +For two real clients on one external server, start `./gradlew runServer` (offline mode, ops `CoalA` and +`CoalB`) and run two instances of +`./gradlew runClientGameTest -PtestTrustStore=... -PtestEndpoint=... -PtestServer=localhost:25570 -PtestUsername=CoalA -PtestRunDir=build/run/clientA` +(and the same with `CoalB` / `clientB`). Both must end with the stacked combo of 12. + +## Translations + +All visible text goes through translation keys in +`src/main/resources/assets/combocoal/lang/en_us.json`. To add a language, copy that file to e.g. +`de_de.json` in the same folder and translate the values. + +## Notes + +* Mod Menu integration is not included (the mod depends on Fabric API only); use the `O` key. +* Hats for pets are not implemented in v1. +* The mod is client-only: `"environment": "client"`. diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000..350cbe9 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,3 @@ +*.db +secret.key +__pycache__ diff --git a/backend/Caddyfile b/backend/Caddyfile new file mode 100644 index 0000000..5ffedbf --- /dev/null +++ b/backend/Caddyfile @@ -0,0 +1,4 @@ +# Caddy obtains and renews the HTTPS certificate for this domain automatically. +master.combocoal.wihuk.pro { + reverse_proxy api:8000 +} diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..0594b76 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.12-slim +WORKDIR /app +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY app.py . +ENV COMBOCOAL_DB=/data/combocoal.db \ + COMBOCOAL_SECRET_FILE=/data/secret.key \ + COMBOCOAL_BEHIND_PROXY=1 +VOLUME /data +EXPOSE 8000 +# All shared state (team combo, used proof-of-work challenges) lives in SQLite, so more workers are fine. +CMD ["gunicorn", "--workers", "2", "--threads", "8", "--bind", "0.0.0.0:8000", "app:app"] diff --git a/backend/app.py b/backend/app.py new file mode 100644 index 0000000..03bff8e --- /dev/null +++ b/backend/app.py @@ -0,0 +1,316 @@ +"""Example backend for the optional ComboCoal stats, leaderboard and "Help!" modules. + +Public endpoints: + GET /leaderboard top 10 players + GET /help servers where players recently asked for help + GET /captcha a small human challenge {"id", "question"} + POST /captcha {"id", "answer"} -> {"token"} (valid for 30 days) + GET /pow a proof-of-work challenge {"challenge", "difficulty"}; ?scope=team gives an easier one + +Protected endpoints (headers X-Token, X-Pow-Challenge, X-Pow-Nonce): + POST /stats {"player", "coal", "bestCombo", "server"} + POST /help {"player", "server", "combo"} + POST /team/sync {"player", "server", "hits"} (team scope proof of work) -> {"combo", "players"} + +Team combo: players on the same server address who opted in share one combo. Every sync reports the +coal they broke since the last sync; the combo resets after 5 seconds without a hit from anyone. + +Proof of work: find a nonce so that sha256(challenge + ":" + nonce) starts with `difficulty` +zero bits. The captcha stops casual scripts from getting a token, the proof of work makes mass +submissions expensive. Both are simple on purpose; stats stay self-reported. Run behind HTTPS. +""" +import base64 +import hashlib +import hmac +import json +import os +import secrets +import sqlite3 +import time +from contextlib import closing + +from flask import Flask, jsonify, request + +app = Flask(__name__) +# Behind a reverse proxy (Caddy) the real client address comes from X-Forwarded-For. +if os.environ.get("COMBOCOAL_BEHIND_PROXY"): + from werkzeug.middleware.proxy_fix import ProxyFix + app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1) +DB_PATH = os.environ.get("COMBOCOAL_DB", "combocoal.db") +SECRET_PATH = os.environ.get("COMBOCOAL_SECRET_FILE", "secret.key") +POW_DIFFICULTY = 18 +TEAM_POW_DIFFICULTY = 12 +TEAM_WINDOW = 5.0 +TEAM_PLAYER_TTL = 10.0 +MAX_TEAM_HITS = 20 +POW_TTL = 120 +TOKEN_TTL = 30 * 24 * 3600 +CAPTCHA_TTL = 300 +HELP_WINDOW = 600 +MAX_NAME = 16 +MAX_SERVER = 255 +MAX_VALUE = 10_000_000 + +CAPTCHA_ATTEMPTS = {} + + +def load_secret(): + env = os.environ.get("COMBOCOAL_SECRET") + if env: + return env.encode() + if not os.path.exists(SECRET_PATH): + # Several worker processes may start at once: write a temp file and link it into place + # atomically so exactly one key wins and nobody reads a half-written file. + tmp = f"{SECRET_PATH}.{os.getpid()}.tmp" + with open(tmp, "wb") as f: + f.write(secrets.token_bytes(32)) + try: + os.link(tmp, SECRET_PATH) + except FileExistsError: + pass + finally: + os.remove(tmp) + with open(SECRET_PATH, "rb") as f: + return f.read() + + +SECRET = load_secret() + + +def sign(data): + body = base64.urlsafe_b64encode(json.dumps(data).encode()).decode() + mac = hmac.new(SECRET, body.encode(), hashlib.sha256).hexdigest() + return body + "." + mac + + +def unsign(value): + """Returns the signed payload, or None if it is malformed, forged or expired.""" + try: + body, mac = value.rsplit(".", 1) + expected = hmac.new(SECRET, body.encode(), hashlib.sha256).hexdigest() + if not hmac.compare_digest(mac, expected): + return None + data = json.loads(base64.urlsafe_b64decode(body.encode())) + return data if data["exp"] > time.time() else None + except (ValueError, KeyError, TypeError): + return None + + +def db(): + conn = sqlite3.connect(DB_PATH) + conn.row_factory = sqlite3.Row + return conn + + +def init_db(): + with closing(db()) as conn, conn: + conn.execute( + """CREATE TABLE IF NOT EXISTS stats ( + player TEXT PRIMARY KEY, coal INTEGER NOT NULL, best_combo INTEGER NOT NULL, + server TEXT NOT NULL, updated TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP)""" + ) + conn.execute("PRAGMA journal_mode=WAL") + conn.execute("CREATE TABLE IF NOT EXISTS used_pow (challenge TEXT PRIMARY KEY, exp REAL NOT NULL)") + conn.execute("CREATE TABLE IF NOT EXISTS team (server TEXT PRIMARY KEY, combo INTEGER NOT NULL, last REAL NOT NULL)") + conn.execute( + """CREATE TABLE IF NOT EXISTS team_players ( + server TEXT NOT NULL, player TEXT NOT NULL, ts REAL NOT NULL, PRIMARY KEY (server, player))""" + ) + conn.execute( + """CREATE TABLE IF NOT EXISTS help ( + player TEXT NOT NULL, server TEXT NOT NULL, combo INTEGER NOT NULL, ts INTEGER NOT NULL)""" + ) + + +def clamp_int(value): + return max(0, min(MAX_VALUE, int(value))) + + +def leading_zero_bits(digest): + bits = 0 + for byte in digest: + if byte == 0: + bits += 8 + continue + bits += 8 - byte.bit_length() + break + return bits + + +def require_pow(scope="default"): + """Checks token and proof of work. Returns an error response, or None if everything is valid.""" + token = unsign(request.headers.get("X-Token", "")) + if not token or token.get("kind") != "token": + return jsonify(error="captcha token missing or expired"), 401 + challenge = request.headers.get("X-Pow-Challenge", "") + nonce = request.headers.get("X-Pow-Nonce", "") + data = unsign(challenge) + if not data or data.get("kind") != "pow" or data.get("scope") != scope: + return jsonify(error="invalid proof of work challenge"), 400 + digest = hashlib.sha256(f"{challenge}:{nonce}".encode()).digest() + if leading_zero_bits(digest) < data["d"]: + return jsonify(error="proof of work too weak"), 400 + # Single use, tracked in the database so every worker process sees the same set. + with closing(db()) as conn, conn: + conn.execute("DELETE FROM used_pow WHERE exp < ?", (time.time(),)) + try: + conn.execute("INSERT INTO used_pow (challenge, exp) VALUES (?, ?)", (challenge, data["exp"])) + except sqlite3.IntegrityError: + return jsonify(error="invalid proof of work challenge"), 400 + return None + + +@app.get("/pow") +def get_pow(): + scope = "team" if request.args.get("scope") == "team" else "default" + difficulty = TEAM_POW_DIFFICULTY if scope == "team" else POW_DIFFICULTY + challenge = sign({"kind": "pow", "scope": scope, "d": difficulty, "r": secrets.token_hex(8), + "exp": time.time() + POW_TTL}) + return jsonify(challenge=challenge, difficulty=difficulty) + + +@app.get("/captcha") +def get_captcha(): + a, b = secrets.randbelow(20) + 1, secrets.randbelow(20) + 1 + ident = sign({"kind": "captcha", "sum": a + b, "r": secrets.token_hex(4), "exp": time.time() + CAPTCHA_TTL}) + return jsonify(id=ident, question=f"{a} + {b}") + + +@app.post("/captcha") +def post_captcha(): + # Crude per-address limit so the captcha cannot be brute forced. + now = time.time() + recent = [t for t in CAPTCHA_ATTEMPTS.get(request.remote_addr, []) if t > now - 60] + if len(recent) >= 10: + return jsonify(error="too many attempts"), 429 + CAPTCHA_ATTEMPTS[request.remote_addr] = recent + [now] + + body = request.get_json(silent=True) or {} + data = unsign(str(body.get("id", ""))) + try: + correct = data and data.get("kind") == "captcha" and int(body.get("answer")) == data["sum"] + except (TypeError, ValueError): + correct = False + if not correct: + return jsonify(error="wrong answer"), 400 + return jsonify(token=sign({"kind": "token", "n": secrets.token_hex(8), "exp": now + TOKEN_TTL})) + + +@app.post("/stats") +def post_stats(): + error = require_pow() + if error: + return error + data = request.get_json(silent=True) or {} + try: + player = str(data["player"]).strip()[:MAX_NAME] + coal = clamp_int(data["coal"]) + best_combo = clamp_int(data["bestCombo"]) + server = str(data.get("server", ""))[:MAX_SERVER] + except (KeyError, TypeError, ValueError): + return jsonify(error="bad request"), 400 + if not player: + return jsonify(error="bad request"), 400 + + # The mod reports one session, so keep the best values instead of adding them up. + with closing(db()) as conn, conn: + conn.execute( + """INSERT INTO stats (player, coal, best_combo, server) VALUES (?, ?, ?, ?) + ON CONFLICT(player) DO UPDATE SET + coal = MAX(coal, excluded.coal), best_combo = MAX(best_combo, excluded.best_combo), + server = excluded.server, updated = CURRENT_TIMESTAMP""", + (player, coal, best_combo, server), + ) + return jsonify(ok=True) + + +@app.get("/leaderboard") +def get_leaderboard(): + with closing(db()) as conn: + rows = conn.execute( + "SELECT player, coal, best_combo FROM stats ORDER BY coal DESC, best_combo DESC LIMIT 10" + ).fetchall() + return jsonify([{"player": r["player"], "coal": r["coal"], "bestCombo": r["best_combo"]} for r in rows]) + + +@app.post("/help") +def post_help(): + error = require_pow() + if error: + return error + data = request.get_json(silent=True) or {} + try: + player = str(data["player"]).strip()[:MAX_NAME] + server = str(data["server"]).strip()[:MAX_SERVER] + combo = clamp_int(data["combo"]) + except (KeyError, TypeError, ValueError): + return jsonify(error="bad request"), 400 + if not player or not server or server == "singleplayer": + return jsonify(error="bad request"), 400 + with closing(db()) as conn, conn: + conn.execute("INSERT INTO help (player, server, combo, ts) VALUES (?, ?, ?, ?)", + (player, server, combo, int(time.time()))) + return jsonify(ok=True) + + +@app.get("/help") +def get_help(): + since = int(time.time()) - HELP_WINDOW + with closing(db()) as conn: + rows = conn.execute( + """SELECT server, COUNT(DISTINCT player) AS helpers, MAX(combo) AS combo + FROM help WHERE ts > ? GROUP BY server ORDER BY helpers DESC, combo DESC LIMIT 20""", + (since,), + ).fetchall() + return jsonify([{"server": r["server"], "helpers": r["helpers"], "combo": r["combo"]} for r in rows]) + + +@app.post("/team/sync") +def team_sync(): + error = require_pow("team") + if error: + return error + data = request.get_json(silent=True) or {} + try: + player = str(data["player"]).strip()[:MAX_NAME] + server = str(data["server"]).strip().lower()[:MAX_SERVER] + hits = max(0, min(MAX_TEAM_HITS, int(data["hits"]))) + except (KeyError, TypeError, ValueError): + return jsonify(error="bad request"), 400 + if not player or not server or server == "singleplayer": + return jsonify(error="bad request"), 400 + + now = time.time() + conn = db() + conn.isolation_level = None # explicit transaction so concurrent workers cannot interleave + try: + conn.execute("BEGIN IMMEDIATE") + conn.execute("DELETE FROM team WHERE last < ?", (now - 3600,)) + row = conn.execute("SELECT combo, last FROM team WHERE server = ?", (server,)).fetchone() + combo, last = (row["combo"], row["last"]) if row else (0, 0.0) + if now - last > TEAM_WINDOW: + combo = 0 + if hits: + combo += hits + last = now + conn.execute("INSERT INTO team (server, combo, last) VALUES (?, ?, ?) " + "ON CONFLICT(server) DO UPDATE SET combo = excluded.combo, last = excluded.last", + (server, combo, last)) + conn.execute("INSERT INTO team_players (server, player, ts) VALUES (?, ?, ?) " + "ON CONFLICT(server, player) DO UPDATE SET ts = excluded.ts", (server, player, now)) + conn.execute("DELETE FROM team_players WHERE ts < ?", (now - TEAM_PLAYER_TTL,)) + players = conn.execute("SELECT COUNT(*) FROM team_players WHERE server = ?", (server,)).fetchone()[0] + conn.execute("COMMIT") + finally: + conn.close() + return jsonify(combo=combo, players=players) + + +init_db() + +if __name__ == "__main__": + # Local testing only; use a proper WSGI server and HTTPS in production. + # Set COMBOCOAL_TLS_CERT and COMBOCOAL_TLS_KEY (PEM files) to serve https directly for development. + cert, key = os.environ.get("COMBOCOAL_TLS_CERT"), os.environ.get("COMBOCOAL_TLS_KEY") + app.run(host="127.0.0.1", port=int(os.environ.get("PORT", "5000")), + ssl_context=(cert, key) if cert and key else None) diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml new file mode 100644 index 0000000..32b3364 --- /dev/null +++ b/backend/docker-compose.yml @@ -0,0 +1,25 @@ +services: + api: + build: . + restart: unless-stopped + environment: + # Optional: set a fixed signing secret instead of the generated /data/secret.key + - COMBOCOAL_SECRET=${COMBOCOAL_SECRET:-} + volumes: + - combocoal-data:/data + + caddy: + image: caddy:2 + restart: unless-stopped + ports: + - "80:80" + - "443:443" + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile:ro + - caddy-data:/data + depends_on: + - api + +volumes: + combocoal-data: + caddy-data: diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..59710ed --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,2 @@ +flask>=3.0 +gunicorn>=22.0 diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..535024f --- /dev/null +++ b/build.gradle @@ -0,0 +1,80 @@ +plugins { + id 'fabric-loom' version '1.10.5' +} + +version = project.mod_version +group = project.maven_group + +base { + archivesName = project.archives_base_name +} + +repositories { +} + +dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" +} + +processResources { + inputs.property "version", project.version + filesMatching("fabric.mod.json") { + expand "version": inputs.properties.version + } +} + +tasks.withType(JavaCompile).configureEach { + it.options.release = 21 + it.options.encoding = "UTF-8" +} + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + withSourcesJar() +} + +// End-to-end client test: ./gradlew runClientGameTest +fabricApi { + configureTests { + createSourceSet = true + modId = "combocoal-gametest" + enableGameTests = false + enableClientGameTests = true + eula = true + } +} + +// Optional: trust a self-signed test certificate for the game test (-PtestTrustStore=path/to/trust.p12). +if (project.hasProperty("testTrustStore")) { + loom.runs.configureEach { + if (name == "clientGameTest") { + vmArg "-Djavax.net.ssl.trustStore=${project.property('testTrustStore')}" + vmArg "-Djavax.net.ssl.trustStorePassword=changeit" + } + } +} + +// Optional: point the game test at a running stats backend (-PtestEndpoint=https://localhost:5443). +if (project.hasProperty("testEndpoint")) { + loom.runs.configureEach { + if (name == "clientGameTest") { + vmArg "-Dcombocoal.testEndpoint=${project.property('testEndpoint')}" + } + } +} + +// Optional two-client test: join an external server with a given username and run directory. +if (project.hasProperty("testServer")) { + loom.runs.configureEach { + if (name == "clientGameTest") { + vmArg "-Dcombocoal.testServer=${project.property('testServer')}" + vmArg "-Dfabric.client.gametest.disableNetworkSynchronizer=true" + programArgs "--username", project.property("testUsername") + runDir project.property("testRunDir") + } + } +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..02e4028 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,12 @@ +org.gradle.jvmargs=-Xmx2G +org.gradle.parallel=true + +minecraft_version=1.21.4 +yarn_mappings=1.21.4+build.8 +loader_version=0.16.14 + +mod_version=1.0.0 +maven_group=pro.wihuk.arigadam +archives_base_name=combocoal + +fabric_version=0.119.4+1.21.4 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..f8e1ee3125fe0768e9a76ee977ac089eb657005e GIT binary patch literal 45633 zcma&NV|1n6wyqu9PQ|uu+csuwn-$x(T~Woh?Nr6KUD3(A)@l1Yd+oj6Z_U=8`RAE` z#vE6_`?!1WLs1443=Ieh3JM4ai0JG2|2{}S&_HrxszP*9^5P7#QX*pVDq?D?;6T8C z{bWO1$9at%!*8ax*TT&F99vwf1Ls+3lklsb|bC`H`~Q z_w}*E9P=Wq;PYlGYhZ^lt#N97b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}|C`2gXh8EhWP1bTgZ)DqHZ&-x|E2*6Ka!RZ zS5jsHN&IW7%g1yUln@bn$cO!hR2b+`P~1-3dFIx!6EltRa{a z6Z@Y$_ug)~d%u)K$+?LYfc<87}bupdiK(3|m%hiA$Pc>zKNP0hqBj{X*L0rm@j(0s(f>>t{1L0?w#rS+#E)IdBKcF5|Dq-S zZ*-X3x;NeSuOSxS<3Q%uy1zwQ+?Kj&)Ou~-|2+&J{Zi^T=lx9+&+B^K_lQ;hY2H6D zeZ9T!H&;?$+kt+MLCs%i{8QEVi8<(Pft!mFt`}r~k5Y%93jAjQ!fgoD?Zh|Vi~q5A z27G^+_!lc1Zfo3}625-J{(B@p`IW|R4(!c|yX*Pn?*SA0)3iUGUB11uH>ab1{F$$g z|7q4=O#$9cezU54J)`wKI1_%J{14{0Zj0P3wEcKU`%-=?@(1PW+Zs0qGuI`%??IID dD~*3C;60WFKt@K_BOwYX49GZ$DDV2e{|AYb(KrAA literal 0 HcmV?d00001 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..e18bc25 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..adff685 --- /dev/null +++ b/gradlew @@ -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='"-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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..c4bdd3a --- /dev/null +++ b/gradlew.bat @@ -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="-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 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..ea68b05 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,8 @@ +pluginManagement { + repositories { + maven { name = 'Fabric'; url = 'https://maven.fabricmc.net/' } + mavenCentral() + gradlePluginPortal() + } +} +rootProject.name = 'combocoal' diff --git a/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalClientGameTest.java b/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalClientGameTest.java new file mode 100644 index 0000000..213973b --- /dev/null +++ b/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalClientGameTest.java @@ -0,0 +1,147 @@ +package pro.wihuk.arigadam.combocoal.gametest; + +import net.fabricmc.fabric.api.client.gametest.v1.FabricClientGameTest; +import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext; +import net.fabricmc.fabric.api.client.gametest.v1.context.TestServerContext; +import net.fabricmc.fabric.api.client.gametest.v1.context.TestSingleplayerContext; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.registry.Registries; +import net.minecraft.util.math.BlockPos; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; +import pro.wihuk.arigadam.combocoal.config.ConfigScreen; +import pro.wihuk.arigadam.combocoal.stats.CaptchaScreen; +import pro.wihuk.arigadam.combocoal.stats.HelpServersScreen; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.pets.PetCat; +import pro.wihuk.arigadam.combocoal.pets.PetWolf; + +/** Mines real coal ore in a creative world and checks combo, HUD, pets and cleanup end to end. */ +public class ComboCoalClientGameTest implements FabricClientGameTest { + private static final String BLOCK_POS = "0 -59 2"; + + @Override + public void runTest(ClientGameTestContext context) { + // Answer the first-launch consent screen with "No thanks". + context.waitFor(client -> client.currentScreen != null); + context.takeScreenshot("00_consent"); + context.clickScreenButton("combocoal.stats.consent.no"); + + // The new screens must open (without an endpoint they just explain that stats are off). + context.setScreen(() -> new HelpServersScreen(null)); + context.waitTicks(5); + context.takeScreenshot("00a_help_servers"); + context.setScreen(() -> new CaptchaScreen(null)); + context.waitTicks(5); + context.takeScreenshot("00a_captcha"); + context.setScreen(() -> new ConfigScreen(null)); + context.waitTicks(5); + context.takeScreenshot("00a_config"); + context.setScreen(() -> null); + + String externalServer = System.getProperty("combocoal.testServer"); + if (externalServer != null) { + // Two-client mode: join a dedicated server started outside the test. + ComboCoalMultiClientTest.run(context, System.getProperty("combocoal.testEndpoint"), externalServer); + return; + } + + try (TestSingleplayerContext world = context.worldBuilder().create()) { + world.getClientWorld().waitForChunksRender(); + world.getServer().runCommand("gamemode creative @p"); + world.getServer().runCommand("tp @p 0.5 -60 0.5 0 0"); + context.waitTicks(10); + + // A coal vein hidden inside stone: the ESP should show it through the wall and the guide arrow should point to it. + world.getServer().runCommand("give @p minecraft:stone_pickaxe"); + world.getServer().runCommand("fill 5 -61 12 9 -57 16 minecraft:stone"); + world.getServer().runCommand("fill 6 -60 13 7 -59 14 minecraft:coal_ore"); + context.waitTicks(330); + context.takeScreenshot("00b_esp_and_arrow"); + + + mineCoal(context, world.getServer(), 12); + context.takeScreenshot("01_combo12"); + check(ComboManager.combo() == 12, "combo should be 12 but is " + ComboManager.combo()); + check(countPets(context) == 2, "expected 2 pets at combo 12, got " + countPets(context)); + + mineCoal(context, world.getServer(), 40); + context.takeScreenshot("02_combo52_sss"); + check(ComboManager.combo() == 52, "combo should be 52 but is " + ComboManager.combo()); + check(countPets(context) == 10, "expected 10 pets at combo 52, got " + countPets(context)); + int serverPets = world.getServer().computeOnServer(server -> countServerPets(server.getOverworld().iterateEntities())); + check(serverPets == 0, "pets must not exist on the server, found " + serverPets); + + // The combo window is 100 ticks; after that every pet must be gone. + context.waitTicks(115); + context.takeScreenshot("03_combo_lost"); + check(ComboManager.combo() == 0, "combo should have expired"); + check(countPets(context) == 0, "pets should poof when the combo is lost"); + + mineCoal(context, world.getServer(), 6); + check(countPets(context) == 1, "expected 1 pet at combo 6"); + + // Maniac mode: iron ore is protected, stone and coal stay breakable. + ComboCoalConfig.get().maniacMode = true; + check(tryBreak(context, world, "minecraft:iron_ore").equals("minecraft:iron_ore"), "iron ore must be protected in maniac mode"); + check(tryBreak(context, world, "minecraft:stone").equals("minecraft:air"), "stone must stay breakable in maniac mode"); + check(tryBreak(context, world, "minecraft:coal_ore").equals("minecraft:air"), "coal ore must stay breakable in maniac mode"); + ComboCoalConfig.get().maniacMode = false; + } + // Leaving the world must clean up the remaining pet. + context.waitTicks(5); + check(ComboManager.combo() == 0, "combo should reset on world leave"); + + String endpoint = System.getProperty("combocoal.testEndpoint"); + if (endpoint != null) { + ComboCoalTeamTest.run(context, endpoint); + } + } + + static void mineCoal(ClientGameTestContext context, TestServerContext server, int count) { + for (int i = 0; i < count; i++) { + server.runCommand("setblock " + BLOCK_POS + " minecraft:coal_ore"); + context.waitTicks(2); + // Creative breaks instantly on the first attack tick; the delay avoids double clicks. + context.getInput().holdMouseFor(0, 2); + context.waitTicks(4); + } + } + + /** Places the block in front of the player, attacks it, and returns the id of what is there afterwards. */ + private static String tryBreak(ClientGameTestContext context, TestSingleplayerContext world, String block) { + world.getServer().runCommand("setblock " + BLOCK_POS + " " + block); + context.waitTicks(2); + context.getInput().holdMouseFor(0, 2); + context.waitTicks(8); + return context.computeOnClient(client -> Registries.BLOCK.getId(client.world.getBlockState(new BlockPos(0, -59, 2)).getBlock()).toString()); + } + + static int countPets(ClientGameTestContext context) { + return context.computeOnClient(client -> { + int pets = 0; + for (Entity entity : client.world.getEntities()) { + if (entity instanceof PetWolf || entity instanceof PetCat) { + pets++; + } + } + return pets; + }); + } + + private static int countServerPets(Iterable entities) { + int pets = 0; + for (Entity entity : entities) { + if (entity.getType() == EntityType.WOLF || entity.getType() == EntityType.CAT) { + pets++; + } + } + return pets; + } + + static void check(boolean condition, String message) { + if (!condition) { + throw new AssertionError(message); + } + } +} diff --git a/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalMultiClientTest.java b/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalMultiClientTest.java new file mode 100644 index 0000000..c139a04 --- /dev/null +++ b/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalMultiClientTest.java @@ -0,0 +1,125 @@ +package pro.wihuk.arigadam.combocoal.gametest; + +import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext; +import net.minecraft.client.gui.screen.GameMenuScreen; +import net.minecraft.client.gui.screen.TitleScreen; +import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; +import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; +import net.minecraft.client.network.ServerAddress; +import net.minecraft.client.network.ServerInfo; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.stats.HelpServersScreen; +import pro.wihuk.arigadam.combocoal.stats.StatsClient; +import pro.wihuk.arigadam.combocoal.stats.TeamCombo; + +import java.util.concurrent.TimeUnit; + +import static pro.wihuk.arigadam.combocoal.gametest.ComboCoalClientGameTest.check; +import static pro.wihuk.arigadam.combocoal.gametest.ComboCoalClientGameTest.mineCoal; + +/** + * Runs in two separate game instances at once (usernames ending in A and B) that join the same + * external dedicated server. Both mine 6 coal; each client must end up with the stacked combo of 12. + */ +final class ComboCoalMultiClientTest { + private static final int HITS_EACH = 12; + + private ComboCoalMultiClientTest() { + } + + static void run(ClientGameTestContext context, String endpoint, String address) { + try { + ComboCoalTeamTest.authenticate(endpoint); + } catch (Exception e) { + throw new AssertionError("captcha failed: " + e, e); + } + String name = context.computeOnClient(client -> client.getSession().getUsername()); + int offsetX = name.endsWith("B") ? 10 : 0; + + context.runOnClient(client -> ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(address), + new ServerInfo("test", address, ServerInfo.ServerType.OTHER), false, null)); + context.waitFor(client -> client.world != null && client.player != null && client.currentScreen == null, 1200); + context.waitTicks(40); + check(!StatsClient.server().equals("singleplayer"), "expected a real server address"); + + // Each player works at its own spot so the clients do not touch each other's blocks. + command(context, "gamemode creative"); + command(context, "tp @s " + (offsetX + 0.5) + " -60 0.5 0 0"); + context.waitTicks(20); + + // Wait until the server reports both players, so the two clients mine at the same time. + context.waitFor(client -> TeamCombo.players() == 2, 3600); + System.out.println("MULTITEST " + name + " sees 2 players, mining"); + + for (int i = 0; i < HITS_EACH; i++) { + command(context, "setblock " + offsetX + " -59 2 minecraft:coal_ore"); + context.waitTicks(2); + context.getInput().holdMouseFor(0, 2); + context.waitTicks(4); + } + + int ticks = context.waitFor(client -> ComboManager.combo() == HITS_EACH * 2, 400); + System.out.println("MULTITEST " + name + " combo=" + ComboManager.combo() + " players=" + TeamCombo.players() + " after " + ticks); + check(ComboManager.combo() == HITS_EACH * 2, name + ": stacked combo should be 24 but is " + ComboManager.combo()); + check(TeamCombo.players() == 2, name + ": expected 2 players"); + context.takeScreenshot("20_multi_" + name); + + // Player A runs out of pickaxe at a high combo: this sends the Help ping. + if (name.endsWith("A")) { + command(context, "give @s minecraft:wooden_pickaxe[minecraft:damage=58]"); + context.waitTicks(60); + } + + // With nobody mining the shared combo ends for both. + context.waitFor(client -> ComboManager.combo() == 0, 400); + check(ComboManager.combo() == 0, name + ": team combo should end"); + leaveServer(context); + + // Wait for player A's Help ping to show up on the backend. + boolean listed = false; + for (int i = 0; i < 40 && !listed; i++) { + listed = helpListed(address); + if (!listed) { + context.waitTicks(20); + } + } + check(listed, name + ": the help ping never appeared on the backend"); + + // Real UI path: multiplayer screen, Help servers button, Join. + context.setScreen(() -> new MultiplayerScreen(new TitleScreen())); + context.waitTicks(10); + context.clickScreenButton("combocoal.help.button"); + context.waitForScreen(HelpServersScreen.class); + context.waitTicks(80); + context.takeScreenshot("21_help_servers_" + name); + check(context.tryClickScreenButton("combocoal.help.join"), name + ": the help list should have a Join button"); + context.waitFor(client -> client.world != null && client.player != null, 1200); + context.waitTicks(40); + leaveServer(context); + System.out.println("MULTITEST " + name + " PASSED"); + } + + private static boolean helpListed(String address) { + try { + return StatsClient.fetchHelpServers().get(5, TimeUnit.SECONDS).stream() + .anyMatch(entry -> entry.server().equalsIgnoreCase(address) && entry.helpers() >= 1); + } catch (Exception e) { + return false; + } + } + + /** Leaves through the pause menu, like a player (this also triggers the stats upload). */ + private static void leaveServer(ClientGameTestContext context) { + context.setScreen(() -> new GameMenuScreen(true)); + context.waitTicks(5); + context.clickScreenButton("menu.disconnect"); + context.waitFor(client -> client.world == null, 400); + context.setScreen(TitleScreen::new); + context.waitTicks(60); + } + + private static void command(ClientGameTestContext context, String command) { + context.runOnClient(client -> client.player.networkHandler.sendChatCommand(command)); + context.waitTicks(3); + } +} diff --git a/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalTeamTest.java b/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalTeamTest.java new file mode 100644 index 0000000..f481099 --- /dev/null +++ b/src/gametest/java/pro/wihuk/arigadam/combocoal/gametest/ComboCoalTeamTest.java @@ -0,0 +1,106 @@ +package pro.wihuk.arigadam.combocoal.gametest; + +import com.google.gson.JsonObject; +import net.fabricmc.fabric.api.client.gametest.v1.context.ClientGameTestContext; +import net.fabricmc.fabric.api.client.gametest.v1.context.TestDedicatedServerContext; +import net.fabricmc.fabric.api.client.gametest.v1.context.TestServerConnection; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; +import pro.wihuk.arigadam.combocoal.stats.StatsApi; +import pro.wihuk.arigadam.combocoal.stats.StatsClient; +import pro.wihuk.arigadam.combocoal.stats.TeamCombo; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static pro.wihuk.arigadam.combocoal.gametest.ComboCoalClientGameTest.check; +import static pro.wihuk.arigadam.combocoal.gametest.ComboCoalClientGameTest.countPets; +import static pro.wihuk.arigadam.combocoal.gametest.ComboCoalClientGameTest.mineCoal; + +/** + * Multiplayer scenario against a real (test) stats backend: captcha, proof of work, shared team combo + * with a simulated teammate, the Help ping and the final stats upload. + */ +final class ComboCoalTeamTest { + private ComboCoalTeamTest() { + } + + static void run(ClientGameTestContext context, String endpoint) { + try { + verify(context, endpoint); + } catch (RuntimeException | Error e) { + throw e; + } catch (Exception e) { + throw new AssertionError("backend call failed: " + e, e); + } + } + + private static void verify(ClientGameTestContext context, String endpoint) throws Exception { + ComboCoalConfig config = ComboCoalConfig.get(); + authenticate(endpoint); + + try (TestDedicatedServerContext server = context.worldBuilder().createServer(); + TestServerConnection connection = server.connect()) { + connection.getClientWorld().waitForChunksRender(); + server.runCommand("gamemode creative @p"); + server.runCommand("tp @p 0.5 -60 0.5 0 0"); + context.waitTicks(10); + check(!StatsClient.server().equals("singleplayer"), "expected a real server address"); + + mineCoal(context, server, 5); + context.waitTicks(45); + check(TeamCombo.active(), "team combo should be active after the first sync"); + check(ComboManager.combo() == 5, "combo should be 5 but is " + ComboManager.combo()); + + // A teammate on the same server breaks 10 coal: the combo stacks. + teammateHits(10); + context.waitTicks(50); + context.takeScreenshot("10_team_combo"); + check(ComboManager.combo() == 15, "team combo should be 15 but is " + ComboManager.combo()); + check(TeamCombo.players() == 2, "expected 2 players, got " + TeamCombo.players()); + check(countPets(context) == 3, "expected 3 pets at team combo 15, got " + countPets(context)); + + // High combo plus a nearly broken pickaxe sends the Help ping. + teammateHits(10); + server.runCommand("give @p minecraft:wooden_pickaxe[minecraft:damage=58]"); + context.waitTicks(60); + check(ComboManager.combo() == 25, "team combo should be 25 but is " + ComboManager.combo()); + List helpServers = StatsClient.fetchHelpServers().get(10, TimeUnit.SECONDS); + check(helpServers.stream().anyMatch(s -> s.server().equalsIgnoreCase(StatsClient.server()) && s.helpers() >= 1), + "help ping missing from backend: " + helpServers); + + // Nobody mines for the whole window: the team combo ends for everyone. + context.waitTicks(140); + check(ComboManager.combo() == 0, "team combo should have ended but is " + ComboManager.combo()); + check(countPets(context) == 0, "pets should be gone after the team combo ended"); + } + + // Leaving the server uploads the session stats. + context.waitTicks(100); + List board = StatsClient.fetchLeaderboard().get(10, TimeUnit.SECONDS); + check(!board.isEmpty() && board.get(0).coal() >= 5, "leaderboard should contain the upload: " + board); + config.statsOptIn = false; + } + + /** Opts in, points the mod at the endpoint and solves the captcha like a player would. */ + static void authenticate(String endpoint) throws Exception { + ComboCoalConfig config = ComboCoalConfig.get(); + config.statsOptIn = true; + config.statsEndpoint = endpoint; + check(!StatsApi.hasToken(), "no token expected before the captcha"); + + StatsApi.Captcha captcha = StatsApi.fetchCaptcha().get(10, TimeUnit.SECONDS); + String[] parts = captcha.question().split(" \\+ "); + int answer = Integer.parseInt(parts[0].trim()) + Integer.parseInt(parts[1].trim()); + StatsApi.submitCaptcha(captcha, Integer.toString(answer)).get(10, TimeUnit.SECONDS); + check(StatsApi.hasToken(), "captcha should have produced a token"); + } + + private static void teammateHits(int hits) throws Exception { + JsonObject body = new JsonObject(); + body.addProperty("player", "Teammate"); + body.addProperty("server", StatsClient.server()); + body.addProperty("hits", hits); + StatsApi.postProtectedJson("/team/sync", "/pow?scope=team", body).get(10, TimeUnit.SECONDS); + } +} diff --git a/src/gametest/resources/fabric.mod.json b/src/gametest/resources/fabric.mod.json new file mode 100644 index 0000000..5345495 --- /dev/null +++ b/src/gametest/resources/fabric.mod.json @@ -0,0 +1,13 @@ +{ + "schemaVersion": 1, + "id": "combocoal-gametest", + "version": "1.0.0", + "name": "ComboCoal GameTest", + "environment": "client", + "entrypoints": { + "fabric-client-gametest": ["pro.wihuk.arigadam.combocoal.gametest.ComboCoalClientGameTest"] + }, + "depends": { + "combocoal": "*" + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/ComboCoalClient.java b/src/main/java/pro/wihuk/arigadam/combocoal/ComboCoalClient.java new file mode 100644 index 0000000..b8ee4fb --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/ComboCoalClient.java @@ -0,0 +1,119 @@ +package pro.wihuk.arigadam.combocoal; + +import net.fabricmc.api.ClientModInitializer; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents; +import net.fabricmc.fabric.api.client.screen.v1.Screens; +import net.fabricmc.fabric.api.event.client.player.ClientPlayerBlockBreakEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.TitleScreen; +import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.text.Text; +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; +import org.lwjgl.glfw.GLFW; +import pro.wihuk.arigadam.combocoal.combo.CoalBlocks; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; +import pro.wihuk.arigadam.combocoal.config.ConfigScreen; +import pro.wihuk.arigadam.combocoal.esp.CoalEsp; +import pro.wihuk.arigadam.combocoal.esp.CoalIndex; +import pro.wihuk.arigadam.combocoal.guide.GuideHud; +import pro.wihuk.arigadam.combocoal.hud.Confetti; +import pro.wihuk.arigadam.combocoal.hud.HudRenderer; +import pro.wihuk.arigadam.combocoal.hud.Popups; +import pro.wihuk.arigadam.combocoal.hud.QuestScreen; +import pro.wihuk.arigadam.combocoal.maniac.ManiacMode; +import pro.wihuk.arigadam.combocoal.pets.Pets; +import pro.wihuk.arigadam.combocoal.progress.Progress; +import pro.wihuk.arigadam.combocoal.stats.ConsentScreen; +import pro.wihuk.arigadam.combocoal.stats.HelpServersScreen; +import pro.wihuk.arigadam.combocoal.stats.StatsClient; +import pro.wihuk.arigadam.combocoal.stats.TeamCombo; +import pro.wihuk.arigadam.combocoal.tools.DurabilityWatcher; + +/** Client entrypoint: wires every module to its Fabric event. */ +public class ComboCoalClient implements ClientModInitializer { + public static final String KEY_CATEGORY = "key.categories.combocoal"; + + private static KeyBinding questKey; + private static KeyBinding configKey; + + @Override + public void onInitializeClient() { + ComboCoalConfig.load(); + Progress.load(); + + questKey = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.combocoal.quest", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_K, KEY_CATEGORY)); + configKey = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.combocoal.config", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_O, KEY_CATEGORY)); + + HudRenderer.register(); + GuideHud.register(); + DurabilityWatcher.register(); + ManiacMode.register(); + CoalEsp.register(); + StatsClient.register(); + TeamCombo.register(); + + ClientPlayerBlockBreakEvents.AFTER.register((world, player, pos, state) -> { + if (CoalBlocks.isCoalOre(state)) { + ComboManager.onCoalBroken(); + } + }); + + // "Help servers" button in the multiplayer screen. + ScreenEvents.AFTER_INIT.register((client, screen, width, height) -> { + if (screen instanceof MultiplayerScreen) { + Screens.getButtons(screen).add(ButtonWidget.builder(Text.translatable("combocoal.help.button"), + button -> client.setScreen(new HelpServersScreen(screen))).dimensions(width - 106, 6, 100, 20).build()); + } + }); + + // The stats consent screen appears once, the first time the title screen opens. + ScreenEvents.AFTER_INIT.register((client, screen, width, height) -> { + if (screen instanceof TitleScreen && !ComboCoalConfig.get().statsConsentShown) { + client.execute(() -> client.setScreen(new ConsentScreen(screen))); + } + }); + + ClientTickEvents.END_CLIENT_TICK.register(this::onTick); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> onWorldLeave()); + ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { + Pets.clear(); + Progress.save(); + }); + } + + private void onTick(MinecraftClient client) { + ComboManager.tick(); + Popups.tick(); + Confetti.tick(); + Pets.tick(); + CoalIndex.tick(client); + + while (questKey.wasPressed()) { + if (client.player != null && client.currentScreen == null) { + client.setScreen(new QuestScreen()); + } + } + while (configKey.wasPressed()) { + if (client.currentScreen == null) { + client.setScreen(new ConfigScreen(null)); + } + } + } + + private void onWorldLeave() { + Pets.clear(); + ComboManager.reset(); + Popups.clear(); + Confetti.clear(); + Progress.save(); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/audio/Sfx.java b/src/main/java/pro/wihuk/arigadam/combocoal/audio/Sfx.java new file mode 100644 index 0000000..f86c8bf --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/audio/Sfx.java @@ -0,0 +1,49 @@ +package pro.wihuk.arigadam.combocoal.audio; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.sound.PositionedSoundInstance; +import net.minecraft.sound.SoundEvent; +import net.minecraft.sound.SoundEvents; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; + +/** Vanilla-only UI sounds, all gated by the "sounds" config flag. */ +public final class Sfx { + private Sfx() { + } + + private static void play(SoundEvent sound, float pitch, float volume) { + if (!ComboCoalConfig.get().sounds) { + return; + } + MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(sound, pitch, volume)); + } + + /** Pitch rises with the combo, capped at 2.0 (the vanilla maximum). */ + public static void pop(int combo) { + play(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, Math.min(2.0f, 0.8f + combo * 0.03f), 0.6f); + } + + public static void coin() { + play(SoundEvents.BLOCK_NOTE_BLOCK_BELL.value(), 1.6f, 0.7f); + } + + public static void rankUp() { + play(SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, 1.0f, 0.8f); + } + + public static void levelUp() { + play(SoundEvents.ENTITY_PLAYER_LEVELUP, 1.0f, 0.9f); + } + + public static void comboLost() { + play(SoundEvents.BLOCK_NOTE_BLOCK_BASS.value(), 0.5f, 0.9f); + } + + public static void alarm() { + play(SoundEvents.BLOCK_NOTE_BLOCK_PLING.value(), 2.0f, 0.8f); + } + + public static void repaired() { + play(SoundEvents.BLOCK_ANVIL_USE, 1.4f, 0.5f); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/combo/CoalBlocks.java b/src/main/java/pro/wihuk/arigadam/combocoal/combo/CoalBlocks.java new file mode 100644 index 0000000..83b48c3 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/combo/CoalBlocks.java @@ -0,0 +1,19 @@ +package pro.wihuk.arigadam.combocoal.combo; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; + +/** The blocks that count as coal ore for the combo, ESP and guide. */ +public final class CoalBlocks { + private CoalBlocks() { + } + + public static boolean isCoalOre(Block block) { + return block == Blocks.COAL_ORE || block == Blocks.DEEPSLATE_COAL_ORE; + } + + public static boolean isCoalOre(BlockState state) { + return isCoalOre(state.getBlock()); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/combo/ComboManager.java b/src/main/java/pro/wihuk/arigadam/combocoal/combo/ComboManager.java new file mode 100644 index 0000000..6a36fd3 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/combo/ComboManager.java @@ -0,0 +1,147 @@ +package pro.wihuk.arigadam.combocoal.combo; + +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.audio.Sfx; +import pro.wihuk.arigadam.combocoal.hud.Confetti; +import pro.wihuk.arigadam.combocoal.hud.Popups; +import pro.wihuk.arigadam.combocoal.pets.Pets; +import pro.wihuk.arigadam.combocoal.progress.Progress; +import pro.wihuk.arigadam.combocoal.stats.TeamCombo; + +/** Tracks the running coal combo, its expiry window and rank changes. */ +public final class ComboManager { + /** 5 seconds without a coal block ends the combo. */ + public static final int WINDOW_TICKS = 100; + private static final float POP_TICKS = 12f; + + private static int combo; + private static int sessionCoal; + private static int ticksSinceCoal; + private static float pop; + private static Rank rank = Rank.C; + /** While true the shared team combo (from the stats server) decides when the combo ends. */ + private static boolean teamControlled; + + private ComboManager() { + } + + public static int combo() { + return combo; + } + + /** Coal mined since the game was launched. */ + public static int sessionCoal() { + return sessionCoal; + } + + public static Rank rank() { + return rank; + } + + /** Pop animation value: 1.0 right after a coal, falling to 0.0. */ + public static float pop(float partialTick) { + return Math.max(0f, pop - partialTick / POP_TICKS); + } + + /** Fraction of the combo window left, from 1.0 down to 0.0. */ + public static float timeLeft(float partialTick) { + return Math.max(0f, 1f - (ticksSinceCoal + partialTick) / WINDOW_TICKS); + } + + public static void onCoalBroken() { + combo++; + sessionCoal++; + ticksSinceCoal = 0; + pop = 1f; + + TeamCombo.onHit(); + Progress.onCoal(combo); + Sfx.pop(combo); + Popups.add(Text.translatable("combocoal.popup.coal"), 0xFFFFFFFF); + if (combo % 5 == 0) { + Popups.add(Text.translatable("combocoal.popup.great"), 0xFFFFFF55); + } + updateRank(); + Pets.sync(combo); + } + + /** Bonus combo for repairing a tool; extends an active combo but never starts one. */ + public static void addBonus(int amount) { + if (combo <= 0) { + return; + } + combo += amount; + ticksSinceCoal = 0; + pop = 1f; + Progress.data().bestCombo = Math.max(Progress.data().bestCombo, combo); + updateRank(); + Pets.sync(combo); + } + + public static void tick() { + if (pop > 0f) { + pop = Math.max(0f, pop - 1f / POP_TICKS); + } + ticksSinceCoal++; + if (combo > 0 && !teamControlled && ticksSinceCoal >= WINDOW_TICKS) { + lose(); + } + } + + public static void setTeamControlled(boolean controlled) { + if (teamControlled && !controlled) { + // Fall back to the personal combo with a fresh window. + ticksSinceCoal = 0; + } + teamControlled = controlled; + } + + /** Applies the shared combo reported by the team server (includes this player's own hits). */ + public static void applyTeamCombo(int teamCombo) { + if (teamCombo == combo) { + return; + } + if (teamCombo <= 0) { + // Nobody hit coal for the whole window. + lose(); + return; + } + boolean increased = teamCombo > combo; + combo = teamCombo; + if (increased) { + ticksSinceCoal = 0; + pop = 1f; + Progress.data().bestCombo = Math.max(Progress.data().bestCombo, combo); + updateRank(); + } else { + rank = Rank.of(combo); + } + Pets.sync(combo); + } + + private static void updateRank() { + Rank newRank = Rank.of(combo); + if (newRank.ordinal() > rank.ordinal()) { + Popups.add(Text.translatable("combocoal.popup.rank_up"), newRank.color); + Confetti.burst(); + Sfx.rankUp(); + } + rank = newRank; + } + + private static void lose() { + Popups.add(Text.translatable("combocoal.popup.combo_lost"), 0xFFFF5555); + Sfx.comboLost(); + Pets.poof(); + reset(); + } + + /** Drops all combo state without any feedback, for example when leaving a world. */ + public static void reset() { + teamControlled = false; + combo = 0; + ticksSinceCoal = 0; + pop = 0f; + rank = Rank.C; + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/combo/Rank.java b/src/main/java/pro/wihuk/arigadam/combocoal/combo/Rank.java new file mode 100644 index 0000000..c85ff0f --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/combo/Rank.java @@ -0,0 +1,39 @@ +package pro.wihuk.arigadam.combocoal.combo; + +import net.minecraft.text.Text; + +public enum Rank { + C(0, 0xFFAAAAAA, "c"), + B(10, 0xFF55FF55, "b"), + A(20, 0xFF55FFFF, "a"), + S(30, 0xFFFFAA00, "s"), + SSS(50, 0xFFFF55FF, "sss"); + + public final int minCombo; + public final int color; + private final String key; + + Rank(int minCombo, int color, String key) { + this.minCombo = minCombo; + this.color = color; + this.key = key; + } + + public static Rank of(int combo) { + Rank result = C; + for (Rank rank : values()) { + if (combo >= rank.minCombo) { + result = rank; + } + } + return result; + } + + public Text title() { + return Text.translatable("combocoal.rank." + key + ".title"); + } + + public Text letter() { + return Text.translatable("combocoal.rank." + key + ".letter"); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/config/ComboCoalConfig.java b/src/main/java/pro/wihuk/arigadam/combocoal/config/ComboCoalConfig.java new file mode 100644 index 0000000..190f0a3 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/config/ComboCoalConfig.java @@ -0,0 +1,92 @@ +package pro.wihuk.arigadam.combocoal.config; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.client.MinecraftClient; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; + +/** User-editable settings, stored as {@code config/combocoal.json}. */ +public class ComboCoalConfig { + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("combocoal.json"); + private static ComboCoalConfig instance = new ComboCoalConfig(); + + public boolean hapticShake = true; + public boolean maniacMode = false; + public boolean strictMode = false; + /** Coal ESP. Only effective in singleplayer unless {@link #allowEspOnMultiplayer} is set. */ + public boolean esp = true; + public boolean allowEspOnMultiplayer = false; + public int espRadius = 32; + /** Arrow to the nearest coal in the guide. Same multiplayer rule as the ESP. */ + public boolean arrow = true; + public boolean allowArrowOnMultiplayer = false; + public boolean pets = true; + public boolean sounds = true; + /** Stats sharing is strictly opt-in; nothing is sent while this is false. */ + public boolean statsOptIn = false; + /** Must be an https:// URL. Nothing is sent to it unless statsOptIn is true. */ + public String statsEndpoint = "https://master.combocoal.wihuk.pro"; + public boolean statsConsentShown = false; + /** Signed token obtained by solving the captcha once; sent with every stats request. */ + public String statsToken = ""; + public float hudScale = 1.0f; + + public static ComboCoalConfig get() { + return instance; + } + + public static void load() { + if (!Files.exists(PATH)) { + save(); + return; + } + try (Reader reader = Files.newBufferedReader(PATH)) { + ComboCoalConfig loaded = GSON.fromJson(reader, ComboCoalConfig.class); + if (loaded != null) { + instance = loaded; + instance.sanitize(); + } + } catch (IOException | RuntimeException e) { + System.err.println("[ComboCoal] Could not read config, using defaults: " + e); + } + } + + public static void save() { + try (Writer writer = Files.newBufferedWriter(PATH)) { + GSON.toJson(instance, writer); + } catch (IOException e) { + System.err.println("[ComboCoal] Could not save config: " + e); + } + } + + private void sanitize() { + hudScale = Math.max(0.5f, Math.min(2.0f, hudScale)); + espRadius = Math.max(8, Math.min(64, espRadius)); + if (statsToken == null) { + statsToken = ""; + } + if (statsEndpoint == null) { + statsEndpoint = ""; + } + } + + private static boolean singleplayer() { + return MinecraftClient.getInstance().isInSingleplayer(); + } + + /** ESP is on in singleplayer by default, and on multiplayer only if explicitly allowed. */ + public boolean espActive() { + return esp && (singleplayer() || allowEspOnMultiplayer); + } + + public boolean arrowActive() { + return arrow && (singleplayer() || allowArrowOnMultiplayer); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/config/ConfigScreen.java b/src/main/java/pro/wihuk/arigadam/combocoal/config/ConfigScreen.java new file mode 100644 index 0000000..cc1ee4e --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/config/ConfigScreen.java @@ -0,0 +1,116 @@ +package pro.wihuk.arigadam.combocoal.config; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.SliderWidget; +import net.minecraft.screen.ScreenTexts; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.stats.CaptchaScreen; +import pro.wihuk.arigadam.combocoal.stats.LeaderboardScreen; + +import java.util.function.BooleanSupplier; +import java.util.function.Consumer; + +/** In-game settings screen; every change is written to config/combocoal.json when the screen closes. */ +public class ConfigScreen extends Screen { + private static final int BUTTON_WIDTH = 150; + private static final int BUTTON_HEIGHT = 20; + private static final int ROW_HEIGHT = 24; + + private final Screen parent; + private int slot; + + public ConfigScreen(Screen parent) { + super(Text.translatable("combocoal.config.title")); + this.parent = parent; + } + + @Override + protected void init() { + slot = 0; + ComboCoalConfig config = ComboCoalConfig.get(); + toggle("hapticShake", () -> config.hapticShake, value -> config.hapticShake = value); + toggle("maniacMode", () -> config.maniacMode, value -> config.maniacMode = value); + toggle("strictMode", () -> config.strictMode, value -> config.strictMode = value); + toggle("esp", () -> config.esp, value -> config.esp = value); + toggle("allowEspOnMultiplayer", () -> config.allowEspOnMultiplayer, value -> config.allowEspOnMultiplayer = value); + toggle("arrow", () -> config.arrow, value -> config.arrow = value); + toggle("allowArrowOnMultiplayer", () -> config.allowArrowOnMultiplayer, value -> config.allowArrowOnMultiplayer = value); + toggle("pets", () -> config.pets, value -> config.pets = value); + toggle("sounds", () -> config.sounds, value -> config.sounds = value); + toggle("statsOptIn", () -> config.statsOptIn, value -> { + config.statsOptIn = value; + config.statsConsentShown = true; + }); + addDrawableChild(new HudScaleSlider(columnX(), rowY(), config)); + slot++; + addDrawableChild(ButtonWidget.builder(Text.translatable("combocoal.config.captcha"), + button -> client.setScreen(new CaptchaScreen(this))) + .dimensions(columnX(), rowY(), BUTTON_WIDTH, BUTTON_HEIGHT).build()); + slot++; + addDrawableChild(ButtonWidget.builder(Text.translatable("combocoal.config.leaderboard"), + button -> client.setScreen(new LeaderboardScreen(this))) + .dimensions(columnX(), rowY(), BUTTON_WIDTH, BUTTON_HEIGHT).build()); + slot++; + + addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, button -> close()) + .dimensions(width / 2 - 50, height - 28, 100, BUTTON_HEIGHT).build()); + } + + private int columnX() { + return slot % 2 == 0 ? width / 2 - BUTTON_WIDTH - 4 : width / 2 + 4; + } + + private int rowY() { + return 36 + slot / 2 * ROW_HEIGHT; + } + + private void toggle(String key, BooleanSupplier getter, Consumer setter) { + Text label = Text.translatable("combocoal.config." + key); + ButtonWidget button = ButtonWidget.builder(optionText(label, getter.getAsBoolean()), pressed -> { + setter.accept(!getter.getAsBoolean()); + pressed.setMessage(optionText(label, getter.getAsBoolean())); + }).dimensions(columnX(), rowY(), BUTTON_WIDTH, BUTTON_HEIGHT).build(); + addDrawableChild(button); + slot++; + } + + private static Text optionText(Text label, boolean on) { + return Text.translatable("combocoal.config.option", label, + Text.translatable(on ? "combocoal.config.on" : "combocoal.config.off")); + } + + @Override + public void render(DrawContext context, int mouseX, int mouseY, float delta) { + super.render(context, mouseX, mouseY, delta); + context.drawCenteredTextWithShadow(textRenderer, title, width / 2, 16, 0xFFFFFFFF); + } + + @Override + public void close() { + ComboCoalConfig.save(); + client.setScreen(parent); + } + + /** Slider for hudScale, 0.5x to 2.0x. */ + private static class HudScaleSlider extends SliderWidget { + private final ComboCoalConfig config; + + HudScaleSlider(int x, int y, ComboCoalConfig config) { + super(x, y, BUTTON_WIDTH, BUTTON_HEIGHT, Text.empty(), (config.hudScale - 0.5) / 1.5); + this.config = config; + updateMessage(); + } + + @Override + protected void updateMessage() { + setMessage(Text.translatable("combocoal.config.hudScale", Math.round(config.hudScale * 100))); + } + + @Override + protected void applyValue() { + config.hudScale = (float) (0.5 + value * 1.5); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalEsp.java b/src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalEsp.java new file mode 100644 index 0000000..a68a05b --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalEsp.java @@ -0,0 +1,126 @@ +package pro.wihuk.arigadam.combocoal.esp; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext; +import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gl.ShaderProgramKeys; +import net.minecraft.client.render.BufferBuilder; +import net.minecraft.client.render.BufferRenderer; +import net.minecraft.client.render.Tessellator; +import net.minecraft.client.render.VertexFormat; +import net.minecraft.client.render.VertexFormats; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import pro.wihuk.arigadam.combocoal.combo.CoalBlocks; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; + +import java.awt.Color; + +/** + * Highlights coal ore through walls, tinted by vein size. This is a cheat on most servers, so it is + * off on multiplayer unless allowEspOnMultiplayer is set. + */ +public final class CoalEsp { + private static final int MAX_BOXES = 500; + + private static boolean multiplayerWarned; + + private CoalEsp() { + } + + public static void register() { + ClientTickEvents.END_CLIENT_TICK.register(CoalEsp::tick); + WorldRenderEvents.LAST.register(CoalEsp::render); + ClientChunkEvents.CHUNK_LOAD.register((world, chunk) -> CoalIndex.forget(chunk.getPos())); + ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> CoalIndex.forget(chunk.getPos())); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> CoalIndex.clear()); + } + + private static void tick(MinecraftClient client) { + if (client.player == null || !ComboCoalConfig.get().espActive()) { + return; + } + CoalIndex.request(); + if (!multiplayerWarned && !client.isInSingleplayer()) { + multiplayerWarned = true; + client.player.sendMessage(Text.translatable("combocoal.warning.esp_multiplayer"), false); + } + } + + private static void render(WorldRenderContext context) { + MinecraftClient client = MinecraftClient.getInstance(); + ComboCoalConfig config = ComboCoalConfig.get(); + if (client.player == null || client.world == null || !config.espActive()) { + return; + } + Vec3d camera = context.camera().getPos(); + BufferBuilder buffer = Tessellator.getInstance().begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); + float pulse = 0.6f + 0.4f * (float) Math.sin(System.currentTimeMillis() / 250.0); + int[] boxes = {0}; + + CoalIndex.forEachWithin(client.player.getPos(), config.espRadius, (pos, size, biggest) -> { + BlockPos blockPos = BlockPos.fromLong(pos); + if (boxes[0] >= MAX_BOXES || !CoalBlocks.isCoalOre(client.world.getBlockState(blockPos))) { + return; + } + boxes[0]++; + // Bigger vein = brighter and warmer; the biggest vein (3+ blocks) also pulses. + float t = Math.min(1f, (size - 1) / 12f); + int rgb = Color.HSBtoRGB(0.6f - 0.48f * t, 0.85f - 0.35f * t, 0.6f + 0.4f * t); + float alpha = 0.25f + 0.25f * t; + if (size == biggest && size >= 3) { + alpha *= pulse + 0.4f; + } + addBox(buffer, (float) (blockPos.getX() - camera.x), (float) (blockPos.getY() - camera.y), + (float) (blockPos.getZ() - camera.z), rgb, Math.min(1f, alpha)); + }); + if (boxes[0] == 0) { + return; + } + + // The world renderer already has the camera rotation on the model-view stack, so vertices are camera-relative. + RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR); + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + RenderSystem.disableDepthTest(); + RenderSystem.disableCull(); + RenderSystem.depthMask(false); + + BufferRenderer.drawWithGlobalProgram(buffer.end()); + + RenderSystem.depthMask(true); + RenderSystem.enableCull(); + RenderSystem.enableDepthTest(); + RenderSystem.disableBlend(); + } + + /** Adds the six faces of a unit cube, slightly enlarged so it does not z-fight the block. */ + private static void addBox(BufferBuilder buffer, float x, float y, float z, int rgb, float alpha) { + float e = 0.003f; + float x0 = x - e, y0 = y - e, z0 = z - e; + float x1 = x + 1 + e, y1 = y + 1 + e, z1 = z + 1 + e; + float r = (rgb >> 16 & 0xFF) / 255f; + float g = (rgb >> 8 & 0xFF) / 255f; + float b = (rgb & 0xFF) / 255f; + quad(buffer, r, g, b, alpha, x0, y0, z0, x1, y0, z0, x1, y0, z1, x0, y0, z1); + quad(buffer, r, g, b, alpha, x0, y1, z0, x0, y1, z1, x1, y1, z1, x1, y1, z0); + quad(buffer, r, g, b, alpha, x0, y0, z0, x0, y1, z0, x1, y1, z0, x1, y0, z0); + quad(buffer, r, g, b, alpha, x0, y0, z1, x1, y0, z1, x1, y1, z1, x0, y1, z1); + quad(buffer, r, g, b, alpha, x0, y0, z0, x0, y0, z1, x0, y1, z1, x0, y1, z0); + quad(buffer, r, g, b, alpha, x1, y0, z0, x1, y1, z0, x1, y1, z1, x1, y0, z1); + } + + private static void quad(BufferBuilder buffer, float r, float g, float b, float a, + float ax, float ay, float az, float bx, float by, float bz, + float cx, float cy, float cz, float dx, float dy, float dz) { + buffer.vertex(ax, ay, az).color(r, g, b, a); + buffer.vertex(bx, by, bz).color(r, g, b, a); + buffer.vertex(cx, cy, cz).color(r, g, b, a); + buffer.vertex(dx, dy, dz).color(r, g, b, a); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalIndex.java b/src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalIndex.java new file mode 100644 index 0000000..042cd57 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/esp/CoalIndex.java @@ -0,0 +1,247 @@ +package pro.wihuk.arigadam.combocoal.esp; + +import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.longs.LongArrayList; +import it.unimi.dsi.fastutil.longs.LongIterator; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.ChunkPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.chunk.ChunkSection; +import net.minecraft.world.chunk.WorldChunk; +import pro.wihuk.arigadam.combocoal.combo.CoalBlocks; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.function.LongPredicate; + +/** + * Incrementally scanned cache of coal ore positions, shared by the ESP and the guide arrow. + * Chunks are scanned a couple per tick (only sections whose palette contains coal are walked) + * and only while a feature has asked for the index this tick via {@link #request()}. + */ +public final class CoalIndex { + private static final int CHUNKS_PER_TICK = 2; + private static final int REFILL_INTERVAL_TICKS = 10; + private static final int VEIN_REBUILD_INTERVAL_TICKS = 10; + private static final int VALIDATE_INTERVAL_TICKS = 20; + /** Scanned chunks are re-read this often to pick up blocks that appeared after the scan. */ + private static final int RESCAN_INTERVAL_TICKS = 300; + + private static final Long2ObjectOpenHashMap CHUNKS = new Long2ObjectOpenHashMap<>(); + private static final Long2IntOpenHashMap VEIN_SIZE = new Long2IntOpenHashMap(); + private static final Long2IntOpenHashMap SCANNED_AT = new Long2IntOpenHashMap(); + private static final ArrayDeque PENDING = new ArrayDeque<>(); + + private static int ticks; + private static int requestedAt = Integer.MIN_VALUE; + private static int maxVein; + private static boolean veinsDirty; + private static int lastVeinRebuild; + + private CoalIndex() { + } + + @FunctionalInterface + public interface PosConsumer { + void accept(long pos, int veinSize, int biggestVein); + } + + /** Features call this every tick they want the index kept up to date. */ + public static void request() { + requestedAt = ticks; + } + + public static void clear() { + CHUNKS.clear(); + SCANNED_AT.clear(); + VEIN_SIZE.clear(); + PENDING.clear(); + maxVein = 0; + veinsDirty = false; + } + + /** Forgets a chunk; it is scanned again the next time the index is active. */ + public static void forget(ChunkPos pos) { + SCANNED_AT.remove(pos.toLong()); + if (CHUNKS.remove(pos.toLong()) != null) { + veinsDirty = true; + } + } + + public static void tick(MinecraftClient client) { + ticks++; + ClientWorld world = client.world; + if (world == null || client.player == null || ticks - requestedAt > 1) { + return; + } + int radius = ComboCoalConfig.get().espRadius; + if (ticks % REFILL_INTERVAL_TICKS == 0) { + refill(client, radius); + } + for (int i = 0; i < CHUNKS_PER_TICK && !PENDING.isEmpty(); i++) { + scan(world, PENDING.poll()); + } + if (ticks % VALIDATE_INTERVAL_TICKS == 0) { + validate(world); + } + if (veinsDirty && ticks - lastVeinRebuild >= VEIN_REBUILD_INTERVAL_TICKS) { + rebuildVeins(); + } + } + + /** Queues unscanned chunks inside the radius (nearest first) and drops chunks far outside it. */ + private static void refill(MinecraftClient client, int radius) { + ChunkPos center = client.player.getChunkPos(); + int chunkRadius = (radius >> 4) + 1; + PENDING.clear(); + List missing = new ArrayList<>(); + for (int dx = -chunkRadius; dx <= chunkRadius; dx++) { + for (int dz = -chunkRadius; dz <= chunkRadius; dz++) { + ChunkPos pos = new ChunkPos(center.x + dx, center.z + dz); + if (needsScan(pos.toLong()) && client.world.getChunkManager().getWorldChunk(pos.x, pos.z) != null) { + missing.add(pos); + } + } + } + missing.sort(Comparator.comparingInt(p -> (p.x - center.x) * (p.x - center.x) + (p.z - center.z) * (p.z - center.z))); + PENDING.addAll(missing); + + int keep = chunkRadius + 2; + LongPredicate tooFar = key -> Math.abs(ChunkPos.getPackedX(key) - center.x) > keep + || Math.abs(ChunkPos.getPackedZ(key) - center.z) > keep; + SCANNED_AT.keySet().removeIf(tooFar); + if (CHUNKS.keySet().removeIf(tooFar)) { + veinsDirty = true; + } + } + + private static boolean needsScan(long chunk) { + return !CHUNKS.containsKey(chunk) || ticks - SCANNED_AT.get(chunk) >= RESCAN_INTERVAL_TICKS; + } + + private static void scan(ClientWorld world, ChunkPos pos) { + WorldChunk chunk = world.getChunkManager().getWorldChunk(pos.x, pos.z); + if (chunk == null) { + return; + } + LongOpenHashSet found = new LongOpenHashSet(); + ChunkSection[] sections = chunk.getSectionArray(); + for (int i = 0; i < sections.length; i++) { + ChunkSection section = sections[i]; + if (section.isEmpty() || !section.hasAny(CoalBlocks::isCoalOre)) { + continue; + } + int baseY = chunk.sectionIndexToCoord(i) << 4; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + for (int z = 0; z < 16; z++) { + if (CoalBlocks.isCoalOre(section.getBlockState(x, y, z))) { + found.add(BlockPos.asLong(pos.getStartX() + x, baseY + y, pos.getStartZ() + z)); + } + } + } + } + } + CHUNKS.put(pos.toLong(), found); + SCANNED_AT.put(pos.toLong(), ticks); + veinsDirty = true; + } + + /** Drops cached positions that are no longer coal (mined, exploded, replaced). */ + private static void validate(ClientWorld world) { + BlockPos.Mutable mutable = new BlockPos.Mutable(); + for (LongOpenHashSet set : CHUNKS.values()) { + LongIterator iterator = set.iterator(); + while (iterator.hasNext()) { + mutable.set(iterator.nextLong()); + if (!CoalBlocks.isCoalOre(world.getBlockState(mutable))) { + iterator.remove(); + veinsDirty = true; + } + } + } + } + + /** Groups cached positions into veins (touching blocks, diagonals included) and records each vein size. */ + private static void rebuildVeins() { + lastVeinRebuild = ticks; + veinsDirty = false; + VEIN_SIZE.clear(); + maxVein = 0; + + LongOpenHashSet all = new LongOpenHashSet(); + CHUNKS.values().forEach(all::addAll); + LongOpenHashSet visited = new LongOpenHashSet(); + for (long start : all) { + if (!visited.add(start)) { + continue; + } + LongArrayList component = new LongArrayList(); + LongArrayList stack = new LongArrayList(); + stack.add(start); + while (!stack.isEmpty()) { + long current = stack.removeLong(stack.size() - 1); + component.add(current); + int cx = BlockPos.unpackLongX(current); + int cy = BlockPos.unpackLongY(current); + int cz = BlockPos.unpackLongZ(current); + for (int dx = -1; dx <= 1; dx++) { + for (int dy = -1; dy <= 1; dy++) { + for (int dz = -1; dz <= 1; dz++) { + long next = BlockPos.asLong(cx + dx, cy + dy, cz + dz); + if (all.contains(next) && visited.add(next)) { + stack.add(next); + } + } + } + } + } + int size = component.size(); + maxVein = Math.max(maxVein, size); + for (long pos : component) { + VEIN_SIZE.put(pos, size); + } + } + } + + /** Visits every cached coal position within the radius of the given point. */ + public static void forEachWithin(Vec3d center, double radius, PosConsumer consumer) { + double radiusSq = radius * radius; + for (LongOpenHashSet set : CHUNKS.values()) { + for (long pos : set) { + double dx = BlockPos.unpackLongX(pos) + 0.5 - center.x; + double dy = BlockPos.unpackLongY(pos) + 0.5 - center.y; + double dz = BlockPos.unpackLongZ(pos) + 0.5 - center.z; + if (dx * dx + dy * dy + dz * dz <= radiusSq) { + consumer.accept(pos, VEIN_SIZE.getOrDefault(pos, 1), maxVein); + } + } + } + } + + /** The cached coal position closest to the given point, or null if none is known. */ + public static BlockPos nearest(Vec3d from) { + long best = 0; + double bestDistSq = Double.MAX_VALUE; + for (LongOpenHashSet set : CHUNKS.values()) { + for (long pos : set) { + double dx = BlockPos.unpackLongX(pos) + 0.5 - from.x; + double dy = BlockPos.unpackLongY(pos) + 0.5 - from.y; + double dz = BlockPos.unpackLongZ(pos) + 0.5 - from.z; + double distSq = dx * dx + dy * dy + dz * dz; + if (distSq < bestDistSq) { + bestDistSq = distSq; + best = pos; + } + } + } + return bestDistSq == Double.MAX_VALUE ? null : BlockPos.fromLong(best); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideHud.java b/src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideHud.java new file mode 100644 index 0000000..64b8491 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideHud.java @@ -0,0 +1,156 @@ +package pro.wihuk.arigadam.combocoal.guide; + +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.option.KeyBinding; +import net.minecraft.client.util.InputUtil; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.OrderedText; +import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.RotationAxis; +import net.minecraft.util.math.Vec3d; +import org.lwjgl.glfw.GLFW; +import pro.wihuk.arigadam.combocoal.ComboCoalClient; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; +import pro.wihuk.arigadam.combocoal.esp.CoalIndex; +import pro.wihuk.arigadam.combocoal.hud.MobileUI; +import pro.wihuk.arigadam.combocoal.progress.Progress; +import pro.wihuk.arigadam.combocoal.progress.SaveData; + +import java.util.List; + +/** The step-by-step coal guide panel, plus the arrow to the nearest coal during the "find coal" step. */ +public final class GuideHud { + private static final int PANEL_X = 6; + private static final int PANEL_Y = 34; + private static final int PANEL_WIDTH = 190; + private static final int STEP_CHECK_INTERVAL = 10; + private static final int SEARCH_INTERVAL = 20; + + private static KeyBinding toggleKey; + private static boolean arrowWarned; + private static BlockPos target; + private static int ticks; + + private GuideHud() { + } + + public static void register() { + toggleKey = KeyBindingHelper.registerKeyBinding( + new KeyBinding("key.combocoal.guide", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_G, ComboCoalClient.KEY_CATEGORY)); + ClientTickEvents.END_CLIENT_TICK.register(GuideHud::tick); + } + + private static GuideStep step() { + SaveData data = Progress.data(); + int index = MathHelper.clamp(data.guideStep, 0, GuideStep.values().length - 1); + return GuideStep.values()[index]; + } + + private static boolean wantsArrow() { + SaveData data = Progress.data(); + return data.guideVisible && step() == GuideStep.FIND_COAL && ComboCoalConfig.get().arrowActive(); + } + + private static void tick(MinecraftClient client) { + while (toggleKey.wasPressed()) { + Progress.data().guideVisible = !Progress.data().guideVisible; + } + if (client.player == null) { + target = null; + return; + } + ticks++; + if (ticks % STEP_CHECK_INTERVAL == 0) { + GuideStep current = step(); + while (current != GuideStep.DONE && current.isDone(client.player)) { + current = current.next(); + } + Progress.data().guideStep = current.ordinal(); + } + if (!wantsArrow()) { + target = null; + return; + } + CoalIndex.request(); + if (!arrowWarned && !client.isInSingleplayer()) { + arrowWarned = true; + client.player.sendMessage(Text.translatable("combocoal.warning.arrow_multiplayer"), false); + } + // The search only reads the cached index, and only runs once per second. + if (ticks % SEARCH_INTERVAL == 0) { + target = CoalIndex.nearest(client.player.getPos()); + } + } + + public static void render(DrawContext ctx, int width, int height) { + MinecraftClient client = MinecraftClient.getInstance(); + if (client.player == null || !Progress.data().guideVisible) { + return; + } + GuideStep step = step(); + TextRenderer font = MobileUI.font(); + List lines = font.wrapLines(step.text(client.player), PANEL_WIDTH - 12); + int panelHeight = 24 + lines.size() * 10; + MobileUI.panel(ctx, PANEL_X, PANEL_Y, PANEL_WIDTH, panelHeight); + MobileUI.outlinedText(ctx, Text.translatable("combocoal.guide.header"), PANEL_X + 6, PANEL_Y + 5, 0xFFFFD700); + for (int i = 0; i < lines.size(); i++) { + ctx.drawTextWithShadow(font, lines.get(i), PANEL_X + 6, PANEL_Y + 18 + i * 10, 0xFFFFFFFF); + } + if (step == GuideStep.FIND_COAL) { + drawFindCoal(ctx, client, PANEL_Y + panelHeight + 4); + } + } + + private static void drawFindCoal(DrawContext ctx, MinecraftClient client, int y) { + if (!ComboCoalConfig.get().arrowActive()) { + ctx.drawTextWithShadow(MobileUI.font(), Text.translatable("combocoal.guide.hidden_multiplayer"), + PANEL_X + 2, y, 0xFFAAAAAA); + return; + } + if (target == null) { + ctx.drawTextWithShadow(MobileUI.font(), Text.translatable("combocoal.guide.searching"), + PANEL_X + 2, y, 0xFFAAAAAA); + return; + } + Vec3d eye = client.player.getEyePos(); + double dx = target.getX() + 0.5 - eye.x; + double dy = target.getY() + 0.5 - eye.y; + double dz = target.getZ() + 0.5 - eye.z; + int distance = (int) Math.round(Math.sqrt(dx * dx + dy * dy + dz * dz)); + + // Minecraft yaw 0 faces south (+Z); a target to the right of the view has a larger yaw. + float targetYaw = (float) Math.toDegrees(Math.atan2(-dx, dz)); + float relative = MathHelper.wrapDegrees(targetYaw - client.player.getYaw()); + drawArrow(ctx, PANEL_X + 22, y + 22, relative); + + String key = dy > 3 ? "combocoal.guide.nearest_above" : dy < -3 ? "combocoal.guide.nearest_below" : "combocoal.guide.nearest"; + MobileUI.outlinedText(ctx, Text.translatable(key, distance), PANEL_X + 48, y + 18, 0xFFFFFFFF); + } + + /** A chunky pixel arrow pointing up when rotation is 0, rotating clockwise for positive degrees. */ + private static void drawArrow(DrawContext ctx, int cx, int cy, float degrees) { + MatrixStack matrices = ctx.getMatrices(); + matrices.push(); + matrices.translate(cx, cy, 0f); + matrices.multiply(RotationAxis.POSITIVE_Z.rotationDegrees(degrees)); + int outline = 0xFF000000; + int fill = 0xFFFFD700; + ctx.fill(-4, -6, 4, 13, outline); + for (int row = 0; row < 11; row++) { + int half = row / 2 + 1; + ctx.fill(-half - 1, -16 + row, half + 1, -15 + row, outline); + } + ctx.fill(-3, -6, 3, 12, fill); + for (int row = 0; row < 11; row++) { + int half = row / 2 + 1; + ctx.fill(-half, -16 + row, half, -15 + row, fill); + } + matrices.pop(); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideStep.java b/src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideStep.java new file mode 100644 index 0000000..eee4dd7 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/guide/GuideStep.java @@ -0,0 +1,84 @@ +package pro.wihuk.arigadam.combocoal.guide; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.registry.tag.ItemTags; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; + +import java.util.function.Predicate; + +/** + * The coal guide steps, in order. A step counts as done when the inventory shows it (or any later + * step), so a player who already owns a stone pickaxe skips straight to finding coal. + */ +public enum GuideStep { + LOGS("logs"), + CRAFTING_TABLE("crafting_table"), + WOODEN_PICKAXE("wooden_pickaxe"), + STONE_PICKAXE("stone_pickaxe"), + FIND_COAL("find_coal"), + MINE_VEIN("mine_vein"), + CRAFT_TORCHES("craft_torches"), + DONE("done"); + + /** Coal needed to finish the "mine the vein" step. */ + public static final int VEIN_COAL = 8; + + private final String key; + + GuideStep(String key) { + this.key = key; + } + + public Text text(PlayerEntity player) { + if (this == MINE_VEIN) { + return Text.translatable("combocoal.guide.step." + key, Math.min(VEIN_COAL, coalProgress(player.getInventory())), VEIN_COAL); + } + return Text.translatable("combocoal.guide.step." + key); + } + + public GuideStep next() { + return values()[Math.min(ordinal() + 1, values().length - 1)]; + } + + public boolean isDone(PlayerEntity player) { + PlayerInventory inventory = player.getInventory(); + boolean anyPickaxe = has(inventory, s -> s.isIn(ItemTags.PICKAXES)); + return switch (this) { + case LOGS -> anyPickaxe || has(inventory, s -> s.isIn(ItemTags.LOGS) || s.isIn(ItemTags.PLANKS) + || s.isOf(Items.CRAFTING_TABLE)); + case CRAFTING_TABLE -> anyPickaxe || has(inventory, s -> s.isOf(Items.CRAFTING_TABLE)); + case WOODEN_PICKAXE -> anyPickaxe; + case STONE_PICKAXE -> has(inventory, s -> s.isIn(ItemTags.PICKAXES) && !s.isOf(Items.WOODEN_PICKAXE)); + case FIND_COAL -> ComboManager.sessionCoal() > 0 || has(inventory, s -> s.isOf(Items.COAL)); + case MINE_VEIN -> coalProgress(inventory) >= VEIN_COAL; + case CRAFT_TORCHES -> has(inventory, s -> s.isOf(Items.TORCH)); + case DONE -> false; + }; + } + + /** Coal mined this session, or coal carried, whichever is higher. */ + private static int coalProgress(PlayerInventory inventory) { + int carried = 0; + for (int i = 0; i < inventory.size(); i++) { + ItemStack stack = inventory.getStack(i); + if (stack.isOf(Items.COAL)) { + carried += stack.getCount(); + } + } + return Math.max(ComboManager.sessionCoal(), carried); + } + + private static boolean has(PlayerInventory inventory, Predicate test) { + for (int i = 0; i < inventory.size(); i++) { + ItemStack stack = inventory.getStack(i); + if (!stack.isEmpty() && test.test(stack)) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/hud/Confetti.java b/src/main/java/pro/wihuk/arigadam/combocoal/hud/Confetti.java new file mode 100644 index 0000000..c7aef21 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/hud/Confetti.java @@ -0,0 +1,72 @@ +package pro.wihuk.arigadam.combocoal.hud; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; + +/** Screen-space confetti: colored squares that burst upward and fall with gravity. */ +public final class Confetti { + private static final int PIECES_PER_BURST = 30; + private static final int LIFETIME_TICKS = 70; + private static final float GRAVITY = 0.3f; + private static final int[] COLORS = {0xFFFF5555, 0xFFFFAA00, 0xFFFFFF55, 0xFF55FF55, 0xFF55FFFF, 0xFF5555FF, 0xFFFF55FF}; + private static final List PIECES = new ArrayList<>(); + + private Confetti() { + } + + private static final class Piece { + float x, y, prevX, prevY, vx, vy; + int size, color, age; + } + + /** Fires 30 pieces from just above the middle of the screen. */ + public static void burst() { + ThreadLocalRandom rng = ThreadLocalRandom.current(); + int width = MinecraftClient.getInstance().getWindow().getScaledWidth(); + int height = MinecraftClient.getInstance().getWindow().getScaledHeight(); + for (int i = 0; i < PIECES_PER_BURST; i++) { + Piece piece = new Piece(); + piece.x = piece.prevX = width / 2f + rng.nextFloat() * 60f - 30f; + piece.y = piece.prevY = height * 0.4f; + piece.vx = rng.nextFloat() * 8f - 4f; + piece.vy = -(rng.nextFloat() * 5f + 3f); + piece.size = 3 + rng.nextInt(3); + piece.color = COLORS[rng.nextInt(COLORS.length)]; + PIECES.add(piece); + } + } + + public static void clear() { + PIECES.clear(); + } + + public static void tick() { + for (Piece piece : PIECES) { + piece.prevX = piece.x; + piece.prevY = piece.y; + piece.vy += GRAVITY; + piece.vx *= 0.98f; + piece.x += piece.vx; + piece.y += piece.vy; + piece.age++; + } + PIECES.removeIf(p -> p.age >= LIFETIME_TICKS); + } + + public static void render(DrawContext ctx, float partialTick) { + for (Piece piece : PIECES) { + float x = piece.prevX + (piece.x - piece.prevX) * partialTick; + float y = piece.prevY + (piece.y - piece.prevY) * partialTick; + int alpha = Math.min(255, (LIFETIME_TICKS - piece.age) * 20); + if (alpha < 8) { + continue; + } + int color = MobileUI.withAlpha(piece.color, alpha); + ctx.fill(Math.round(x), Math.round(y), Math.round(x) + piece.size, Math.round(y) + piece.size, color); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/hud/HudRenderer.java b/src/main/java/pro/wihuk/arigadam/combocoal/hud/HudRenderer.java new file mode 100644 index 0000000..f516823 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/hud/HudRenderer.java @@ -0,0 +1,115 @@ +package pro.wihuk.arigadam.combocoal.hud; + +import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.render.RenderTickCounter; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.combo.Rank; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; +import pro.wihuk.arigadam.combocoal.guide.GuideHud; +import pro.wihuk.arigadam.combocoal.progress.Progress; +import pro.wihuk.arigadam.combocoal.progress.SaveData; +import pro.wihuk.arigadam.combocoal.stats.TeamCombo; +import pro.wihuk.arigadam.combocoal.tools.DurabilityWatcher; + +import java.util.concurrent.ThreadLocalRandom; + +/** Draws the whole mobile-game overlay: top bar, combo counter, popups, confetti and warnings. */ +public final class HudRenderer { + private static final int SHAKE_START_COMBO = 25; + + private HudRenderer() { + } + + public static void register() { + HudRenderCallback.EVENT.register(HudRenderer::render); + } + + private static void render(DrawContext ctx, RenderTickCounter tickCounter) { + MinecraftClient client = MinecraftClient.getInstance(); + if (client.player == null || client.options.hudHidden) { + return; + } + ComboCoalConfig config = ComboCoalConfig.get(); + float partial = tickCounter.getTickDelta(false); + + Confetti.render(ctx, partial); + + float scale = config.hudScale; + int width = (int) (ctx.getScaledWindowWidth() / scale); + int height = (int) (ctx.getScaledWindowHeight() / scale); + MatrixStack matrices = ctx.getMatrices(); + matrices.push(); + matrices.scale(scale, scale, 1f); + applyShake(matrices, config); + + drawTopBar(ctx); + drawCombo(ctx, width, height, partial); + Popups.render(ctx, width - 80, height / 2f - 50f, partial); + GuideHud.render(ctx, width, height); + DurabilityWatcher.render(ctx, width, height); + + matrices.pop(); + } + + /** Random per-frame offset that grows with the combo; moves the HUD only, never the camera. */ + private static void applyShake(MatrixStack matrices, ComboCoalConfig config) { + int combo = ComboManager.combo(); + if (!config.hapticShake || combo < SHAKE_START_COMBO) { + return; + } + float amplitude = Math.min(4f, 1f + (combo - SHAKE_START_COMBO) / 10f); + ThreadLocalRandom rng = ThreadLocalRandom.current(); + matrices.translate((rng.nextFloat() - 0.5f) * 2f * amplitude, (rng.nextFloat() - 0.5f) * 2f * amplitude, 0f); + } + + private static void drawTopBar(DrawContext ctx) { + SaveData data = Progress.data(); + int x = 6; + int y = 6; + MobileUI.panel(ctx, x, y, 196, 22); + MobileUI.outlinedText(ctx, Text.translatable("combocoal.hud.level", data.level), x + 6, y + 7, 0xFFFFFFFF); + MobileUI.bar(ctx, x + 44, y + 7, 74, 8, data.xp / (float) Progress.xpForNextLevel(), 0xFF55FFFF); + // A small gold coin icon followed by the balance. + ctx.fill(x + 128, y + 6, x + 136, y + 14, 0xFF000000); + ctx.fill(x + 129, y + 7, x + 135, y + 13, 0xFFFFD700); + ctx.fill(x + 130, y + 8, x + 132, y + 10, 0xFFFFF0A0); + MobileUI.outlinedText(ctx, Text.literal(String.valueOf(data.coins)), x + 141, y + 7, 0xFFFFD700); + } + + private static void drawCombo(DrawContext ctx, int width, int height, float partial) { + int combo = ComboManager.combo(); + if (combo <= 0) { + return; + } + Rank rank = ComboManager.rank(); + int color = rank == Rank.SSS ? MobileUI.rainbow(0f) : rank.color; + float centerY = height / 2f; + float right = width - 14f; + + // Elastic pop: starts big, undershoots slightly, settles at 1.0. + float pop = ComboManager.pop(partial); + float popScale = 1f + 0.8f * (1f - MobileUI.easeOutBack(1f - pop)); + + Text number = Text.translatable("combocoal.hud.combo", combo); + int panelWidth = Math.max(130, (int) (MobileUI.font().getWidth(number) * 3f) + 24); + MobileUI.panel(ctx, (int) right - panelWidth + 8, (int) centerY - 62, panelWidth, 110); + + MobileUI.scaledText(ctx, number, right, centerY - 36f, 3f * popScale, color, 1f); + MobileUI.scaledText(ctx, Text.translatable("combocoal.hud.rank_line", rank.letter(), rank.title()), + right, centerY - 8f, 1.2f, color, 1f); + + float timeLeft = ComboManager.timeLeft(partial); + boolean flashing = timeLeft < 0.25f && (System.currentTimeMillis() / 150) % 2 == 0; + MobileUI.bar(ctx, (int) right - 100, (int) centerY + 6, 100, 6, timeLeft, flashing ? 0xFFFF5555 : color); + MobileUI.scaledText(ctx, Text.translatable("combocoal.hud.best", Progress.data().bestCombo), + right, centerY + 24f, 0.9f, 0xFFAAAAAA, 1f); + if (TeamCombo.active()) { + MobileUI.scaledText(ctx, Text.translatable("combocoal.hud.team", TeamCombo.players()), + right, centerY + 34f, 0.9f, 0xFF55FFFF, 1f); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/hud/MobileUI.java b/src/main/java/pro/wihuk/arigadam/combocoal/hud/MobileUI.java new file mode 100644 index 0000000..7b1f1a0 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/hud/MobileUI.java @@ -0,0 +1,91 @@ +package pro.wihuk.arigadam.combocoal.hud; + +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; + +import java.awt.Color; + +/** Drawing helpers for the chunky, mobile-game look: panels, bars and outlined text. */ +public final class MobileUI { + public static final int PANEL_FILL = 0xCC1B1B2F; + public static final int PANEL_BORDER = 0xFF000000; + + private MobileUI() { + } + + public static TextRenderer font() { + return MinecraftClient.getInstance().textRenderer; + } + + public static float easeOutBack(float t) { + float c1 = 1.70158f; + float c3 = c1 + 1f; + float u = t - 1f; + return 1f + c3 * u * u * u + c1 * u * u; + } + + /** A fully saturated color that cycles over time, for the SSS rank. */ + public static int rainbow(float offset) { + float hue = ((System.currentTimeMillis() % 2000L) / 2000f + offset) % 1f; + return Color.HSBtoRGB(hue, 0.75f, 1f) | 0xFF000000; + } + + public static int withAlpha(int color, int alpha) { + return (Math.max(0, Math.min(255, alpha)) << 24) | (color & 0xFFFFFF); + } + + /** Text with a 1px black outline; the outline takes the alpha of the given color. */ + public static void outlinedText(DrawContext ctx, Text text, int x, int y, int color) { + TextRenderer font = font(); + int outline = color & 0xFF000000; + for (int dx = -1; dx <= 1; dx++) { + for (int dy = -1; dy <= 1; dy++) { + if (dx != 0 || dy != 0) { + ctx.drawText(font, text, x + dx, y + dy, outline, false); + } + } + } + ctx.drawText(font, text, x, y, color, false); + } + + /** + * Draws outlined text scaled around its anchor point. {@code ax} is the horizontal anchor + * (0 = x is the left edge, 0.5 = center, 1 = right edge); y is the vertical center. + */ + public static void scaledText(DrawContext ctx, Text text, float x, float y, float scale, int color, float ax) { + TextRenderer font = font(); + MatrixStack matrices = ctx.getMatrices(); + matrices.push(); + matrices.translate(x, y, 0f); + matrices.scale(scale, scale, 1f); + outlinedText(ctx, text, Math.round(-font.getWidth(text) * ax), -font.fontHeight / 2, color); + matrices.pop(); + } + + /** A chunky panel with a dark outline, a light top edge and a shaded bottom edge. */ + public static void panel(DrawContext ctx, int x, int y, int w, int h, int fill) { + ctx.fill(x - 1, y, x + w + 1, y + h, PANEL_BORDER); + ctx.fill(x, y - 1, x + w, y + h + 1, PANEL_BORDER); + ctx.fill(x, y, x + w, y + h, fill); + ctx.fill(x, y, x + w, y + 2, 0x30FFFFFF); + ctx.fill(x, y + h - 2, x + w, y + h, 0x30000000); + } + + public static void panel(DrawContext ctx, int x, int y, int w, int h) { + panel(ctx, x, y, w, h, PANEL_FILL); + } + + /** A progress bar; {@code fraction} is clamped to 0..1. */ + public static void bar(DrawContext ctx, int x, int y, int w, int h, float fraction, int color) { + ctx.fill(x - 1, y - 1, x + w + 1, y + h + 1, PANEL_BORDER); + ctx.fill(x, y, x + w, y + h, 0xFF2A2A3A); + int filled = Math.round(w * Math.max(0f, Math.min(1f, fraction))); + if (filled > 0) { + ctx.fill(x, y, x + filled, y + h, color | 0xFF000000); + ctx.fill(x, y, x + filled, y + Math.max(1, h / 3), 0x50FFFFFF); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/hud/Popups.java b/src/main/java/pro/wihuk/arigadam/combocoal/hud/Popups.java new file mode 100644 index 0000000..40eb2d3 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/hud/Popups.java @@ -0,0 +1,62 @@ +package pro.wihuk.arigadam.combocoal.hud; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.Text; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; + +/** Floating text popups that rise and fade over one second. */ +public final class Popups { + private static final int LIFETIME_TICKS = 20; + private static final List ACTIVE = new ArrayList<>(); + + private Popups() { + } + + private static final class Popup { + final Text text; + final int color; + final float xOffset; + final int slot; + int age; + + Popup(Text text, int color, float xOffset, int slot) { + this.text = text; + this.color = color; + this.xOffset = xOffset; + this.slot = slot; + } + } + + public static void add(Text text, int color) { + // Popups spawned within a few ticks of each other are stacked instead of overlapping. + int slot = (int) ACTIVE.stream().filter(p -> p.age < 6).count(); + float xOffset = ThreadLocalRandom.current().nextFloat() * 40f - 20f; + ACTIVE.add(new Popup(text, color, xOffset, slot)); + } + + public static void clear() { + ACTIVE.clear(); + } + + public static void tick() { + ACTIVE.removeIf(p -> ++p.age >= LIFETIME_TICKS); + } + + /** Draws the popups rising from the given anchor point. */ + public static void render(DrawContext ctx, float anchorX, float anchorY, float partialTick) { + for (Popup popup : ACTIVE) { + float t = Math.min(1f, (popup.age + partialTick) / LIFETIME_TICKS); + int alpha = Math.round(255 * (1f - t * t)); + if (alpha < 8) { + continue; + } + float rise = 36f * (1f - (1f - t) * (1f - t)); + float scale = 1.4f * (0.6f + 0.4f * MobileUI.easeOutBack(Math.min(1f, t * 5f))); + MobileUI.scaledText(ctx, popup.text, anchorX + popup.xOffset, anchorY - rise - popup.slot * 14f, scale, + MobileUI.withAlpha(popup.color, alpha), 0.5f); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/hud/QuestScreen.java b/src/main/java/pro/wihuk/arigadam/combocoal/hud/QuestScreen.java new file mode 100644 index 0000000..18593f6 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/hud/QuestScreen.java @@ -0,0 +1,88 @@ +package pro.wihuk.arigadam.combocoal.hud; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.screen.ScreenTexts; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.progress.Quest; + +/** The daily quest panel, opened with a keybind. */ +public class QuestScreen extends Screen { + private static final int PANEL_WIDTH = 220; + private static final int PANEL_HEIGHT = 120; + private static final int CLAIM_WIDTH = 100; + private static final int CLAIM_HEIGHT = 22; + + public QuestScreen() { + super(Text.translatable("combocoal.quest.title")); + } + + private int left() { + return (width - PANEL_WIDTH) / 2; + } + + private int top() { + return (height - PANEL_HEIGHT) / 2; + } + + private int claimX() { + return left() + (PANEL_WIDTH - CLAIM_WIDTH) / 2; + } + + private int claimY() { + return top() + 80; + } + + @Override + protected void init() { + addDrawable(this::drawPanel); + addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, button -> close()) + .dimensions(width / 2 - 40, top() + PANEL_HEIGHT + 8, 80, 20).build()); + } + + private void drawPanel(DrawContext ctx, int mouseX, int mouseY, float delta) { + int x = left(); + int y = top(); + MobileUI.panel(ctx, x, y, PANEL_WIDTH, PANEL_HEIGHT); + MobileUI.scaledText(ctx, title, x + PANEL_WIDTH / 2f, y + 12, 1.4f, 0xFFFFD700, 0.5f); + MobileUI.scaledText(ctx, Text.translatable("combocoal.quest.goal", Quest.TARGET), + x + PANEL_WIDTH / 2f, y + 32, 1f, 0xFFFFFFFF, 0.5f); + + int progress = Quest.progress(); + MobileUI.bar(ctx, x + 20, y + 44, PANEL_WIDTH - 40, 10, progress / (float) Quest.TARGET, 0xFF55FF55); + MobileUI.scaledText(ctx, Text.translatable("combocoal.quest.progress", progress, Quest.TARGET), + x + PANEL_WIDTH / 2f, y + 64, 0.9f, 0xFFAAAAAA, 0.5f); + + if (Quest.canClaim()) { + float pulse = 1f + 0.08f * (float) Math.sin(System.currentTimeMillis() / 150.0); + int w = Math.round(CLAIM_WIDTH * pulse); + int h = Math.round(CLAIM_HEIGHT * pulse); + int bx = claimX() + (CLAIM_WIDTH - w) / 2; + int by = claimY() + (CLAIM_HEIGHT - h) / 2; + int fill = isOverClaim(mouseX, mouseY) ? 0xFFFFC107 : 0xFFE0A000; + MobileUI.panel(ctx, bx, by, w, h, fill); + MobileUI.scaledText(ctx, Text.translatable("combocoal.quest.claim"), bx + w / 2f, by + h / 2f, 1.2f, 0xFFFFFFFF, 0.5f); + } else if (Quest.isClaimed()) { + MobileUI.scaledText(ctx, Text.translatable("combocoal.quest.claimed"), + x + PANEL_WIDTH / 2f, claimY() + CLAIM_HEIGHT / 2f, 1.1f, 0xFF55FF55, 0.5f); + } else { + MobileUI.scaledText(ctx, Text.translatable("combocoal.quest.reward", Quest.REWARD_COINS, Quest.REWARD_XP), + x + PANEL_WIDTH / 2f, claimY() + CLAIM_HEIGHT / 2f, 0.9f, 0xFFFFD700, 0.5f); + } + } + + private boolean isOverClaim(double mouseX, double mouseY) { + return mouseX >= claimX() && mouseX <= claimX() + CLAIM_WIDTH + && mouseY >= claimY() && mouseY <= claimY() + CLAIM_HEIGHT; + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (button == 0 && Quest.canClaim() && isOverClaim(mouseX, mouseY)) { + Quest.claim(); + return true; + } + return super.mouseClicked(mouseX, mouseY, button); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/maniac/ManiacMode.java b/src/main/java/pro/wihuk/arigadam/combocoal/maniac/ManiacMode.java new file mode 100644 index 0000000..10aa799 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/maniac/ManiacMode.java @@ -0,0 +1,47 @@ +package pro.wihuk.arigadam.combocoal.maniac; + +import net.fabricmc.fabric.api.event.player.AttackBlockCallback; +import net.fabricmc.fabric.api.tag.convention.v2.ConventionalBlockTags; +import net.minecraft.block.BlockState; +import net.minecraft.registry.tag.BlockTags; +import net.minecraft.text.Text; +import net.minecraft.util.ActionResult; +import pro.wihuk.arigadam.combocoal.combo.CoalBlocks; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; + +/** Coal Maniac mode: refuses to break non-coal ores (and, in strict mode, anything but coal and logs). */ +public final class ManiacMode { + private static final int MESSAGE_COOLDOWN_TICKS = 30; + private static long lastMessageTick = Long.MIN_VALUE; + + private ManiacMode() { + } + + public static void register() { + AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> { + ComboCoalConfig config = ComboCoalConfig.get(); + if (!world.isClient || !config.maniacMode) { + return ActionResult.PASS; + } + if (!isForbidden(world.getBlockState(pos), config.strictMode)) { + return ActionResult.PASS; + } + long now = world.getTime(); + if (now - lastMessageTick >= MESSAGE_COOLDOWN_TICKS) { + lastMessageTick = now; + player.sendMessage(Text.translatable("combocoal.maniac.oath"), true); + } + return ActionResult.FAIL; + }); + } + + private static boolean isForbidden(BlockState state, boolean strict) { + if (CoalBlocks.isCoalOre(state)) { + return false; + } + if (strict) { + return !state.isIn(BlockTags.LOGS); + } + return state.isIn(ConventionalBlockTags.ORES); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/pets/PetCat.java b/src/main/java/pro/wihuk/arigadam/combocoal/pets/PetCat.java new file mode 100644 index 0000000..3b4b351 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/pets/PetCat.java @@ -0,0 +1,66 @@ +package pro.wihuk.arigadam.combocoal.pets; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.passive.CatEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DyeColor; +import net.minecraft.util.Hand; +import net.minecraft.world.World; + +/** A purely client-side cat: no AI, no collision, no sound and nothing a player can interact with. */ +public class PetCat extends CatEntity { + public PetCat(World world, DyeColor collar) { + super(EntityType.CAT, world); + setAiDisabled(true); + setNoGravity(true); + setSilent(true); + setInvulnerable(true); + noClip = true; + setTamed(true, false); + // The collar color has no public setter, so it is applied through the NBT reader. + NbtCompound nbt = new NbtCompound(); + nbt.putByte("CollarColor", (byte) collar.getId()); + readCustomDataFromNbt(nbt); + } + + @Override + public boolean canHit() { + return false; + } + + @Override + public boolean isAttackable() { + return false; + } + + @Override + public boolean isPushable() { + return false; + } + + @Override + public void pushAwayFrom(Entity entity) { + } + + @Override + public boolean canBeLeashed() { + return false; + } + + @Override + public ActionResult interactMob(PlayerEntity player, Hand hand) { + return ActionResult.PASS; + } + + @Override + public void playSound(SoundEvent sound, float volume, float pitch) { + } + + @Override + public void playSoundIfNotSilent(SoundEvent event) { + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/pets/PetWolf.java b/src/main/java/pro/wihuk/arigadam/combocoal/pets/PetWolf.java new file mode 100644 index 0000000..5bf1c6a --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/pets/PetWolf.java @@ -0,0 +1,66 @@ +package pro.wihuk.arigadam.combocoal.pets; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.passive.WolfEntity; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.sound.SoundEvent; +import net.minecraft.util.ActionResult; +import net.minecraft.util.DyeColor; +import net.minecraft.util.Hand; +import net.minecraft.world.World; + +/** A purely client-side wolf: no AI, no collision, no sound and nothing a player can interact with. */ +public class PetWolf extends WolfEntity { + public PetWolf(World world, DyeColor collar) { + super(EntityType.WOLF, world); + setAiDisabled(true); + setNoGravity(true); + setSilent(true); + setInvulnerable(true); + noClip = true; + setTamed(true, false); + // The collar color has no public setter, so it is applied through the NBT reader. + NbtCompound nbt = new NbtCompound(); + nbt.putByte("CollarColor", (byte) collar.getId()); + readCustomDataFromNbt(nbt); + } + + @Override + public boolean canHit() { + return false; + } + + @Override + public boolean isAttackable() { + return false; + } + + @Override + public boolean isPushable() { + return false; + } + + @Override + public void pushAwayFrom(Entity entity) { + } + + @Override + public boolean canBeLeashed() { + return false; + } + + @Override + public ActionResult interactMob(PlayerEntity player, Hand hand) { + return ActionResult.PASS; + } + + @Override + public void playSound(SoundEvent sound, float volume, float pitch) { + } + + @Override + public void playSoundIfNotSilent(SoundEvent event) { + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/pets/Pets.java b/src/main/java/pro/wihuk/arigadam/combocoal/pets/Pets.java new file mode 100644 index 0000000..b982bb3 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/pets/Pets.java @@ -0,0 +1,164 @@ +package pro.wihuk.arigadam.combocoal.pets; + +import net.minecraft.block.BlockState; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.entity.Entity; +import net.minecraft.entity.passive.TameableEntity; +import net.minecraft.particle.ParticleEffect; +import net.minecraft.particle.ParticleTypes; +import net.minecraft.util.DyeColor; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; +import net.minecraft.util.shape.VoxelShape; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; + +/** + * Dancing pets: one per 5 combo (max 12), alternating wolf and cat. They are client-side entities + * only: they are added to the ClientWorld, never sent to a server, and removed on every exit path. + */ +public final class Pets { + private static final int MAX_PETS = 12; + private static final int COMBO_PER_PET = 5; + /** 120 BPM = two beats per second = one beat every 10 ticks. */ + private static final int TICKS_PER_BEAT = 10; + private static final double ORBIT_RADIUS = 2.5; + private static final double HOP_HEIGHT = 0.35; + private static final DyeColor[] COLLARS = { + DyeColor.RED, DyeColor.ORANGE, DyeColor.YELLOW, DyeColor.LIME, DyeColor.LIGHT_BLUE, DyeColor.CYAN, + DyeColor.BLUE, DyeColor.PURPLE, DyeColor.MAGENTA, DyeColor.PINK, DyeColor.WHITE, DyeColor.GREEN + }; + + private static final List PETS = new ArrayList<>(); + /** Negative ids can never collide with ids assigned by a server. */ + private static int nextEntityId = -1_000_000; + + private Pets() { + } + + /** Grows or shrinks the pack to match the combo. */ + public static void sync(int combo) { + ClientWorld world = MinecraftClient.getInstance().world; + ClientPlayerEntity player = MinecraftClient.getInstance().player; + if (world == null || player == null || !ComboCoalConfig.get().pets) { + return; + } + int wanted = Math.min(MAX_PETS, combo / COMBO_PER_PET); + while (PETS.size() < wanted) { + spawn(world, player); + } + while (PETS.size() > wanted) { + TameableEntity pet = PETS.remove(PETS.size() - 1); + burst(world, pet, ParticleTypes.HAPPY_VILLAGER, 6); + remove(world, pet); + } + } + + /** The combo was lost: every pet poofs away with sad smoke. */ + public static void poof() { + ClientWorld world = MinecraftClient.getInstance().world; + if (world != null) { + for (TameableEntity pet : PETS) { + burst(world, pet, ParticleTypes.POOF, 4); + burst(world, pet, ParticleTypes.LARGE_SMOKE, 6); + } + } + clear(); + } + + /** Removes every pet without effects. Safe to call at any time, including when no world is loaded. */ + public static void clear() { + ClientWorld world = MinecraftClient.getInstance().world; + if (world != null) { + for (TameableEntity pet : PETS) { + remove(world, pet); + } + } + PETS.clear(); + } + + public static void tick() { + MinecraftClient client = MinecraftClient.getInstance(); + ClientWorld world = client.world; + ClientPlayerEntity player = client.player; + if (world == null || player == null) { + PETS.clear(); + return; + } + if (!ComboCoalConfig.get().pets) { + clear(); + return; + } + // A dimension change replaces the ClientWorld, taking our old entities with it. + if (!PETS.isEmpty() && PETS.get(0).getWorld() != world) { + PETS.clear(); + } + sync(ComboManager.combo()); + dance(world, player); + } + + private static void spawn(ClientWorld world, ClientPlayerEntity player) { + int index = PETS.size(); + DyeColor collar = COLLARS[index % COLLARS.length]; + TameableEntity pet = index % 2 == 0 ? new PetWolf(world, collar) : new PetCat(world, collar); + pet.setId(nextEntityId--); + pet.setPosition(player.getX(), player.getY(), player.getZ()); + world.addEntity(pet); + PETS.add(pet); + burst(world, pet, ParticleTypes.HAPPY_VILLAGER, 4); + } + + private static void remove(ClientWorld world, Entity pet) { + world.removeEntity(pet.getId(), Entity.RemovalReason.DISCARDED); + } + + /** Orbits the pets around the player, hopping and toggling sit/stand on every beat. */ + private static void dance(ClientWorld world, ClientPlayerEntity player) { + long time = world.getTime(); + long beat = time / TICKS_PER_BEAT; + double beatPhase = (time % TICKS_PER_BEAT) / (double) TICKS_PER_BEAT; + double hop = 4 * beatPhase * (1 - beatPhase) * HOP_HEIGHT; + for (int i = 0; i < PETS.size(); i++) { + TameableEntity pet = PETS.get(i); + double angle = Math.PI * 2 * i / PETS.size() + time * 0.05; + double x = player.getX() + Math.cos(angle) * ORBIT_RADIUS; + double z = player.getZ() + Math.sin(angle) * ORBIT_RADIUS; + double y = groundY(world, x, player.getY(), z) + hop; + pet.setPosition(x, y, z); + + float yaw = (float) Math.toDegrees(Math.atan2(x - player.getX(), player.getZ() - z)); + pet.setYaw(yaw); + pet.setBodyYaw(yaw); + pet.setHeadYaw(yaw); + pet.setInSittingPose((beat + i) % 2 == 0); + } + } + + /** Top of the highest solid block within a few blocks of the player's feet, so pets follow the terrain. */ + private static double groundY(ClientWorld world, double x, double playerY, double z) { + int startY = (int) Math.floor(playerY); + for (int y = startY; y >= startY - 3; y--) { + BlockPos pos = BlockPos.ofFloored(x, y, z); + BlockState state = world.getBlockState(pos); + VoxelShape shape = state.getCollisionShape(world, pos); + if (!shape.isEmpty()) { + return y + shape.getMax(Direction.Axis.Y); + } + } + return playerY; + } + + private static void burst(ClientWorld world, Entity pet, ParticleEffect particle, int count) { + ThreadLocalRandom rng = ThreadLocalRandom.current(); + for (int i = 0; i < count; i++) { + world.addParticle(particle, pet.getX() + rng.nextDouble(-0.3, 0.3), pet.getY() + 0.3 + rng.nextDouble(0.5), + pet.getZ() + rng.nextDouble(-0.3, 0.3), 0.0, 0.04, 0.0); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/progress/Progress.java b/src/main/java/pro/wihuk/arigadam/combocoal/progress/Progress.java new file mode 100644 index 0000000..fbc122e --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/progress/Progress.java @@ -0,0 +1,58 @@ +package pro.wihuk.arigadam.combocoal.progress; + +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.audio.Sfx; +import pro.wihuk.arigadam.combocoal.hud.Confetti; +import pro.wihuk.arigadam.combocoal.hud.Popups; + +/** Level, XP and coins. Loaded once at startup and written on world leave and game close. */ +public final class Progress { + private static SaveData data = new SaveData(); + + private Progress() { + } + + public static void load() { + data = SaveData.load(); + Quest.refresh(); + } + + public static void save() { + data.save(); + } + + public static SaveData data() { + return data; + } + + public static int xpForNextLevel() { + return data.level * 100; + } + + /** Called for every coal ore broken, with the combo value after the increment. */ + public static void onCoal(int combo) { + data.totalCoal++; + data.bestCombo = Math.max(data.bestCombo, combo); + addXp(10 + combo); + addCoins(1 + combo / 10); + if (combo % 10 == 0) { + Sfx.coin(); + } + Quest.onCoal(); + } + + public static void addCoins(int amount) { + data.coins += amount; + } + + public static void addXp(int amount) { + data.xp += amount; + while (data.xp >= xpForNextLevel()) { + data.xp -= xpForNextLevel(); + data.level++; + Popups.add(Text.translatable("combocoal.popup.level_up"), 0xFF55FFFF); + Confetti.burst(); + Sfx.levelUp(); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/progress/Quest.java b/src/main/java/pro/wihuk/arigadam/combocoal/progress/Quest.java new file mode 100644 index 0000000..f0734f6 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/progress/Quest.java @@ -0,0 +1,63 @@ +package pro.wihuk.arigadam.combocoal.progress; + +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.audio.Sfx; +import pro.wihuk.arigadam.combocoal.hud.Confetti; +import pro.wihuk.arigadam.combocoal.hud.Popups; + +import java.time.LocalDate; + +/** The daily "Mine 50 coal" quest. Earned purely by playing; there is nothing to buy or wait for. */ +public final class Quest { + public static final int TARGET = 50; + public static final int REWARD_COINS = 50; + public static final int REWARD_XP = 150; + + private Quest() { + } + + /** Starts a fresh quest when the calendar day has changed. */ + public static void refresh() { + SaveData data = Progress.data(); + String today = LocalDate.now().toString(); + if (!today.equals(data.questDate)) { + data.questDate = today; + data.questProgress = 0; + data.questClaimed = false; + } + } + + public static void onCoal() { + refresh(); + SaveData data = Progress.data(); + if (!data.questClaimed && data.questProgress < TARGET) { + data.questProgress++; + } + } + + public static int progress() { + refresh(); + return Progress.data().questProgress; + } + + public static boolean canClaim() { + return progress() >= TARGET && !Progress.data().questClaimed; + } + + public static boolean isClaimed() { + refresh(); + return Progress.data().questClaimed; + } + + public static void claim() { + if (!canClaim()) { + return; + } + Progress.data().questClaimed = true; + Progress.addCoins(REWARD_COINS); + Progress.addXp(REWARD_XP); + Sfx.coin(); + Popups.add(Text.translatable("combocoal.popup.quest_done"), 0xFFFFD700); + Confetti.burst(); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/progress/SaveData.java b/src/main/java/pro/wihuk/arigadam/combocoal/progress/SaveData.java new file mode 100644 index 0000000..37d978f --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/progress/SaveData.java @@ -0,0 +1,53 @@ +package pro.wihuk.arigadam.combocoal.progress; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import net.fabricmc.loader.api.FabricLoader; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; + +/** Everything that persists between sessions, stored as {@code config/combocoal_save.json}. */ +public class SaveData { + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); + private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("combocoal_save.json"); + + public int level = 1; + public int xp = 0; + public int coins = 0; + public int bestCombo = 0; + public long totalCoal = 0; + + /** ISO date of the current quest day; the quest resets when the date changes. */ + public String questDate = ""; + public int questProgress = 0; + public boolean questClaimed = false; + + public int guideStep = 0; + public boolean guideVisible = true; + + public static SaveData load() { + if (Files.exists(PATH)) { + try (Reader reader = Files.newBufferedReader(PATH)) { + SaveData loaded = GSON.fromJson(reader, SaveData.class); + if (loaded != null) { + return loaded; + } + } catch (IOException | RuntimeException e) { + System.err.println("[ComboCoal] Could not read save data, starting fresh: " + e); + } + } + return new SaveData(); + } + + public void save() { + try (Writer writer = Files.newBufferedWriter(PATH)) { + GSON.toJson(this, writer); + } catch (IOException e) { + System.err.println("[ComboCoal] Could not save progress: " + e); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/stats/CaptchaScreen.java b/src/main/java/pro/wihuk/arigadam/combocoal/stats/CaptchaScreen.java new file mode 100644 index 0000000..99e9316 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/stats/CaptchaScreen.java @@ -0,0 +1,100 @@ +package pro.wihuk.arigadam.combocoal.stats; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.gui.widget.TextFieldWidget; +import net.minecraft.screen.ScreenTexts; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.hud.MobileUI; + +/** One-time human check: solve a small sum to get the token the stats server requires. */ +public class CaptchaScreen extends Screen { + private enum State { LOADING, READY, SUBMITTING, SOLVED, FAILED } + + private final Screen parent; + private volatile State state = State.LOADING; + private volatile StatsApi.Captcha captcha; + private volatile boolean wrongAnswer; + private TextFieldWidget answerField; + private ButtonWidget submitButton; + + public CaptchaScreen(Screen parent) { + super(Text.translatable("combocoal.captcha.title")); + this.parent = parent; + } + + @Override + protected void init() { + addDrawable(this::drawPanel); + answerField = addDrawableChild(new TextFieldWidget(textRenderer, width / 2 - 40, height / 2 + 4, 80, 20, + Text.translatable("combocoal.captcha.answer"))); + answerField.setMaxLength(6); + submitButton = addDrawableChild(ButtonWidget.builder(Text.translatable("combocoal.captcha.submit"), button -> submit()) + .dimensions(width / 2 - 50, height / 2 + 30, 100, 20).build()); + addDrawableChild(ButtonWidget.builder(ScreenTexts.CANCEL, button -> close()) + .dimensions(width / 2 - 50, height / 2 + 54, 100, 20).build()); + setInitialFocus(answerField); + if (captcha == null && StatsApi.enabled()) { + load(); + } else if (!StatsApi.enabled()) { + state = State.FAILED; + } + } + + private void load() { + state = State.LOADING; + StatsApi.fetchCaptcha().whenComplete((result, error) -> { + captcha = result; + state = error == null ? State.READY : State.FAILED; + }); + } + + private void submit() { + StatsApi.Captcha current = captcha; + if (state != State.READY || current == null || answerField.getText().isBlank()) { + return; + } + state = State.SUBMITTING; + StatsApi.submitCaptcha(current, answerField.getText()).whenComplete((ignored, error) -> { + if (error == null) { + state = State.SOLVED; + } else { + // A wrong answer needs a fresh challenge. + wrongAnswer = true; + client.execute(() -> answerField.setText("")); + load(); + } + }); + } + + @Override + public void tick() { + submitButton.active = state == State.READY; + if (state == State.SOLVED) { + close(); + } + } + + private void drawPanel(DrawContext ctx, int mouseX, int mouseY, float delta) { + int panelWidth = 240; + int x = (width - panelWidth) / 2; + int y = height / 2 - 60; + MobileUI.panel(ctx, x, y, panelWidth, 140); + MobileUI.scaledText(ctx, title, width / 2f, y + 14, 1.4f, 0xFFFFD700, 0.5f); + Text message = switch (state) { + case LOADING, SUBMITTING -> Text.translatable("combocoal.captcha.loading"); + case READY -> wrongAnswer + ? Text.translatable("combocoal.captcha.wrong", captcha.question()) + : Text.translatable("combocoal.captcha.question", captcha.question()); + case SOLVED -> Text.translatable("combocoal.captcha.solved"); + case FAILED -> Text.translatable("combocoal.captcha.failed"); + }; + MobileUI.scaledText(ctx, message, width / 2f, y + 40, 1.2f, state == State.FAILED || wrongAnswer ? 0xFFFF5555 : 0xFFFFFFFF, 0.5f); + } + + @Override + public void close() { + client.setScreen(parent); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/stats/ConsentScreen.java b/src/main/java/pro/wihuk/arigadam/combocoal/stats/ConsentScreen.java new file mode 100644 index 0000000..f03aa8c --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/stats/ConsentScreen.java @@ -0,0 +1,77 @@ +package pro.wihuk.arigadam.combocoal.stats; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.text.OrderedText; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; +import pro.wihuk.arigadam.combocoal.hud.MobileUI; + +import java.util.ArrayList; +import java.util.List; + +/** Shown once at first launch. Stats stay off unless the player clicks "Yes". */ +public class ConsentScreen extends Screen { + private final Screen parent; + private boolean answered; + + public ConsentScreen(Screen parent) { + super(Text.translatable("combocoal.stats.consent.title")); + this.parent = parent; + } + + @Override + protected void init() { + addDrawable(this::drawText); + int y = height - 52; + addDrawableChild(ButtonWidget.builder(Text.translatable("combocoal.stats.consent.yes"), button -> answer(true)) + .dimensions(width / 2 - 154, y, 150, 20).build()); + addDrawableChild(ButtonWidget.builder(Text.translatable("combocoal.stats.consent.no"), button -> answer(false)) + .dimensions(width / 2 + 4, y, 150, 20).build()); + } + + private void drawText(DrawContext ctx, int mouseX, int mouseY, float delta) { + int maxWidth = Math.min(width - 40, 320); + int x = (width - maxWidth) / 2; + MobileUI.scaledText(ctx, title, width / 2f, 24, 1.4f, 0xFFFFD700, 0.5f); + + String endpoint = StatsApi.endpoint(); + List paragraphs = new ArrayList<>(); + paragraphs.add(Text.translatable("combocoal.stats.consent.intro")); + paragraphs.add(Text.translatable("combocoal.stats.consent.data")); + paragraphs.add(Text.translatable("combocoal.stats.consent.captcha")); + paragraphs.add(Text.translatable("combocoal.stats.consent.never")); + paragraphs.add(endpoint == null + ? Text.translatable("combocoal.stats.consent.no_endpoint") + : Text.translatable("combocoal.stats.consent.endpoint", endpoint)); + paragraphs.add(Text.translatable("combocoal.stats.consent.change")); + + int y = 44; + for (Text paragraph : paragraphs) { + for (OrderedText line : textRenderer.wrapLines(paragraph, maxWidth)) { + ctx.drawTextWithShadow(textRenderer, line, x, y, 0xFFFFFFFF); + y += 10; + } + y += 6; + } + } + + private void answer(boolean share) { + ComboCoalConfig config = ComboCoalConfig.get(); + config.statsOptIn = share; + config.statsConsentShown = true; + ComboCoalConfig.save(); + answered = true; + // Opting in leads straight to the one-time captcha; opting out just returns. + client.setScreen(share ? new CaptchaScreen(parent) : parent); + } + + @Override + public void close() { + // Closing without answering counts as "No thanks". + if (!answered) { + answer(false); + } + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/stats/HelpServersScreen.java b/src/main/java/pro/wihuk/arigadam/combocoal/stats/HelpServersScreen.java new file mode 100644 index 0000000..1b70965 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/stats/HelpServersScreen.java @@ -0,0 +1,109 @@ +package pro.wihuk.arigadam.combocoal.stats; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.multiplayer.ConnectScreen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.network.ServerAddress; +import net.minecraft.client.network.ServerInfo; +import net.minecraft.screen.ScreenTexts; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.hud.MobileUI; + +import java.util.List; + +/** Servers where ComboCoal players recently asked for help (low pickaxe at a high combo). */ +public class HelpServersScreen extends Screen { + private static final int ROW_HEIGHT = 24; + + private final Screen parent; + private volatile List servers; + private volatile boolean failed; + private boolean rowsBuilt; + + public HelpServersScreen(Screen parent) { + super(Text.translatable("combocoal.help.title")); + this.parent = parent; + } + + @Override + protected void init() { + rowsBuilt = false; + addDrawable(this::drawPanel); + addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, button -> close()) + .dimensions(width / 2 - 50, height - 32, 100, 20).build()); + if (servers == null && StatsApi.enabled()) { + StatsClient.fetchHelpServers().whenComplete((result, error) -> { + if (error != null) { + failed = true; + } else { + servers = result; + } + }); + } + } + + /** Join buttons can only be added from the render thread once the list has arrived. */ + @Override + public void tick() { + List list = servers; + if (list == null || rowsBuilt) { + return; + } + rowsBuilt = true; + for (int i = 0; i < list.size(); i++) { + String address = list.get(i).server(); + addDrawableChild(ButtonWidget.builder(Text.translatable("combocoal.help.join"), button -> join(address)) + .dimensions(width / 2 + 112, rowTop() + i * ROW_HEIGHT, 40, 18).build()); + } + } + + private int rowTop() { + return height / 2 - 70; + } + + private void join(String address) { + ConnectScreen.connect(this, client, ServerAddress.parse(address), + new ServerInfo(address, address, ServerInfo.ServerType.OTHER), false, null); + } + + private void drawPanel(DrawContext ctx, int mouseX, int mouseY, float delta) { + int panelWidth = 330; + int x = (width - panelWidth) / 2; + MobileUI.panel(ctx, x, rowTop() - 40, panelWidth, 220); + MobileUI.scaledText(ctx, title, width / 2f, rowTop() - 24, 1.4f, 0xFFFFD700, 0.5f); + + List list = servers; + if (!StatsApi.enabled()) { + drawMessage(ctx, Text.translatable("combocoal.leaderboard.disabled"), x); + } else if (failed) { + drawMessage(ctx, Text.translatable("combocoal.leaderboard.error"), x); + } else if (list == null) { + drawMessage(ctx, Text.translatable("combocoal.leaderboard.loading"), x); + } else if (list.isEmpty()) { + drawMessage(ctx, Text.translatable("combocoal.help.empty"), x); + } else { + for (int i = 0; i < list.size(); i++) { + StatsClient.HelpServer row = list.get(i); + int y = rowTop() + i * ROW_HEIGHT; + MobileUI.outlinedText(ctx, Text.translatable("combocoal.help.mark"), x + 10, y + 1, 0xFFFF5555); + MobileUI.outlinedText(ctx, Text.literal(row.server()), x + 46, y + 1, 0xFFFFFFFF); + ctx.drawTextWithShadow(textRenderer, Text.translatable("combocoal.help.row", row.helpers(), row.combo()), + x + 46, y + 11, 0xFFAAAAAA); + } + } + } + + private void drawMessage(DrawContext ctx, Text message, int x) { + int y = rowTop(); + for (var line : textRenderer.wrapLines(message, 250)) { + ctx.drawTextWithShadow(textRenderer, line, x + 14, y, 0xFFAAAAAA); + y += 10; + } + } + + @Override + public void close() { + client.setScreen(parent); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/stats/LeaderboardScreen.java b/src/main/java/pro/wihuk/arigadam/combocoal/stats/LeaderboardScreen.java new file mode 100644 index 0000000..0284107 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/stats/LeaderboardScreen.java @@ -0,0 +1,80 @@ +package pro.wihuk.arigadam.combocoal.stats; + +import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.screen.ScreenTexts; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; +import pro.wihuk.arigadam.combocoal.hud.MobileUI; + +import java.util.List; + +/** Shows the top entries of the configured leaderboard endpoint. Only fetches when stats are opted in. */ +public class LeaderboardScreen extends Screen { + private final Screen parent; + private volatile List entries; + private volatile boolean failed; + + public LeaderboardScreen(Screen parent) { + super(Text.translatable("combocoal.leaderboard.title")); + this.parent = parent; + } + + @Override + protected void init() { + addDrawable(this::drawBoard); + addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, button -> close()) + .dimensions(width / 2 - 50, height - 32, 100, 20).build()); + if (entries == null && canFetch()) { + StatsClient.fetchLeaderboard().whenComplete((result, error) -> { + if (error != null) { + failed = true; + } else { + entries = result; + } + }); + } + } + + private static boolean canFetch() { + return StatsApi.enabled(); + } + + private void drawBoard(DrawContext ctx, int mouseX, int mouseY, float delta) { + int panelWidth = 260; + int panelHeight = 150; + int x = (width - panelWidth) / 2; + int y = (height - panelHeight) / 2 - 10; + MobileUI.panel(ctx, x, y, panelWidth, panelHeight); + MobileUI.scaledText(ctx, title, width / 2f, y + 14, 1.4f, 0xFFFFD700, 0.5f); + + List rows = entries; + if (!canFetch()) { + drawMessage(ctx, Text.translatable("combocoal.leaderboard.disabled"), x, y, panelWidth); + } else if (failed) { + drawMessage(ctx, Text.translatable("combocoal.leaderboard.error"), x, y, panelWidth); + } else if (rows == null) { + drawMessage(ctx, Text.translatable("combocoal.leaderboard.loading"), x, y, panelWidth); + } else { + for (int i = 0; i < rows.size(); i++) { + StatsClient.Entry row = rows.get(i); + Text line = Text.translatable("combocoal.leaderboard.row", i + 1, row.player(), row.coal(), row.bestCombo()); + MobileUI.outlinedText(ctx, line, x + 12, y + 30 + i * 11, i == 0 ? 0xFFFFD700 : 0xFFFFFFFF); + } + } + } + + private void drawMessage(DrawContext ctx, Text message, int x, int y, int panelWidth) { + int lineY = y + 40; + for (var line : textRenderer.wrapLines(message, panelWidth - 24)) { + ctx.drawTextWithShadow(textRenderer, line, x + 12, lineY, 0xFFAAAAAA); + lineY += 10; + } + } + + @Override + public void close() { + client.setScreen(parent); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsApi.java b/src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsApi.java new file mode 100644 index 0000000..0999647 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsApi.java @@ -0,0 +1,147 @@ +package pro.wihuk.arigadam.combocoal.stats; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; +import pro.wihuk.arigadam.combocoal.config.ComboCoalConfig; + +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.time.Duration; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +/** + * Small HTTP client for the optional stats server. Everything runs on a background thread with + * short timeouts. Protected requests carry the captcha token plus a proof of work: the server hands + * out a challenge and we must find a nonce whose SHA-256 hash starts with enough zero bits. + */ +public final class StatsApi { + private static final Duration TIMEOUT = Duration.ofSeconds(5); + private static final int MAX_POW_DIFFICULTY = 24; + private static final HttpClient HTTP = HttpClient.newBuilder().connectTimeout(TIMEOUT).build(); + private static final ExecutorService WORKER = Executors.newSingleThreadExecutor(runnable -> { + Thread thread = new Thread(runnable, "ComboCoal-Stats"); + thread.setDaemon(true); + return thread; + }); + + private StatsApi() { + } + + public record Captcha(String id, String question) { + } + + /** The configured endpoint without a trailing slash, or null if stats cannot be used. */ + public static String endpoint() { + String endpoint = ComboCoalConfig.get().statsEndpoint.trim(); + if (!endpoint.toLowerCase().startsWith("https://")) { + return null; + } + return endpoint.endsWith("/") ? endpoint.substring(0, endpoint.length() - 1) : endpoint; + } + + /** True when the player opted in and an https endpoint is configured. */ + public static boolean enabled() { + return ComboCoalConfig.get().statsOptIn && endpoint() != null; + } + + public static boolean hasToken() { + return !ComboCoalConfig.get().statsToken.isEmpty(); + } + + public static CompletableFuture getJson(String path) { + return CompletableFuture.supplyAsync(() -> requestJson(HttpRequest.newBuilder(URI.create(endpoint() + path)).GET()), WORKER); + } + + public static CompletableFuture fetchCaptcha() { + return getJson("/captcha").thenApply(json -> { + JsonObject object = json.getAsJsonObject(); + return new Captcha(object.get("id").getAsString(), object.get("question").getAsString()); + }); + } + + /** Sends the answer; on success the returned token is stored in the config. */ + public static CompletableFuture submitCaptcha(Captcha captcha, String answer) { + JsonObject body = new JsonObject(); + body.addProperty("id", captcha.id()); + body.addProperty("answer", answer.trim()); + return CompletableFuture.supplyAsync(() -> { + HttpRequest.Builder request = HttpRequest.newBuilder(URI.create(endpoint() + "/captcha")) + .header("Content-Type", "application/json") + .POST(HttpRequest.BodyPublishers.ofString(body.toString())); + ComboCoalConfig.get().statsToken = requestJson(request).getAsJsonObject().get("token").getAsString(); + ComboCoalConfig.save(); + return null; + }, WORKER); + } + + /** POSTs JSON to a protected endpoint after solving a proof of work. Completes exceptionally on failure. */ + public static CompletableFuture postProtected(String path, JsonObject body) { + return postProtectedJson(path, "/pow", body).thenApply(response -> null); + } + + /** Like {@link #postProtected} but returns the response, using the given proof-of-work challenge path. */ + public static CompletableFuture postProtectedJson(String path, String powPath, JsonObject body) { + return CompletableFuture.supplyAsync(() -> { + JsonObject pow = requestJson(HttpRequest.newBuilder(URI.create(endpoint() + powPath)).GET()).getAsJsonObject(); + String challenge = pow.get("challenge").getAsString(); + int difficulty = Math.min(MAX_POW_DIFFICULTY, pow.get("difficulty").getAsInt()); + HttpRequest.Builder request = HttpRequest.newBuilder(URI.create(endpoint() + path)) + .header("Content-Type", "application/json") + .header("X-Token", ComboCoalConfig.get().statsToken) + .header("X-Pow-Challenge", challenge) + .header("X-Pow-Nonce", Long.toString(solve(challenge, difficulty))) + .POST(HttpRequest.BodyPublishers.ofString(body.toString())); + return requestJson(request).getAsJsonObject(); + }, WORKER); + } + + private static JsonElement requestJson(HttpRequest.Builder builder) { + try { + HttpResponse response = HTTP.send(builder.timeout(TIMEOUT).build(), HttpResponse.BodyHandlers.ofString()); + if (response.statusCode() != 200) { + throw new IllegalStateException("HTTP " + response.statusCode()); + } + return JsonParser.parseString(response.body()); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new IllegalStateException(e); + } catch (java.io.IOException e) { + throw new IllegalStateException(e); + } + } + + /** Finds a nonce so that sha256(challenge + ":" + nonce) has at least {@code difficulty} leading zero bits. */ + static long solve(String challenge, int difficulty) { + try { + MessageDigest digest = MessageDigest.getInstance("SHA-256"); + for (long nonce = 0; ; nonce++) { + byte[] hash = digest.digest((challenge + ":" + nonce).getBytes(StandardCharsets.UTF_8)); + if (leadingZeroBits(hash) >= difficulty) { + return nonce; + } + } + } catch (NoSuchAlgorithmException e) { + throw new IllegalStateException(e); + } + } + + private static int leadingZeroBits(byte[] hash) { + int bits = 0; + for (byte value : hash) { + if (value == 0) { + bits += 8; + } else { + return bits + Integer.numberOfLeadingZeros(value & 0xFF) - 24; + } + } + return bits; + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsClient.java b/src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsClient.java new file mode 100644 index 0000000..207d63d --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/stats/StatsClient.java @@ -0,0 +1,132 @@ +package pro.wihuk.arigadam.combocoal.stats; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ServerInfo; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.progress.Progress; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; + +/** + * Opt-in stats sharing and the "Help!" ping. Nothing is ever sent unless statsOptIn is true, an + * https endpoint is configured and the captcha was solved. The stats payload is exactly: player name, + * coal mined this session, best combo, server address. A help ping is: player name, server address, + * current combo. All requests are asynchronous with short timeouts and never stall the game. + */ +public final class StatsClient { + private static final int PERIODIC_SEND_TICKS = 6000; + private static final int HELP_COOLDOWN_TICKS = 6000; + private static final int LIST_SIZE = 10; + + private static String currentServer = "singleplayer"; + private static int lastSentCoal; + private static int ticks; + private static int lastHelpTick = -HELP_COOLDOWN_TICKS; + + private StatsClient() { + } + + public record Entry(String player, int coal, int bestCombo) { + } + + public record HelpServer(String server, int helpers, int combo) { + } + + public static void register() { + ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> { + ServerInfo server = client.getCurrentServerEntry(); + currentServer = server == null ? "singleplayer" : server.address; + }); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> sendStats()); + ClientTickEvents.END_CLIENT_TICK.register(client -> { + ticks++; + if (client.player != null && ticks % PERIODIC_SEND_TICKS == 0) { + sendStats(); + } + }); + ClientLifecycleEvents.CLIENT_STOPPING.register(client -> { + // Give the final report a brief chance to leave before the JVM exits. + try { + CompletableFuture done = sendStats(); + if (done != null) { + done.get(1500, TimeUnit.MILLISECONDS); + } + } catch (Exception ignored) { + // Offline or slow endpoint: dropping the report is fine. + } + }); + } + + /** The server address of the current connection, or "singleplayer". */ + public static String server() { + return currentServer; + } + + public static boolean canSend() { + return StatsApi.enabled() && StatsApi.hasToken(); + } + + /** Sends the session summary, or returns null when opted out, unverified or nothing changed. */ + private static CompletableFuture sendStats() { + int coal = ComboManager.sessionCoal(); + if (!canSend() || coal <= 0 || coal == lastSentCoal) { + return null; + } + lastSentCoal = coal; + JsonObject body = new JsonObject(); + body.addProperty("player", MinecraftClient.getInstance().getSession().getUsername()); + body.addProperty("coal", coal); + body.addProperty("bestCombo", Progress.data().bestCombo); + body.addProperty("server", currentServer); + return StatsApi.postProtected("/stats", body).exceptionally(error -> null); + } + + /** Asks other players for help (pickaxe about to break at a high combo). Multiplayer only, rate limited. */ + public static void sendHelp() { + if (!canSend() || currentServer.equals("singleplayer") || ticks - lastHelpTick < HELP_COOLDOWN_TICKS) { + return; + } + lastHelpTick = ticks; + JsonObject body = new JsonObject(); + body.addProperty("player", MinecraftClient.getInstance().getSession().getUsername()); + body.addProperty("server", currentServer); + body.addProperty("combo", ComboManager.combo()); + StatsApi.postProtected("/help", body).exceptionally(error -> null); + } + + /** Fetches the top entries; completes exceptionally if stats are disabled or the endpoint is unreachable. */ + public static CompletableFuture> fetchLeaderboard() { + return fetchList("/leaderboard", row -> new Entry(row.get("player").getAsString(), + row.get("coal").getAsInt(), row.get("bestCombo").getAsInt())); + } + + /** Fetches servers where players recently asked for help. */ + public static CompletableFuture> fetchHelpServers() { + return fetchList("/help", row -> new HelpServer(row.get("server").getAsString(), + row.get("helpers").getAsInt(), row.get("combo").getAsInt())); + } + + private static CompletableFuture> fetchList(String path, java.util.function.Function parser) { + if (!StatsApi.enabled()) { + return CompletableFuture.failedFuture(new IllegalStateException("stats disabled")); + } + return StatsApi.getJson(path).thenApply(json -> { + List result = new ArrayList<>(); + for (JsonElement element : json.getAsJsonArray()) { + result.add(parser.apply(element.getAsJsonObject())); + if (result.size() >= LIST_SIZE) { + break; + } + } + return result; + }); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/stats/TeamCombo.java b/src/main/java/pro/wihuk/arigadam/combocoal/stats/TeamCombo.java new file mode 100644 index 0000000..6fc6fa2 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/stats/TeamCombo.java @@ -0,0 +1,101 @@ +package pro.wihuk.arigadam.combocoal.stats; + +import com.google.gson.JsonObject; +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; +import net.minecraft.client.MinecraftClient; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; + +/** + * Shared combo for players on the same multiplayer server. Only active for players who opted in to + * stats (and solved the captcha). Every second the coal broken since the last sync is reported and + * the server answers with the team combo, which then drives the local combo. If the server stops + * answering the mod falls back to the normal personal combo after a few seconds. + */ +public final class TeamCombo { + private static final int SYNC_INTERVAL_TICKS = 20; + private static final int STALE_TICKS = 100; + /** Matches the per-sync cap on the server. */ + private static final int MAX_PENDING_HITS = 20; + + private static int ticks; + private static int pendingHits; + private static int lastSuccessTick = Integer.MIN_VALUE; + private static boolean inFlight; + private static int players = 1; + + private TeamCombo() { + } + + public static void register() { + ClientTickEvents.END_CLIENT_TICK.register(TeamCombo::tick); + ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> reset()); + } + + /** True while the combo is driven by the shared team combo. */ + public static boolean active() { + return ticks - lastSuccessTick <= STALE_TICKS; + } + + public static int players() { + return players; + } + + /** Called for every coal this player breaks. */ + public static void onHit() { + if (isEligible()) { + pendingHits = Math.min(MAX_PENDING_HITS, pendingHits + 1); + } + } + + private static boolean isEligible() { + return StatsClient.canSend() && !StatsClient.server().equals("singleplayer"); + } + + private static void reset() { + pendingHits = 0; + lastSuccessTick = Integer.MIN_VALUE; + inFlight = false; + players = 1; + ComboManager.setTeamControlled(false); + } + + private static void tick(MinecraftClient client) { + ticks++; + if (client.player == null || !isEligible()) { + if (lastSuccessTick != Integer.MIN_VALUE) { + reset(); + } + return; + } + if (!active()) { + ComboManager.setTeamControlled(false); + } + if (ticks % SYNC_INTERVAL_TICKS != 0 || inFlight) { + return; + } + int sent = pendingHits; + pendingHits = 0; + inFlight = true; + JsonObject body = new JsonObject(); + body.addProperty("player", client.getSession().getUsername()); + body.addProperty("server", StatsClient.server()); + body.addProperty("hits", sent); + StatsApi.postProtectedJson("/team/sync", "/pow?scope=team", body).whenComplete((response, error) -> + client.execute(() -> onResponse(response, error, sent))); + } + + /** Runs on the client thread. Hits made while the request was in flight are added on top. */ + private static void onResponse(JsonObject response, Throwable error, int sent) { + inFlight = false; + if (error != null || response == null) { + // Keep the unsent hits for the next attempt. + pendingHits = Math.min(MAX_PENDING_HITS, pendingHits + sent); + return; + } + lastSuccessTick = ticks; + players = Math.max(1, response.get("players").getAsInt()); + ComboManager.setTeamControlled(true); + ComboManager.applyTeamCombo(response.get("combo").getAsInt() + pendingHits); + } +} diff --git a/src/main/java/pro/wihuk/arigadam/combocoal/tools/DurabilityWatcher.java b/src/main/java/pro/wihuk/arigadam/combocoal/tools/DurabilityWatcher.java new file mode 100644 index 0000000..62ac244 --- /dev/null +++ b/src/main/java/pro/wihuk/arigadam/combocoal/tools/DurabilityWatcher.java @@ -0,0 +1,91 @@ +package pro.wihuk.arigadam.combocoal.tools; + +import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.DrawContext; +import net.minecraft.component.DataComponentTypes; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.text.Text; +import pro.wihuk.arigadam.combocoal.audio.Sfx; +import pro.wihuk.arigadam.combocoal.combo.ComboManager; +import pro.wihuk.arigadam.combocoal.hud.MobileUI; +import pro.wihuk.arigadam.combocoal.hud.Popups; +import pro.wihuk.arigadam.combocoal.stats.StatsClient; + +/** Warns when the held tool is below 10% durability and rewards repairing it. */ +public final class DurabilityWatcher { + private static final float LOW_FRACTION = 0.10f; + private static final int ALARM_INTERVAL_TICKS = 40; + private static final int REPAIR_COMBO_BONUS = 3; + /** A low tool at this combo or higher also sends an opt-in "Help!" ping. */ + private static final int HELP_MIN_COMBO = 20; + + private static boolean warning; + private static Text toolName = Text.empty(); + private static int ticks; + /** Identifies the low tool (slot, item, max damage) so a later repair of that same tool is noticed. */ + private static String lowKey; + + private DurabilityWatcher() { + } + + public static void register() { + ClientTickEvents.END_CLIENT_TICK.register(DurabilityWatcher::tick); + } + + private static void tick(MinecraftClient client) { + PlayerEntity player = client.player; + if (player == null) { + warning = false; + lowKey = null; + return; + } + ItemStack stack = player.getMainHandStack(); + if (!stack.isDamageable() || !stack.contains(DataComponentTypes.TOOL)) { + warning = false; + return; + } + String key = player.getInventory().selectedSlot + ":" + stack.getItem() + ":" + stack.getMaxDamage(); + float remaining = (stack.getMaxDamage() - stack.getDamage()) / (float) stack.getMaxDamage(); + if (remaining < LOW_FRACTION) { + if (!warning) { + ticks = 0; + } + warning = true; + lowKey = key; + toolName = stack.getName(); + // Rate limited inside StatsClient, so checking every tick is cheap. + if (ComboManager.combo() >= HELP_MIN_COMBO) { + StatsClient.sendHelp(); + } + if (ticks++ % ALARM_INTERVAL_TICKS == 0) { + Sfx.alarm(); + } + return; + } + warning = false; + if (key.equals(lowKey)) { + lowKey = null; + ComboManager.addBonus(REPAIR_COMBO_BONUS); + Popups.add(Text.translatable("combocoal.popup.repaired", REPAIR_COMBO_BONUS), 0xFF55FF55); + Sfx.repaired(); + } + } + + public static void render(DrawContext ctx, int width, int height) { + if (!warning) { + return; + } + boolean bright = (System.currentTimeMillis() / 250) % 2 == 0; + int fill = bright ? 0xDDB01010 : 0xDD600808; + int panelWidth = 220; + int x = (width - panelWidth) / 2; + int y = 40; + MobileUI.panel(ctx, x, y, panelWidth, 30, fill); + MobileUI.scaledText(ctx, Text.translatable("combocoal.durability.warning", toolName), + width / 2f, y + 10, 1f, 0xFFFFFFFF, 0.5f); + MobileUI.scaledText(ctx, Text.translatable("combocoal.durability.hint"), + width / 2f, y + 21, 0.8f, 0xFFFFDDDD, 0.5f); + } +} diff --git a/src/main/resources/assets/combocoal/lang/en_us.json b/src/main/resources/assets/combocoal/lang/en_us.json new file mode 100644 index 0000000..b983c28 --- /dev/null +++ b/src/main/resources/assets/combocoal/lang/en_us.json @@ -0,0 +1,112 @@ +{ + "key.categories.combocoal": "ComboCoal", + "key.combocoal.quest": "Open daily quest", + "key.combocoal.guide": "Toggle coal guide", + "key.combocoal.config": "Open ComboCoal settings", + + "combocoal.rank.c.letter": "C", + "combocoal.rank.c.title": "COAL!", + "combocoal.rank.b.letter": "B", + "combocoal.rank.b.title": "NICE VEIN!", + "combocoal.rank.a.letter": "A", + "combocoal.rank.a.title": "COAL-ASSAULT!", + "combocoal.rank.s.letter": "S", + "combocoal.rank.s.title": "UNSTOPPABLE!", + "combocoal.rank.sss.letter": "SSS", + "combocoal.rank.sss.title": "COAL MANIAC!!!", + + "combocoal.hud.level": "Lv. %s", + "combocoal.hud.combo": "x%s", + "combocoal.hud.rank_line": "[%s] %s", + "combocoal.hud.best": "Best: x%s", + "combocoal.hud.team": "TEAM: %s players", + + "combocoal.popup.coal": "+1 Coal", + "combocoal.popup.great": "GREAT!", + "combocoal.popup.rank_up": "RANK UP!", + "combocoal.popup.level_up": "LEVEL UP!", + "combocoal.popup.combo_lost": "COMBO LOST", + "combocoal.popup.quest_done": "QUEST COMPLETE!", + "combocoal.popup.repaired": "REPAIRED! +%s combo", + + "combocoal.quest.title": "Daily Quest", + "combocoal.quest.goal": "Mine %s coal", + "combocoal.quest.progress": "%s / %s", + "combocoal.quest.claim": "CLAIM!", + "combocoal.quest.claimed": "Claimed - see you tomorrow!", + "combocoal.quest.reward": "Reward: %s coins + %s XP", + + "combocoal.maniac.oath": "You swore an oath to coal!", + + "combocoal.guide.header": "Coal Guide", + "combocoal.guide.step.logs": "Punch a tree and collect some logs", + "combocoal.guide.step.crafting_table": "Craft a crafting table", + "combocoal.guide.step.wooden_pickaxe": "Craft a wooden pickaxe", + "combocoal.guide.step.stone_pickaxe": "Mine cobblestone and craft a stone pickaxe", + "combocoal.guide.step.find_coal": "Find a coal ore vein", + "combocoal.guide.step.mine_vein": "Mine the vein (%s / %s coal)", + "combocoal.guide.step.craft_torches": "Craft some torches (coal + stick)", + "combocoal.guide.step.done": "Guide complete! Now go grind that combo!", + "combocoal.guide.nearest": "Nearest coal: %s blocks", + "combocoal.guide.nearest_above": "Nearest coal: %s blocks (above you)", + "combocoal.guide.nearest_below": "Nearest coal: %s blocks (below you)", + "combocoal.guide.searching": "Searching for coal...", + "combocoal.guide.hidden_multiplayer": "Coal arrow is disabled on multiplayer servers", + + "combocoal.durability.warning": "Your %s is about to break!", + "combocoal.durability.hint": "Repair it at an anvil or with Mending", + + "combocoal.warning.esp_multiplayer": "ComboCoal: the coal ESP is active on a multiplayer server. Many servers forbid this and you may get banned.", + "combocoal.warning.arrow_multiplayer": "ComboCoal: the coal arrow is active on a multiplayer server. Many servers forbid this and you may get banned.", + + "combocoal.config.title": "ComboCoal Settings", + "combocoal.config.on": "ON", + "combocoal.config.off": "OFF", + "combocoal.config.option": "%s: %s", + "combocoal.config.hapticShake": "Haptic shake", + "combocoal.config.maniacMode": "Coal Maniac mode", + "combocoal.config.strictMode": "Strict mode", + "combocoal.config.esp": "Coal ESP", + "combocoal.config.allowEspOnMultiplayer": "ESP on multiplayer", + "combocoal.config.arrow": "Coal arrow", + "combocoal.config.allowArrowOnMultiplayer": "Arrow on multiplayer", + "combocoal.config.pets": "Dancing pets", + "combocoal.config.sounds": "Sounds", + "combocoal.config.statsOptIn": "Share stats", + "combocoal.config.hudScale": "HUD scale: %s%%", + "combocoal.config.leaderboard": "Leaderboard", + "combocoal.config.captcha": "Verify (captcha)", + + "combocoal.stats.consent.title": "ComboCoal: share your stats?", + "combocoal.stats.consent.intro": "ComboCoal can send your coal stats to a leaderboard server. This is optional and OFF by default.", + "combocoal.stats.consent.data": "If you enable it, exactly this is sent over HTTPS: your player name, the coal you mined this session, your best combo and the address of the server you are playing on. If your pickaxe is about to break at a high combo on a server, a Help ping with your name, that server address and your combo is sent too. On multiplayer servers a shared team combo is also synced about once per second: your name, the server address and how many coal you broke.", + "combocoal.stats.consent.captcha": "You will solve one small captcha first, and every upload includes a small proof-of-work computed on your computer.", + "combocoal.stats.consent.never": "Nothing else is sent. Your IP address is never put in the data, but like any web request it is visible to the server that receives it.", + "combocoal.stats.consent.endpoint": "Endpoint: %s", + "combocoal.stats.consent.no_endpoint": "No endpoint is configured yet, so nothing can be sent until you set statsEndpoint in the config.", + "combocoal.stats.consent.change": "You can change this any time in the ComboCoal settings or in config/combocoal.json.", + "combocoal.stats.consent.yes": "Yes, share my stats", + "combocoal.stats.consent.no": "No thanks", + + "combocoal.leaderboard.title": "Coal Leaderboard", + "combocoal.leaderboard.loading": "Loading...", + "combocoal.leaderboard.error": "Could not load the leaderboard.", + "combocoal.leaderboard.disabled": "Enable stats sharing and set an https endpoint to see the leaderboard.", + "combocoal.leaderboard.row": "%s. %s - %s coal (best x%s)", + + "combocoal.captcha.title": "Human check", + "combocoal.captcha.loading": "Please wait...", + "combocoal.captcha.question": "What is %s ?", + "combocoal.captcha.wrong": "Wrong answer. What is %s ?", + "combocoal.captcha.answer": "Answer", + "combocoal.captcha.submit": "Verify", + "combocoal.captcha.solved": "Verified!", + "combocoal.captcha.failed": "Could not reach the stats server.", + + "combocoal.help.button": "Help servers", + "combocoal.help.title": "Servers asking for help", + "combocoal.help.mark": "[HELP]", + "combocoal.help.row": "%s player(s) need help, combo x%s", + "combocoal.help.join": "Join", + "combocoal.help.empty": "Nobody is asking for help right now." +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json new file mode 100644 index 0000000..23692ac --- /dev/null +++ b/src/main/resources/fabric.mod.json @@ -0,0 +1,19 @@ +{ + "schemaVersion": 1, + "id": "combocoal", + "version": "${version}", + "name": "ComboCoal", + "description": "A mobile-game style coal grinding mod: combos, ranks, pets, guide and more. Client-only.", + "authors": ["Arigadam"], + "license": "MIT", + "environment": "client", + "entrypoints": { + "client": ["pro.wihuk.arigadam.combocoal.ComboCoalClient"] + }, + "depends": { + "fabricloader": ">=0.16.0", + "minecraft": "~1.21.4", + "java": ">=21", + "fabric-api": "*" + } +}