Merge remote-tracking branch 'origin/main' into pr854
# Conflicts: # crates/horizon-client/src/game/remote.rs
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
name: cancel-on-close
|
||||
# A closed or merged pull request's queued and running checks free the runners at once.
|
||||
# pull_request_target so the token can cancel runs of pull requests from forks too;
|
||||
# it checks out nothing and runs no code from the pull request.
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [closed]
|
||||
permissions:
|
||||
actions: write
|
||||
jobs:
|
||||
cancel:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel the pull request's unfinished runs
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
REPO: ${{ github.repository }}
|
||||
BRANCH: ${{ github.event.pull_request.head.ref }}
|
||||
SHA: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
for status in queued in_progress waiting pending requested; do
|
||||
gh run list -R "$REPO" --branch "$BRANCH" --status "$status" --limit 100 \
|
||||
--json databaseId,event,headSha \
|
||||
-q ".[] | select(.event == \"pull_request\" and .headSha == \"$SHA\") | .databaseId"
|
||||
done | sort -u | while read -r id; do
|
||||
gh run cancel -R "$REPO" "$id" || true
|
||||
done
|
||||
@@ -56,6 +56,8 @@ jobs:
|
||||
run: |
|
||||
cargo +stable fmt --all -- --check
|
||||
cargo +stable clippy --workspace --all-targets -- -D warnings
|
||||
# The server build (released as horizon-engine): the game without sound or controllers.
|
||||
cargo +stable clippy -p horizon-client --all-targets --no-default-features -- -D warnings
|
||||
- name: Test Rust core and voxel kernel correctness
|
||||
if: steps.rust.outputs.required != 'false'
|
||||
run: cargo +stable test --workspace
|
||||
|
||||
@@ -76,6 +76,9 @@ jobs:
|
||||
os: ubuntu-22.04
|
||||
dir: horizon-linux-x86_64
|
||||
asset: horizon-linux-x86_64.tar.gz
|
||||
# The server build too: packaging/server/install.sh installs it on Linux.
|
||||
server_dir: horizon-server-linux-x86_64
|
||||
server_asset: horizon-server-linux-x86_64.tar.gz
|
||||
- name: windows
|
||||
os: windows-latest
|
||||
dir: horizon-windows-x64
|
||||
@@ -190,6 +193,29 @@ jobs:
|
||||
path: dist/${{ matrix.asset }}
|
||||
if-no-files-found: error
|
||||
retention-days: 3
|
||||
- name: The server build (the game without sound or controllers, as horizon-engine)
|
||||
if: matrix.server_asset
|
||||
run: |
|
||||
set -euo pipefail
|
||||
# After the client is packaged: target/release/horizon-client is rebuilt without the audio and
|
||||
# controllers features, so it needs neither libasound nor libudev (minimal server images lack them).
|
||||
cargo build --release --locked -p horizon-client --no-default-features --bin horizon-client
|
||||
cargo run --locked -p xtask -- package-server target/release/horizon-client "dist/${{ matrix.server_dir }}"
|
||||
folder="dist/${{ matrix.server_dir }}"
|
||||
python3 tools/check_imports.py --server "$folder/horizon-engine" "$folder/horizon-server" "$folder/horizon-prepare"
|
||||
"$folder/horizon-engine" --help | grep -q -- '--resources'
|
||||
"$folder/horizon-server" --version
|
||||
cd dist
|
||||
rm -f "${{ matrix.server_asset }}"
|
||||
tar czf "${{ matrix.server_asset }}" "${{ matrix.server_dir }}"
|
||||
ls -l "${{ matrix.server_asset }}"
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: matrix.server_asset
|
||||
with:
|
||||
name: ${{ matrix.server_asset }}
|
||||
path: dist/${{ matrix.server_asset }}
|
||||
if-no-files-found: error
|
||||
retention-days: 3
|
||||
|
||||
publish:
|
||||
needs: [decide, build]
|
||||
@@ -220,7 +246,7 @@ jobs:
|
||||
run: |
|
||||
gh release create "$TAG" --target "${{ needs.decide.outputs.head }}" --title "$(cat notes/title.txt)" \
|
||||
--notes-file notes/body.md --latest dist/horizon-linux-x86_64.tar.gz dist/horizon-windows-x64.zip \
|
||||
dist/horizon-macos-arm64.zip
|
||||
dist/horizon-macos-arm64.zip dist/horizon-server-linux-x86_64.tar.gz
|
||||
- name: Dry run, the release that would be published
|
||||
if: needs.decide.outputs.dry_run == 'true'
|
||||
run: |
|
||||
|
||||
Generated
+2
@@ -1435,6 +1435,7 @@ dependencies = [
|
||||
"naga",
|
||||
"png",
|
||||
"pollster",
|
||||
"rustix 1.1.5",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
@@ -1555,6 +1556,7 @@ dependencies = [
|
||||
name = "horizon-server"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"horizon-bench",
|
||||
"horizon-server-files",
|
||||
"libc",
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
# Horizon's server against vanilla 26.3: mixed bots, equal work (2026-10-18)
|
||||
|
||||
This reruns `../server-mixed-2026-10-18/` with the bots' load made the same on both servers. In that run the
|
||||
`explore` bots flew as fast as each server sent them chunks. Horizon kept up and vanilla didn't, so Horizon
|
||||
sent 2.9 to 5.9 times as many chunks a second, and vanilla's walking bots got a fifth of the chunks Horizon's
|
||||
got. The comparison of tick times wasn't fair.
|
||||
|
||||
## Summary
|
||||
|
||||
- **The work was equal** at 1 and 10 bots. At 25 bots it was equal in chunks sent a second (158.6 against 157.6);
|
||||
vanilla was still catching up on chunks its bots hadn't had yet, see "Equal work" below. Every bot joined, none
|
||||
was dropped, no chunk was sent twice, and no bot ever waited for the chunk it stood in.
|
||||
- **Tick time (MSPT), same work:**
|
||||
- 1 bot: 1.8 ms on Horizon against 11.3 on vanilla;
|
||||
- 10 bots: 4.7 against 34.3 ms;
|
||||
- 25 bots: 11.7 against 50.5 ms. Vanilla dropped just under 20 TPS (19.8) and its worst 5-second P99 was
|
||||
1388 ms, against Horizon's 130;
|
||||
- 50 bots: Horizon ran at 23.8 ms (20 TPS). Vanilla's watchdog stopped its server 30 s after the last bot
|
||||
joined ("A single server tick took 60.01 seconds").
|
||||
- **Memory:** Horizon's RSS was 4.1 to 4.9 times smaller: 0.69 against 3.40 GB with one bot, 0.95 against
|
||||
3.87 GB with 25, and 1.03 GB with 50. Vanilla's heap is fixed at 4 GB, so its RSS is mostly that heap.
|
||||
- **CPU** (100 % is one of the machine's 4 threads): 30 against 128 % at 10 bots, 58 against 192 % at 25.
|
||||
- **What changed since the first run:** the first run's vanilla held 50 bots at 29.7 ms because its walking
|
||||
bots got 640 to 1100 chunks each. With the explore bots paced, vanilla serves the walking bots in full
|
||||
(5400 to 6100 chunks each, against Horizon's 6100 to 6600), and that is the load it can't carry at 50.
|
||||
|
||||
## Results
|
||||
|
||||
MSPT is milliseconds per tick from each server's own `/tick query` (50 is the limit for 20 TPS). P95 and P99
|
||||
are over the 300 measured seconds. "Worst P99" is the highest P99 of a single 5-second query. RSS and CPU
|
||||
cover the server's process tree. "First-time chunks/s" counts chunks a bot hadn't received before (summed
|
||||
over the bots). "Waited" is ticks a second that bots stood still waiting for their own chunk. "Pulled back"
|
||||
counts position packets that moved a bot back.
|
||||
|
||||
| Bots | Server | MSPT | P95 | P99 | Worst P99 | TPS | RSS (mean / max) | CPU | Start | Chunks/s | First-time chunks/s | Waited | Pulled back |
|
||||
|---:|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
||||
| 1 | Horizon | **1.77** | 4.21 | 13.04 | 47.5 | 20 | **0.69 / 0.69 GB** | 28 % | 19.7 s | 9.94 | 0.01 | 0 | 0 |
|
||||
| 1 | vanilla | 11.34 | 17.12 | 33.22 | 119.1 | 20 | 3.40 / 3.42 GB | 36 % | 20.4 s | 9.98 | 0.01 | 0 | 0 |
|
||||
| 10 | Horizon | **4.74** | 10.48 | 19.69 | 120.1 | 20 | **0.86 / 0.88 GB** | 30 % | 19.5 s | 61.35 | 1.79 | 0 | 4159 |
|
||||
| 10 | vanilla | 34.30 | 53.72 | 89.08 | 375.8 | 20 | 3.71 / 3.75 GB | 128 % | 19.9 s | 61.66 | 1.93 | 0 | 3976 |
|
||||
| 25 | Horizon | **11.72** | 24.45 | 43.79 | 129.8 | 20 | **0.95 / 1.09 GB** | 58 % | 9.6 s | 158.57 | 5.78 | 0 | 3496 |
|
||||
| 25 | vanilla | 50.45 | 74.09 | 191.21 | 1388.1 | 19.82 | 3.87 / 4.75 GB | 192 % | 37.8 s | 157.63 | 8.25 | 0 | 3629 |
|
||||
| 50 | Horizon | **23.82** | 50.98 | 74.64 | 195.9 | 20 | **1.03 / 1.20 GB** | 98 % | 14.9 s | 302.81 | 10.96 | 0 | 7565 |
|
||||
| 50 | vanilla | stopped by its watchdog | | | | | | | 11.2 s | | | | |
|
||||
|
||||
Chunks each bot received over the whole run, by behaviour (mean):
|
||||
|
||||
| Bots | Server | walk | explore | idle |
|
||||
|---:|---|---:|---:|---:|
|
||||
| 1 | Horizon | 6092 | | |
|
||||
| 1 | vanilla | 6084 | | |
|
||||
| 10 | Horizon | 6248 | 1165 | 473 |
|
||||
| 10 | vanilla | 5729 | 1124 | 473 |
|
||||
| 25 | Horizon | 6629 | 1267 | 473 |
|
||||
| 25 | vanilla | 5387 | 1119 | 473 |
|
||||
| 50 | Horizon | 6497 | 1256 | 473 |
|
||||
|
||||
Both servers pulled bots back about as often (`moved too quickly` 20 and 296 times on vanilla at 10 and 25
|
||||
bots).
|
||||
|
||||
## Equal work
|
||||
|
||||
`tools/server_bench.py` now prints a work table after the runs. At each bot count it compares every server's
|
||||
chunks sent a second and first-time chunks a second with the busiest server's. Work counts as equal when
|
||||
both are within 10 % (or within a chunk a second when there are few). The report keeps the table as `work`.
|
||||
|
||||
| Bots | Chunks/s (Horizon, vanilla) | First-time chunks/s (Horizon, vanilla) | Equal |
|
||||
|---:|---|---|---|
|
||||
| 1 | 9.94, 9.98 | 0.01, 0.01 | yes |
|
||||
| 10 | 61.35, 61.66 | 1.79, 1.93 | yes |
|
||||
| 25 | 158.57, 157.63 | 5.78, 8.25 | no: vanilla sent 2.5 more first-time chunks a second |
|
||||
|
||||
Two settings made the load the same:
|
||||
|
||||
- **Explore bots paced at 0.8 blocks a second** (`--explore-speed 0.8`), the rate the 2026-10-17 run showed
|
||||
both servers keep up with. Every bot then follows the same path on both servers. The path is deterministic
|
||||
per bot, and a bot only stops while the chunk it stands in hasn't arrived, which never happened here
|
||||
(`Waited` 0). So both servers had the same chunks to send.
|
||||
- **A 300-second warm-up** before the 300 measured seconds. A first pass with the old 60-second warm-up
|
||||
(aborted after 10 bots) sent the same chunks a second on both (63.1 against 61.4). But vanilla was still
|
||||
delivering the bots' first views during the measurement (12.9 first-time chunks a second against Horizon's
|
||||
4.1), so its window held more work than Horizon's. With 300 seconds both were in steady state at 1 and 10
|
||||
bots. At 25, vanilla still sent 2.5 more first-time chunks a second than Horizon: 1.6 % of all it sent, and
|
||||
its walking bots ended the run with 19 % fewer chunks. Read the 25-bot tick times with that in mind: the
|
||||
extra first-time chunks are work vanilla had still to do because it fell behind.
|
||||
|
||||
## Method
|
||||
|
||||
`tools/server_bench.py` ran each configuration on a fresh server:
|
||||
|
||||
- the same `server.properties` on both: seed 12345, view and simulation distance 10, offline, creative,
|
||||
difficulty easy, `sync-chunk-writes=true`, white-list off;
|
||||
- `gamerule respawn_radius 0`, and otherwise vanilla's default game rules (the locator bar on for both);
|
||||
- the server waits for `Done`, the bots join one a second, warm up for 300 seconds and are measured for 300,
|
||||
with `/tick query` every 5 seconds and RSS and CPU every second.
|
||||
|
||||
The bots are `horizon-bots --behaviour mixed`: 60 % walk, 20 % explore and 20 % idle, each choice deterministic
|
||||
per bot. All are creative and fly 24 blocks above spawn. `walk` flies to random points within 48 blocks at
|
||||
5.6 blocks a second, `explore` flies straight out at 0.8 blocks a second, and `idle` hovers.
|
||||
|
||||
**Machine.** The ThinkPad: Intel Core i7-7500U (2 cores, 4 threads), 32 GB, NixOS. The desktop (24 threads)
|
||||
was meant to run it, but it didn't wake (`~/fleet/power wake desktop` timed out, as it did for the first run).
|
||||
No other session ran on the ThinkPad during the runs (`load.txt`, a sample a minute). The servers ran under
|
||||
`nice -n 19`. The bots ran on the Mac mini (M4 Pro, shared with other work at 70 to 90 % CPU) and reached the
|
||||
ThinkPad over the tailnet.
|
||||
|
||||
**What ran.**
|
||||
|
||||
- Horizon: the server build from #916 (`horizon-client --no-default-features`, no sound or controllers) at
|
||||
519ec121, packaged with `xtask package-server` and installed with `install.sh --archive`, as Linux owners
|
||||
will get it. `horizon-server` ran it as `horizon-engine`. The game files were prepared from the owner's own
|
||||
Minecraft. `horizon-bots` and `server_bench.py` came from this PR.
|
||||
- Vanilla: the pinned 26.3 server jar (the owner's own copy) on OpenJDK 25.0.4.1, `-Xms4g -Xmx4g`.
|
||||
|
||||
`server_bench.py` stopped after vanilla's 50-bot server crashed and before it wrote its report.
|
||||
`mixed-equal.json` holds the run lines it printed. The vanilla 50 entry and its error come from that server's
|
||||
log, and the `work` table was computed with `server_bench.work`. `load.txt` is the fleet monitor's view of the
|
||||
machines during the runs.
|
||||
|
||||
## Reproduce
|
||||
|
||||
curl -fsSL https://raw.githubusercontent.com/ludovic111/horizon/main/packaging/server/install.sh | sh
|
||||
horizon-prepare --prepare --server-jar /path/to/server.jar # your own copy
|
||||
cargo build --release -p horizon-bots # on the machine that runs the bots
|
||||
# in a checkout whose .local/minecraft holds the pinned vanilla jars (tools/lab.py prepare):
|
||||
HORIZON_BENCH_BIN=~/.local/share/horizon/current \
|
||||
python3 tools/server_bench.py --servers horizon,vanilla --bots 1,10,25,50 --behaviour mixed \
|
||||
--explore-speed 0.8 --warmup 300 --nice 19 \
|
||||
--bots-via 'ssh <bots machine>' --bots-bin /path/to/horizon-bots --connect <this machine's address> \
|
||||
--out mixed-equal.json
|
||||
|
||||
## Next
|
||||
|
||||
- One pass per configuration ran. Vanilla at 50 bots, in particular, needs a second pass, ideally on the
|
||||
desktop (24 threads), where neither server is CPU-bound.
|
||||
- 100 bots, and Paper and Fabric + Lithium (docs/server.md section 9).
|
||||
- A longer warm-up, or measuring from when the first-time chunk rate settles, so the 25-bot work is equal too.
|
||||
@@ -0,0 +1,702 @@
|
||||
2026-10-18T19:32:39Z
|
||||
ludothinkpad ok: 27.2 GB free, 4 threads 17% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 25.9 GB free, 14 threads 73% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 27.0 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 42% busy (agents 0.0, rest 1.6 cores) · 80°C · load 5.9
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:33:44Z
|
||||
ludothinkpad ok: 26.7 GB free, 4 threads 19% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.7 GB free, 14 threads 93% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 34% busy (agents 0.0, rest 1.7 cores) · 81°C · load 4.0
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:34:48Z
|
||||
ludothinkpad ok: 26.4 GB free, 4 threads 56% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.9 GB free, 14 threads 90% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 54% busy (agents 0.0, rest 2.2 cores) · 79°C · load 2.8
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:35:52Z
|
||||
ludothinkpad ok: 26.7 GB free, 4 threads 27% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 25.4 GB free, 14 threads 85% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 30% busy (agents 0.0, rest 1.1 cores) · 82°C · load 2.2
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:36:57Z
|
||||
ludothinkpad ok: 26.7 GB free, 4 threads 25% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 25.4 GB free, 14 threads 93% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 37% busy (agents 0.0, rest 1.2 cores) · 80°C · load 1.5
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:38:01Z
|
||||
ludothinkpad ok: 26.6 GB free, 4 threads 54% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.7 GB free, 14 threads 64% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 21% busy (agents 0.0, rest 1.2 cores) · 81°C · load 1.9
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:39:05Z
|
||||
ludothinkpad ok: 26.7 GB free, 4 threads 20% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.1 GB free, 14 threads 70% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 28% busy (agents 0.0, rest 1.0 cores) · 81°C · load 1.3
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:40:10Z
|
||||
ludothinkpad ok: 26.7 GB free, 4 threads 39% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.2 GB free, 14 threads 73% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 32% busy (agents 0.0, rest 1.7 cores) · 80°C · load 0.9
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:41:14Z
|
||||
ludothinkpad ok: 26.7 GB free, 4 threads 31% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.8 GB free, 14 threads 77% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 15% busy (agents 0.0, rest 1.1 cores) · 82°C · load 1.3
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:42:19Z
|
||||
ludothinkpad ok: 26.5 GB free, 4 threads 26% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.1 GB free, 14 threads 94% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 30% busy (agents 0.0, rest 1.3 cores) · 78°C · load 1.1
|
||||
· disk 289.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:43:23Z
|
||||
ludothinkpad busy: 26.7 GB free, 4 threads 99% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.2 GB free, 14 threads 83% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 99% busy (agents 0.0, rest 3.8 cores) · 86°C · load 2.4
|
||||
· disk 289.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:44:27Z
|
||||
ludothinkpad busy: 25.2 GB free, 4 threads 98% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.0 GB free, 14 threads 73% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 24.9 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 83% busy (agents 0.0, rest 3.7 cores) · 83°C · load 5.5
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:45:31Z
|
||||
ludothinkpad ok: 24.5 GB free, 4 threads 39% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.0 GB free, 14 threads 93% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 24.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 34% busy (agents 0.0, rest 1.5 cores) · 84°C · load 3.5
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:46:35Z
|
||||
ludothinkpad ok: 23.7 GB free, 4 threads 69% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.2 GB free, 14 threads 90% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 23.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 75% busy (agents 0.0, rest 2.8 cores) · 87°C · load 2.7
|
||||
· disk 289.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:47:40Z
|
||||
ludothinkpad ok: 23.8 GB free, 4 threads 66% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 25.9 GB free, 14 threads 85% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 23.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 59% busy (agents 0.0, rest 2.5 cores) · 83°C · load 2.9
|
||||
· disk 291.7 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:48:44Z
|
||||
ludothinkpad ok: 24.2 GB free, 4 threads 61% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.0 GB free, 14 threads 90% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 24.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 62% busy (agents 0.0, rest 2.5 cores) · 84°C · load 3.2
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:49:48Z
|
||||
ludothinkpad ok: 25.1 GB free, 4 threads 59% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 31.1 GB free, 14 threads 81% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 25.1 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 57% busy (agents 0.0, rest 2.4 cores) · 85°C · load 2.9
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:50:52Z
|
||||
ludothinkpad ok: 25.7 GB free, 4 threads 39% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.4 GB free, 14 threads 88% busy, 2 sessions
|
||||
macbook offline
|
||||
RAM 25.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 18% busy (agents 0.0, rest 1.4 cores) · 67°C · load 2.4
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:51:57Z
|
||||
ludothinkpad ok: 23.7 GB free, 4 threads 40% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.9 GB free, 14 threads 83% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 23.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 23% busy (agents 0.0, rest 1.4 cores) · 81°C · load 1.8
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:53:01Z
|
||||
ludothinkpad ok: 25.3 GB free, 4 threads 25% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.1 GB free, 14 threads 84% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 25.1 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 31% busy (agents 0.0, rest 1.2 cores) · 80°C · load 1.8
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:54:05Z
|
||||
ludothinkpad ok: 26.5 GB free, 4 threads 75% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.1 GB free, 14 threads 91% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.5 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 69% busy (agents 0.0, rest 2.5 cores) · 78°C · load 2.3
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:55:09Z
|
||||
ludothinkpad busy: 26.4 GB free, 4 threads 89% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.3 GB free, 14 threads 86% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 32% busy (agents 0.0, rest 2.4 cores) · 79°C · load 2.9
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:56:14Z
|
||||
ludothinkpad ok: 26.4 GB free, 4 threads 39% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.1 GB free, 14 threads 68% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 63% busy (agents 0.0, rest 1.8 cores) · 82°C · load 2.3
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:57:18Z
|
||||
ludothinkpad ok: 26.3 GB free, 4 threads 20% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.2 GB free, 14 threads 85% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 19% busy (agents 0.0, rest 1.0 cores) · 80°C · load 1.8
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:58:22Z
|
||||
ludothinkpad ok: 26.3 GB free, 4 threads 28% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.3 GB free, 14 threads 88% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.1 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 93% busy (agents 0.0, rest 2.5 cores) · 80°C · load 2.0
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T19:59:27Z
|
||||
ludothinkpad ok: 26.2 GB free, 4 threads 52% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 35.0 GB free, 14 threads 85% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 26.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 22% busy (agents 0.0, rest 1.8 cores) · 80°C · load 3.6
|
||||
· disk 291.4 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:00:31Z
|
||||
ludothinkpad busy: 25.8 GB free, 4 threads 87% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 33.0 GB free, 14 threads 87% busy, 1 sessions
|
||||
macbook offline
|
||||
RAM 27.5 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 51% busy (agents 0.0, rest 2.9 cores) · 79°C · load 3.6
|
||||
· disk 291.5 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:01:35Z
|
||||
ludothinkpad ok: 25.6 GB free, 4 threads 35% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 32.4 GB free, 14 threads 81% busy, 1 sessions
|
||||
macbook ok: 7.2 GB free, 12 threads 32% busy, 0 sessions
|
||||
RAM 25.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 34% busy (agents 0.0, rest 1.3 cores) · 81°C · load 2.5
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:02:40Z
|
||||
ludothinkpad ok: 26.6 GB free, 4 threads 35% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.2 GB free, 14 threads 79% busy, 1 sessions
|
||||
macbook ok: 6.5 GB free, 12 threads 39% busy, 0 sessions
|
||||
RAM 26.5 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 33% busy (agents 0.0, rest 1.3 cores) · 81°C · load 2.7
|
||||
· disk 291.6 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:03:44Z
|
||||
ludothinkpad ok: 25.5 GB free, 4 threads 56% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 31.1 GB free, 14 threads 89% busy, 1 sessions
|
||||
macbook ok: 6.8 GB free, 12 threads 6% busy, 0 sessions
|
||||
RAM 25.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 66% busy (agents 0.0, rest 2.5 cores) · 87°C · load 2.5
|
||||
· disk 291.3 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:04:48Z
|
||||
ludothinkpad busy: 26.2 GB free, 4 threads 99% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 30.0 GB free, 14 threads 89% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 31% busy, 0 sessions
|
||||
RAM 25.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 84% busy (agents 0.0, rest 3.7 cores) · 85°C · load 3.4
|
||||
· disk 291.3 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:05:52Z
|
||||
ludothinkpad busy: 24.5 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 34.1 GB free, 14 threads 89% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 24.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 100% busy (agents 0.0, rest 4.0 cores) · 83°C · load 9.0
|
||||
· disk 291.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:06:57Z
|
||||
ludothinkpad busy: 23.5 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.3 GB free, 14 threads 88% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 5% busy, 0 sessions
|
||||
RAM 23.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 99% busy (agents 0.0, rest 4.0 cores) · 82°C · load 10.1
|
||||
· disk 309.2 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:08:01Z
|
||||
ludothinkpad busy: 23.4 GB free, 4 threads 88% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.6 GB free, 14 threads 83% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 2% busy, 0 sessions
|
||||
RAM 23.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 77% busy (agents 0.0, rest 3.4 cores) · 84°C · load 7.5
|
||||
· disk 309.2 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:09:05Z
|
||||
ludothinkpad busy: 24.0 GB free, 4 threads 89% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 25.9 GB free, 14 threads 83% busy, 1 sessions
|
||||
macbook ok: 7.1 GB free, 12 threads 19% busy, 0 sessions
|
||||
RAM 23.9 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 91% busy (agents 0.0, rest 3.6 cores) · 82°C · load 5.9
|
||||
· disk 309.1 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:10:09Z
|
||||
ludothinkpad busy: 24.0 GB free, 4 threads 98% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.1 GB free, 14 threads 88% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 19% busy, 0 sessions
|
||||
RAM 24.0 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 92% busy (agents 0.0, rest 3.7 cores) · 84°C · load 6.6
|
||||
· disk 309.1 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:11:14Z
|
||||
ludothinkpad busy: 24.3 GB free, 4 threads 92% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.3 GB free, 14 threads 84% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 18% busy, 0 sessions
|
||||
RAM 24.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 99% busy (agents 0.0, rest 3.7 cores) · 85°C · load 6.5
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:12:18Z
|
||||
ludothinkpad busy: 24.7 GB free, 4 threads 89% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.6 GB free, 14 threads 78% busy, 1 sessions
|
||||
macbook ok: 7.3 GB free, 12 threads 20% busy, 0 sessions
|
||||
RAM 24.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 82% busy (agents 0.0, rest 3.4 cores) · 84°C · load 6.1
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:13:22Z
|
||||
ludothinkpad ok: 23.4 GB free, 4 threads 53% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.1 GB free, 14 threads 77% busy, 1 sessions
|
||||
macbook ok: 7.3 GB free, 12 threads 20% busy, 0 sessions
|
||||
RAM 23.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 48% busy (agents 0.0, rest 2.4 cores) · 80°C · load 4.2
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:14:27Z
|
||||
ludothinkpad ok: 24.0 GB free, 4 threads 44% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.0 GB free, 14 threads 71% busy, 1 sessions
|
||||
macbook ok: 6.9 GB free, 12 threads 2% busy, 0 sessions
|
||||
RAM 24.1 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 23% busy (agents 0.0, rest 2.0 cores) · 77°C · load 4.3
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:15:31Z
|
||||
ludothinkpad ok: 22.7 GB free, 4 threads 31% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.2 GB free, 14 threads 86% busy, 1 sessions
|
||||
macbook ok: 6.9 GB free, 12 threads 19% busy, 0 sessions
|
||||
RAM 22.5 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 30% busy (agents 0.0, rest 1.3 cores) · 77°C · load 2.6
|
||||
· disk 309.1 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:16:35Z
|
||||
ludothinkpad ok: 26.8 GB free, 4 threads 37% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.6 GB free, 14 threads 82% busy, 1 sessions
|
||||
macbook ok: 6.8 GB free, 12 threads 9% busy, 0 sessions
|
||||
RAM 26.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 42% busy (agents 0.0, rest 1.7 cores) · 81°C · load 2.3
|
||||
· disk 309.1 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:17:39Z
|
||||
ludothinkpad ok: 26.3 GB free, 4 threads 63% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.8 GB free, 14 threads 78% busy, 1 sessions
|
||||
macbook ok: 7.0 GB free, 12 threads 19% busy, 0 sessions
|
||||
RAM 26.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 64% busy (agents 0.0, rest 2.6 cores) · 87°C · load 1.9
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:18:43Z
|
||||
ludothinkpad ok: 26.9 GB free, 4 threads 37% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 32.2 GB free, 14 threads 87% busy, 1 sessions
|
||||
macbook ok: 7.0 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 26.9 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 56% busy (agents 0.0, rest 1.9 cores) · 84°C · load 3.9
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:19:48Z
|
||||
ludothinkpad ok: 26.0 GB free, 4 threads 77% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.2 GB free, 14 threads 83% busy, 1 sessions
|
||||
macbook ok: 7.0 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 26.0 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 66% busy (agents 0.0, rest 2.9 cores) · 86°C · load 3.2
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:20:52Z
|
||||
ludothinkpad ok: 25.9 GB free, 4 threads 80% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.8 GB free, 14 threads 84% busy, 1 sessions
|
||||
macbook ok: 7.0 GB free, 12 threads 17% busy, 0 sessions
|
||||
RAM 25.9 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 68% busy (agents 0.0, rest 3.2 cores) · 86°C · load 4.4
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:21:56Z
|
||||
ludothinkpad ok: 26.3 GB free, 4 threads 63% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.3 GB free, 14 threads 77% busy, 1 sessions
|
||||
macbook ok: 6.8 GB free, 12 threads 14% busy, 0 sessions
|
||||
RAM 26.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 66% busy (agents 0.0, rest 2.8 cores) · 84°C · load 3.1
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:23:00Z
|
||||
ludothinkpad ok: 26.8 GB free, 4 threads 74% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.1 GB free, 14 threads 82% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 11% busy, 0 sessions
|
||||
RAM 26.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 65% busy (agents 0.0, rest 2.8 cores) · 84°C · load 5.0
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:24:05Z
|
||||
ludothinkpad ok: 26.9 GB free, 4 threads 64% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.3 GB free, 14 threads 90% busy, 1 sessions
|
||||
macbook ok: 6.8 GB free, 12 threads 8% busy, 0 sessions
|
||||
RAM 26.9 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 64% busy (agents 0.0, rest 2.7 cores) · 86°C · load 4.9
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:25:09Z
|
||||
ludothinkpad ok: 26.0 GB free, 4 threads 56% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.2 GB free, 14 threads 88% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 12% busy, 0 sessions
|
||||
RAM 26.0 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 49% busy (agents 0.0, rest 2.1 cores) · 72°C · load 5.5
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:26:13Z
|
||||
ludothinkpad ok: 25.8 GB free, 4 threads 47% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.8 GB free, 14 threads 78% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 8% busy, 0 sessions
|
||||
RAM 25.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 56% busy (agents 0.0, rest 2.1 cores) · 78°C · load 3.1
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:27:18Z
|
||||
ludothinkpad busy: 25.5 GB free, 4 threads 94% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.6 GB free, 14 threads 82% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 17% busy, 0 sessions
|
||||
RAM 25.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 100% busy (agents 0.0, rest 3.9 cores) · 78°C · load 4.7
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:28:22Z
|
||||
ludothinkpad busy: 24.6 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.4 GB free, 14 threads 80% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 8% busy, 0 sessions
|
||||
RAM 24.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 99% busy (agents 0.0, rest 4.0 cores) · 77°C · load 10.5
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:29:27Z
|
||||
ludothinkpad busy: 24.3 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.8 GB free, 14 threads 80% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 8% busy, 0 sessions
|
||||
RAM 24.0 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 99% busy (agents 0.0, rest 4.0 cores) · 82°C · load 10.0
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:30:31Z
|
||||
ludothinkpad busy: 23.7 GB free, 4 threads 91% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 30.1 GB free, 14 threads 71% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 9% busy, 0 sessions
|
||||
RAM 23.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 94% busy (agents 0.0, rest 3.8 cores) · 80°C · load 10.3
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:31:36Z
|
||||
ludothinkpad busy: 23.6 GB free, 4 threads 93% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.0 GB free, 14 threads 81% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 14% busy, 0 sessions
|
||||
RAM 23.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 95% busy (agents 0.0, rest 3.7 cores) · 80°C · load 10.7
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:32:40Z
|
||||
ludothinkpad busy: 23.6 GB free, 4 threads 94% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.9 GB free, 14 threads 76% busy, 1 sessions
|
||||
macbook ok: 6.8 GB free, 12 threads 22% busy, 0 sessions
|
||||
RAM 23.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 84% busy (agents 0.0, rest 3.5 cores) · 80°C · load 9.7
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:33:45Z
|
||||
ludothinkpad ok: 25.2 GB free, 4 threads 51% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.1 GB free, 14 threads 82% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 17% busy, 0 sessions
|
||||
RAM 25.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 48% busy (agents 0.0, rest 2.1 cores) · 87°C · load 6.5
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:34:49Z
|
||||
ludothinkpad ok: 25.1 GB free, 4 threads 56% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.2 GB free, 14 threads 87% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 17% busy, 0 sessions
|
||||
RAM 24.5 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 78% busy (agents 0.0, rest 2.7 cores) · 88°C · load 4.0
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:35:53Z
|
||||
ludothinkpad busy: 23.6 GB free, 4 threads 86% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.9 GB free, 14 threads 86% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 17% busy, 0 sessions
|
||||
RAM 23.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 88% busy (agents 0.0, rest 3.3 cores) · 85°C · load 4.9
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:36:58Z
|
||||
ludothinkpad ok: 23.6 GB free, 4 threads 75% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.4 GB free, 14 threads 84% busy, 1 sessions
|
||||
macbook ok: 6.5 GB free, 12 threads 18% busy, 0 sessions
|
||||
RAM 23.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 85% busy (agents 0.0, rest 3.2 cores) · 85°C · load 5.1
|
||||
· disk 309.0 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:38:02Z
|
||||
ludothinkpad ok: 22.6 GB free, 4 threads 55% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.5 GB free, 14 threads 80% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 22.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 54% busy (agents 0.0, rest 2.2 cores) · 85°C · load 4.5
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:39:06Z
|
||||
ludothinkpad ok: 27.2 GB free, 4 threads 55% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.5 GB free, 14 threads 85% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 9% busy, 0 sessions
|
||||
RAM 27.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 48% busy (agents 0.0, rest 2.2 cores) · 87°C · load 4.0
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:40:10Z
|
||||
ludothinkpad ok: 26.2 GB free, 4 threads 72% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.7 GB free, 14 threads 84% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 19% busy, 0 sessions
|
||||
RAM 26.3 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 80% busy (agents 0.0, rest 3.1 cores) · 86°C · load 10.8
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:41:15Z
|
||||
ludothinkpad busy: 26.4 GB free, 4 threads 86% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.5 GB free, 14 threads 79% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 26.4 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 90% busy (agents 0.0, rest 3.4 cores) · 86°C · load 12.8
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:42:19Z
|
||||
ludothinkpad ok: 26.2 GB free, 4 threads 82% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.9 GB free, 14 threads 78% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 11% busy, 0 sessions
|
||||
RAM 26.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 74% busy (agents 0.0, rest 3.3 cores) · 85°C · load 8.8
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:43:23Z
|
||||
ludothinkpad busy: 26.7 GB free, 4 threads 93% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.3 GB free, 14 threads 81% busy, 1 sessions
|
||||
macbook ok: 6.6 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 26.7 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 88% busy (agents 0.0, rest 3.4 cores) · 85°C · load 5.4
|
||||
· disk 308.9 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:44:27Z
|
||||
ludothinkpad ok: 27.0 GB free, 4 threads 82% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.9 GB free, 14 threads 87% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 13% busy, 0 sessions
|
||||
RAM 27.0 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 75% busy (agents 0.0, rest 3.3 cores) · 82°C · load 9.8
|
||||
· disk 308.8 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:45:32Z
|
||||
ludothinkpad ok: 27.2 GB free, 4 threads 76% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.8 GB free, 14 threads 80% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 27.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 84% busy (agents 0.0, rest 3.2 cores) · 85°C · load 6.9
|
||||
· disk 308.8 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:46:36Z
|
||||
ludothinkpad busy: 27.1 GB free, 4 threads 87% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.8 GB free, 14 threads 92% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 9% busy, 0 sessions
|
||||
RAM 26.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 85% busy (agents 0.0, rest 3.2 cores) · 82°C · load 4.4
|
||||
· disk 308.8 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:47:40Z
|
||||
ludothinkpad busy: 25.3 GB free, 4 threads 86% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.5 GB free, 14 threads 72% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 9% busy, 0 sessions
|
||||
RAM 25.5 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 85% busy (agents 0.0, rest 3.4 cores) · 86°C · load 3.7
|
||||
· disk 308.8 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:48:45Z
|
||||
ludothinkpad busy: 26.1 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.5 GB free, 14 threads 84% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 15% busy, 0 sessions
|
||||
RAM 26.1 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 98% busy (agents 0.0, rest 3.9 cores) · 80°C · load 6.5
|
||||
· disk 308.8 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:49:50Z
|
||||
ludothinkpad ok: 26.8 GB free, 4 threads 71% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.7 GB free, 14 threads 93% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 26.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 92% busy (agents 0.0, rest 3.4 cores) · 81°C · load 5.2
|
||||
· disk 308.7 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:50:54Z
|
||||
ludothinkpad busy: 25.8 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 31.3 GB free, 14 threads 95% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 11% busy, 0 sessions
|
||||
RAM 25.8 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 99% busy (agents 0.0, rest 4.0 cores) · 82°C · load 8.1
|
||||
· disk 308.7 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:51:59Z
|
||||
ludothinkpad ok: 27.2 GB free, 4 threads 12% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 31.2 GB free, 14 threads 76% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 8% busy, 0 sessions
|
||||
RAM 27.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 15% busy (agents 0.0, rest 1.3 cores) · 81°C · load 7.9
|
||||
· disk 308.7 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:53:03Z
|
||||
ludothinkpad ok: 27.3 GB free, 4 threads 42% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.8 GB free, 14 threads 87% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 9% busy, 0 sessions
|
||||
RAM 27.2 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 14% busy (agents 0.0, rest 0.8 cores) · 82°C · load 3.1
|
||||
· disk 308.7 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:54:08Z
|
||||
ludothinkpad ok: 28.9 GB free, 4 threads 4% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.2 GB free, 14 threads 80% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 9% busy, 0 sessions
|
||||
RAM 28.9 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 2% busy (agents 0.0, rest 0.3 cores) · 82°C · load 1.3
|
||||
· disk 308.7 GB free · battery 96% · Ludovic: away
|
||||
|
||||
2026-10-18T20:55:12Z
|
||||
ludothinkpad ok: 27.7 GB free, 4 threads 27% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 31.2 GB free, 14 threads 70% busy, 1 sessions
|
||||
macbook ok: 6.7 GB free, 12 threads 10% busy, 0 sessions
|
||||
RAM 27.6 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 26% busy (agents 0.0, rest 1.2 cores) · 69°C · load 1.0
|
||||
· disk 308.8 GB free · battery 96% · Ludovic: away
|
||||
|
||||
@@ -0,0 +1,421 @@
|
||||
{
|
||||
"kind": "horizon-server-benchmark",
|
||||
"date": "2026-10-18T19:32:00+00:00",
|
||||
"machine": {
|
||||
"system": "Linux",
|
||||
"machine": "x86_64",
|
||||
"cpus": 4,
|
||||
"name": "ThinkPad, Intel Core i7-7500U, 32 GB, NixOS"
|
||||
},
|
||||
"commit": "f1d5bf520986b00a5b968a84d85809fca1a039fa",
|
||||
"engine": "horizon-engine: the server build of #916 (horizon-client --no-default-features) at 519ec121, as install.sh --archive installed it",
|
||||
"java": [
|
||||
"openjdk 25.0.4.1 2026-08-18"
|
||||
],
|
||||
"settings": {
|
||||
"servers": "horizon,vanilla",
|
||||
"bots": "1,10,25,50",
|
||||
"behaviour": "mixed",
|
||||
"join_every": 1.0,
|
||||
"warmup": 300,
|
||||
"seconds": 300,
|
||||
"seed": 12345,
|
||||
"explore_speed": 0.8,
|
||||
"gamerule": "",
|
||||
"heap": "4g",
|
||||
"nice": 19,
|
||||
"bots_via": "ssh macmini",
|
||||
"connect": "the ThinkPad's tailnet address",
|
||||
"properties": {
|
||||
"level-seed": "12345",
|
||||
"view-distance": "10",
|
||||
"simulation-distance": "10",
|
||||
"online-mode": "false",
|
||||
"white-list": "false",
|
||||
"gamemode": "creative",
|
||||
"force-gamemode": "true",
|
||||
"spawn-protection": "0",
|
||||
"max-players": "200",
|
||||
"difficulty": "easy",
|
||||
"sync-chunk-writes": "true"
|
||||
}
|
||||
},
|
||||
"note": "server_bench.py was stopped after vanilla's 50-bot server crashed, before it wrote this file; the runs are the lines it printed, and the vanilla 50 entry is taken from that server's log.",
|
||||
"runs": [
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 1,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 19.73,
|
||||
"mspt": {
|
||||
"average": 1.77,
|
||||
"p50": 1.34,
|
||||
"p95": 4.21,
|
||||
"p99": 13.04
|
||||
},
|
||||
"mspt_worst_p99": 47.5,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 686.54,
|
||||
"max": 686.7
|
||||
},
|
||||
"cpu_percent": 27.92,
|
||||
"chunks_per_second": 9.94,
|
||||
"unique_per_second": 0.01,
|
||||
"forgotten_per_second": 9.9,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 6092,
|
||||
"chunks_per_bot": {
|
||||
"walk": 6092.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 699.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 0,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 1,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 1,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 20.45,
|
||||
"mspt": {
|
||||
"average": 11.34,
|
||||
"p50": 10.6,
|
||||
"p95": 17.12,
|
||||
"p99": 33.22
|
||||
},
|
||||
"mspt_worst_p99": 119.1,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 3404.16,
|
||||
"max": 3416.3
|
||||
},
|
||||
"cpu_percent": 35.93,
|
||||
"chunks_per_second": 9.98,
|
||||
"unique_per_second": 0.01,
|
||||
"forgotten_per_second": 9.93,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 6084,
|
||||
"chunks_per_bot": {
|
||||
"walk": 6084.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 699.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 0,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 1,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 59
|
||||
},
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 10,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 19.54,
|
||||
"mspt": {
|
||||
"average": 4.74,
|
||||
"p50": 3.83,
|
||||
"p95": 10.48,
|
||||
"p99": 19.69
|
||||
},
|
||||
"mspt_worst_p99": 120.1,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 855.26,
|
||||
"max": 882.7
|
||||
},
|
||||
"cpu_percent": 29.78,
|
||||
"chunks_per_second": 61.35,
|
||||
"unique_per_second": 1.79,
|
||||
"forgotten_per_second": 61.47,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 40762,
|
||||
"chunks_per_bot": {
|
||||
"walk": 6247.67,
|
||||
"explore": 1165.0,
|
||||
"idle": 473.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 701.83,
|
||||
"explore": 1086.0,
|
||||
"idle": 473.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 4159,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 10,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 10,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 19.95,
|
||||
"mspt": {
|
||||
"average": 34.3,
|
||||
"p50": 32.2,
|
||||
"p95": 53.72,
|
||||
"p99": 89.08
|
||||
},
|
||||
"mspt_worst_p99": 375.8,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 3713.5,
|
||||
"max": 3754.9
|
||||
},
|
||||
"cpu_percent": 128.07,
|
||||
"chunks_per_second": 61.66,
|
||||
"unique_per_second": 1.93,
|
||||
"forgotten_per_second": 61.71,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 37568,
|
||||
"chunks_per_bot": {
|
||||
"walk": 5729.0,
|
||||
"explore": 1124.0,
|
||||
"idle": 473.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 701.17,
|
||||
"explore": 1055.0,
|
||||
"idle": 473.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 3976,
|
||||
"moved_too_quickly": 20,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 10,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 25,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 9.61,
|
||||
"mspt": {
|
||||
"average": 11.72,
|
||||
"p50": 9.88,
|
||||
"p95": 24.45,
|
||||
"p99": 43.79
|
||||
},
|
||||
"mspt_worst_p99": 129.8,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 947.35,
|
||||
"max": 1086.1
|
||||
},
|
||||
"cpu_percent": 57.83,
|
||||
"chunks_per_second": 158.57,
|
||||
"unique_per_second": 5.78,
|
||||
"forgotten_per_second": 158.45,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 108126,
|
||||
"chunks_per_bot": {
|
||||
"walk": 6628.53,
|
||||
"explore": 1266.6,
|
||||
"idle": 473.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 704.67,
|
||||
"explore": 1189.2,
|
||||
"idle": 473.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 3496,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 25,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 25,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 37.78,
|
||||
"mspt": {
|
||||
"average": 50.45,
|
||||
"p50": 46.39,
|
||||
"p95": 74.09,
|
||||
"p99": 191.21
|
||||
},
|
||||
"mspt_worst_p99": 1388.1,
|
||||
"tps": 19.82,
|
||||
"rss_mb": {
|
||||
"mean": 3866.18,
|
||||
"max": 4745.0
|
||||
},
|
||||
"cpu_percent": 192.42,
|
||||
"chunks_per_second": 157.63,
|
||||
"unique_per_second": 8.25,
|
||||
"forgotten_per_second": 156.12,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 88763,
|
||||
"chunks_per_bot": {
|
||||
"walk": 5387.0,
|
||||
"explore": 1118.6,
|
||||
"idle": 473.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 699.0,
|
||||
"explore": 1075.0,
|
||||
"idle": 473.0
|
||||
},
|
||||
"resent": 2,
|
||||
"pulled_back": 3629,
|
||||
"moved_too_quickly": 296,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 25,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 50,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 14.93,
|
||||
"mspt": {
|
||||
"average": 23.82,
|
||||
"p50": 20.11,
|
||||
"p95": 50.98,
|
||||
"p99": 74.64
|
||||
},
|
||||
"mspt_worst_p99": 195.9,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 1031.41,
|
||||
"max": 1201.2
|
||||
},
|
||||
"cpu_percent": 98.21,
|
||||
"chunks_per_second": 302.81,
|
||||
"unique_per_second": 10.96,
|
||||
"forgotten_per_second": 303.47,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 212181,
|
||||
"chunks_per_bot": {
|
||||
"walk": 6496.53,
|
||||
"explore": 1255.5,
|
||||
"idle": 473.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 701.9,
|
||||
"explore": 1184.7,
|
||||
"idle": 473.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 7565,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 50,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 50,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 11.16,
|
||||
"error": "stopped by its watchdog 30 s after the last bot joined: \"A single server tick took 60.01 seconds (should be max 0.05)\" (Player.tick)"
|
||||
}
|
||||
],
|
||||
"work": [
|
||||
{
|
||||
"behaviour": "mixed",
|
||||
"bots": 1,
|
||||
"servers": {
|
||||
"horizon": {
|
||||
"chunks_per_second": {
|
||||
"value": 9.94,
|
||||
"share": 0.996
|
||||
},
|
||||
"unique_per_second": {
|
||||
"value": 0.01,
|
||||
"share": 1.0
|
||||
},
|
||||
"waited_ticks_per_second": 0.0
|
||||
},
|
||||
"vanilla": {
|
||||
"chunks_per_second": {
|
||||
"value": 9.98,
|
||||
"share": 1.0
|
||||
},
|
||||
"unique_per_second": {
|
||||
"value": 0.01,
|
||||
"share": 1.0
|
||||
},
|
||||
"waited_ticks_per_second": 0.0
|
||||
}
|
||||
},
|
||||
"equal": true
|
||||
},
|
||||
{
|
||||
"behaviour": "mixed",
|
||||
"bots": 10,
|
||||
"servers": {
|
||||
"horizon": {
|
||||
"chunks_per_second": {
|
||||
"value": 61.35,
|
||||
"share": 0.995
|
||||
},
|
||||
"unique_per_second": {
|
||||
"value": 1.79,
|
||||
"share": 0.927
|
||||
},
|
||||
"waited_ticks_per_second": 0.0
|
||||
},
|
||||
"vanilla": {
|
||||
"chunks_per_second": {
|
||||
"value": 61.66,
|
||||
"share": 1.0
|
||||
},
|
||||
"unique_per_second": {
|
||||
"value": 1.93,
|
||||
"share": 1.0
|
||||
},
|
||||
"waited_ticks_per_second": 0.0
|
||||
}
|
||||
},
|
||||
"equal": true
|
||||
},
|
||||
{
|
||||
"behaviour": "mixed",
|
||||
"bots": 25,
|
||||
"servers": {
|
||||
"horizon": {
|
||||
"chunks_per_second": {
|
||||
"value": 158.57,
|
||||
"share": 1.0
|
||||
},
|
||||
"unique_per_second": {
|
||||
"value": 5.78,
|
||||
"share": 0.701
|
||||
},
|
||||
"waited_ticks_per_second": 0.0
|
||||
},
|
||||
"vanilla": {
|
||||
"chunks_per_second": {
|
||||
"value": 157.63,
|
||||
"share": 0.994
|
||||
},
|
||||
"unique_per_second": {
|
||||
"value": 8.25,
|
||||
"share": 1.0
|
||||
},
|
||||
"waited_ticks_per_second": 0.0
|
||||
}
|
||||
},
|
||||
"equal": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
# Horizon's server against vanilla 26.3: mixed bots (2026-10-18)
|
||||
|
||||
The first benchmark from docs/server.md section 10 (item 4): the same bots on Horizon's dedicated server, as
|
||||
`install.sh` installs it today, and on vanilla 26.3's, one server at a time on the same quiet machine.
|
||||
There were 1, 10, 25 and 50 bots, all with the `mixed` behaviour.
|
||||
|
||||
## Summary
|
||||
|
||||
- **Both servers held 20 TPS in every run.**
|
||||
- **Memory:** Horizon's RSS was 3.7 to 5.2 times smaller: 0.65 GB against 3.4 GB with one player, and
|
||||
1.0 GB against 4.0 GB with 50. Vanilla runs with the usual fixed heap (`-Xms4g -Xmx4g`), so its RSS
|
||||
is mostly that heap.
|
||||
- **Tick time (MSPT):**
|
||||
- with 1, 10 and 25 players, Horizon's average tick was shorter (2.4 against 17.9 ms, 12.4 against 34.5,
|
||||
24.0 against 31.6);
|
||||
- with 50, it was longer (35.2 against 29.7 ms);
|
||||
- Horizon's P99 was lower at every count, and so were its worst 5-second windows (241 ms at most,
|
||||
against 424 to 2320 ms for vanilla).
|
||||
- **The work was not equal, and the difference counts against Horizon.** In `mixed`, 20 % of the bots
|
||||
fly straight out at 22 blocks a second, as fast as each server sends them chunks. Horizon kept up:
|
||||
- with 10 or more players it sent 2.9 to 5.9 times as many chunks a second, and generated 1.9 to 2.9
|
||||
times as much new terrain a second;
|
||||
- its walking bots each received 3300 to 4000 chunks, against 640 to 1100 on vanilla once 10 or more
|
||||
were online.
|
||||
|
||||
So at 50 players Horizon's tick is 18 % longer while it generates twice the new terrain. The
|
||||
equal-rate explore pass of `../server-equal-work-2026-10-17/` is the fair comparison for exploring.
|
||||
- **Start (fresh world, to `Done`):** 10 to 20 s for Horizon, 14.5 to 28.6 s for vanilla.
|
||||
|
||||
## Results
|
||||
|
||||
MSPT is milliseconds per tick from each server's own `/tick query` (50 is the limit for 20 TPS). P95 and
|
||||
P99 are over the whole run. "Worst P99" is the highest P99 of a single 5-second query. RSS and CPU cover
|
||||
the server's whole process tree (100 % is one thread; the machine has 4). "New chunks/s" counts chunks
|
||||
no bot had before. "Pulled back" counts position packets that moved a bot back.
|
||||
|
||||
| Bots | Server | MSPT | P95 | P99 | Worst P99 | TPS | RSS (mean / max) | CPU | Start | Chunks/s | New chunks/s | Pulled back |
|
||||
|---:|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|
|
||||
| 1 | Horizon | **2.4** | 5.2 | 18.2 | 45.6 | 20 | **0.65 / 0.66 GB** | 25 % | 10.9 s | 9.9 | 0.3 | 0 |
|
||||
| 1 | vanilla | 17.9 | 27.6 | 47.3 | 423.8 | 20 | 3.38 / 3.39 GB | 64 % | 14.8 s | 9.9 | 0.3 | 0 |
|
||||
| 10 | Horizon | **12.4** | 36.0 | 65.9 | 117.1 | 20 | **0.94 / 1.01 GB** | 210 % | 10.2 s | 98.2 | 36.5 | 6267 |
|
||||
| 10 | vanilla | 34.5 | 63.5 | 138.6 | 884.7 | 20 | 3.59 / 3.66 GB | 217 % | 14.5 s | 24.3 | 19.1 | 5500 |
|
||||
| 25 | Horizon | **24.0** | 49.7 | 80.6 | 168.8 | 20 | **1.01 / 1.18 GB** | 192 % | 14.7 s | 178.2 | 31.9 | 5532 |
|
||||
| 25 | vanilla | 31.6 | 70.0 | 222.7 | 2319.6 | 20 | 3.74 / 4.06 GB | 218 % | 28.6 s | 30.4 | 10.8 | 4524 |
|
||||
| 50 | Horizon | 35.2 | 69.0 | 96.6 | 240.8 | 20 | **1.01 / 1.25 GB** | 218 % | 19.8 s | 273.2 | 34.6 | 8369 |
|
||||
| 50 | vanilla | **29.7** | 62.3 | 137.4 | 489.3 | 20 | 4.00 / 4.60 GB | 294 % | 20.6 s | 94.4 | 17.8 | 12034 |
|
||||
|
||||
Chunks each bot received, by behaviour (mean):
|
||||
|
||||
| Bots | Server | walk | explore | idle |
|
||||
|---:|---|---:|---:|---:|
|
||||
| 10 | Horizon | 3992 | 7360 | 473 |
|
||||
| 10 | vanilla | 680 | 2824 | 358 |
|
||||
| 25 | Horizon | 3928 | 2475 | 473 |
|
||||
| 25 | vanilla | 640 | 738 | 180 |
|
||||
| 50 | Horizon | 3300 | 1192 | 460 |
|
||||
| 50 | vanilla | 1105 | 629 | 220 |
|
||||
|
||||
No bot failed to join or was dropped, and no chunk was sent twice (`resent` 0), on either server. Vanilla
|
||||
also logged "moved too quickly" 12, 324 and 2193 times at 10, 25 and 50 bots.
|
||||
|
||||
## Method
|
||||
|
||||
`tools/server_bench.py`, unchanged, runs each configuration on a fresh server:
|
||||
|
||||
- the same `server.properties` on both: seed 12345, view and simulation distance 10, offline, creative,
|
||||
difficulty easy, `sync-chunk-writes=true`, white-list off;
|
||||
- `gamerule respawn_radius 0`, and otherwise vanilla's default game rules on both. The locator bar is on
|
||||
for both: Horizon's server has run it since v2026.10.18.13. The 2026-10-17 runs turned it off on vanilla
|
||||
because Horizon had none then;
|
||||
- the server waits for `Done`, then the bots join one a second, warm up for 60 seconds, and are measured
|
||||
for 300 seconds, with `/tick query` every 5 seconds and RSS and CPU every second.
|
||||
|
||||
The bots are `horizon-bots --behaviour mixed`: 60 % walk, 20 % explore and 20 % idle, each choice
|
||||
deterministic per bot. All are creative and fly 24 blocks above their spawn:
|
||||
|
||||
- `walk`: random points within 48 blocks at 5.6 blocks a second;
|
||||
- `explore`: straight out at up to 22 blocks a second, as fast as chunks come;
|
||||
- `idle`: hovers.
|
||||
|
||||
A bot doesn't move while the chunk it stands in hasn't arrived, and it acknowledges chunk batches as
|
||||
vanilla's client does.
|
||||
|
||||
**Machine.** The ThinkPad: Intel Core i7-7500U (2 cores, 4 threads), 32 GB, NixOS (Linux 6.18). No other
|
||||
session ran on it (`load.txt`: the fleet monitor shows 0 sessions throughout). The busy periods are the
|
||||
servers themselves, which used 2 to 3 of its 4 threads from 10 bots up, so both servers were CPU-bound
|
||||
there. The servers ran under `nice -n 19`. The desktop was meant to run this (24 threads) but didn't
|
||||
wake. The bots ran on the Mac mini (M4 Pro) and reached the ThinkPad over the tailnet, so they took none
|
||||
of the servers' CPU. The Mac mini was shared with other work (70 to 90 % busy), which only affects the
|
||||
bots' timing.
|
||||
|
||||
**What ran.**
|
||||
|
||||
- Horizon: the published v2026.10.18.15 release, `horizon-client` (the engine) at 6c078b28, as
|
||||
`install.sh` installs it. Its game files were prepared from the owner's own Minecraft by the release's
|
||||
`horizon-prepare`. `horizon-server` (the supervisor, which takes no part in the tick) came from #898
|
||||
(4ea2243e), because the release's copy can't find game files prepared without sounds (#893).
|
||||
`horizon-bots` came from main.
|
||||
- Vanilla: the pinned 26.3 server jar (the owner's own copy) on OpenJDK 25.0.4.1, `-Xms4g -Xmx4g`.
|
||||
|
||||
On Linux the release's engine needs `libasound.so.2` and `libudev.so.1`. The ThinkPad has them only in
|
||||
the Nix store, so the run set `LD_LIBRARY_PATH` to them (see #898).
|
||||
|
||||
## Reproduce
|
||||
|
||||
curl -fsSL https://raw.githubusercontent.com/ludovic111/horizon/main/packaging/server/install.sh | sh
|
||||
horizon-prepare --prepare --server-jar /path/to/server.jar # your own copy
|
||||
cargo build --release -p horizon-bots # on the machine that runs the bots
|
||||
# in a checkout whose .local/minecraft holds the pinned vanilla jars (tools/lab.py prepare):
|
||||
HORIZON_BENCH_BIN=<a folder with horizon-server and horizon-client> \
|
||||
python3 tools/server_bench.py --servers horizon,vanilla --bots 1,10,25,50 --behaviour mixed --nice 19 \
|
||||
--bots-via 'ssh <bots machine>' --bots-bin /path/to/horizon-bots --connect <this machine's address> \
|
||||
--out mixed.json
|
||||
|
||||
`mixed.json` is the report (`horizon-server-benchmark`: machine, versions, settings and every run), and
|
||||
`load.txt` is the ThinkPad's load before and during the run.
|
||||
|
||||
## Next
|
||||
|
||||
- An equal-work `mixed` pass (`--explore-speed` at a rate both servers keep up with), then 100 bots.
|
||||
- The same run on a bigger machine, so neither server is CPU-bound at 25 to 50 bots.
|
||||
- Paper and Fabric + Lithium (docs/server.md section 9).
|
||||
- At 50 players Horizon's tick is longer than vanilla's while it generates and sends far more. The
|
||||
profile of the 2026-10-17 run (streaming and block entity ticks growing with players) is
|
||||
perf-server's to take on.
|
||||
@@ -0,0 +1,286 @@
|
||||
ludothinkpad — OK
|
||||
RAM 29.1 GB free of 31.2 GB · swap 0.3 GB/15.6 GB
|
||||
CPU 4 threads, 2% busy (agents 0.0, rest 0.1 cores) · 67°C · load 2.1
|
||||
· disk 295.5 GB free · battery 96%
|
||||
|
||||
Sessions, most important first:
|
||||
(finished session) 0.0 GB leftovers: node 0.0 GB
|
||||
|
||||
Other machines (≤ 1 min old): desktop offline · macbook offline · macmini ok: 26.6 GB free, 14 threads 69% busy, 1 sessions
|
||||
|
||||
# During the run, once a minute (uptime, then ~/fleet/load fleet)
|
||||
18:25:30
|
||||
18:25:30 up 8 days 3:08, 0 users, load average: 2.13, 1.53, 1.29
|
||||
ludothinkpad ok: 29.1 GB free, 4 threads 2% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.6 GB free, 14 threads 87% busy, 1 sessions
|
||||
18:26:34
|
||||
18:26:34 up 8 days 3:09, 0 users, load average: 1.70, 1.56, 1.31
|
||||
ludothinkpad ok: 28.5 GB free, 4 threads 23% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.4 GB free, 14 threads 85% busy, 1 sessions
|
||||
18:27:38
|
||||
18:27:38 up 8 days 3:10, 0 users, load average: 1.10, 1.43, 1.28
|
||||
ludothinkpad ok: 28.5 GB free, 4 threads 4% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.7 GB free, 14 threads 80% busy, 1 sessions
|
||||
18:28:42
|
||||
18:28:42 up 8 days 3:11, 0 users, load average: 0.93, 1.29, 1.24
|
||||
ludothinkpad ok: 28.5 GB free, 4 threads 22% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.0 GB free, 14 threads 82% busy, 1 sessions
|
||||
18:29:46
|
||||
18:29:46 up 8 days 3:12, 0 users, load average: 0.62, 1.12, 1.18
|
||||
ludothinkpad ok: 28.5 GB free, 4 threads 12% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 25.7 GB free, 14 threads 81% busy, 1 sessions
|
||||
18:30:50
|
||||
18:30:51 up 8 days 3:13, 0 users, load average: 0.79, 1.05, 1.15
|
||||
ludothinkpad ok: 28.5 GB free, 4 threads 7% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.0 GB free, 14 threads 88% busy, 1 sessions
|
||||
18:31:55
|
||||
18:31:55 up 8 days 3:14, 0 users, load average: 0.67, 0.96, 1.11
|
||||
ludothinkpad ok: 28.6 GB free, 4 threads 73% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.3 GB free, 14 threads 79% busy, 1 sessions
|
||||
18:32:59
|
||||
18:32:59 up 8 days 3:15, 0 users, load average: 4.01, 1.91, 1.44
|
||||
ludothinkpad ok: 25.9 GB free, 4 threads 24% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.4 GB free, 14 threads 85% busy, 1 sessions
|
||||
18:34:03
|
||||
18:34:03 up 8 days 3:16, 0 users, load average: 2.24, 1.84, 1.44
|
||||
ludothinkpad ok: 25.9 GB free, 4 threads 21% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.2 GB free, 14 threads 86% busy, 1 sessions
|
||||
18:35:07
|
||||
18:35:07 up 8 days 3:17, 0 users, load average: 1.28, 1.63, 1.40
|
||||
ludothinkpad ok: 25.8 GB free, 4 threads 21% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 31.0 GB free, 14 threads 86% busy, 1 sessions
|
||||
18:36:11
|
||||
18:36:11 up 8 days 3:18, 0 users, load average: 0.79, 1.41, 1.33
|
||||
ludothinkpad ok: 25.9 GB free, 4 threads 18% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.3 GB free, 14 threads 93% busy, 1 sessions
|
||||
18:37:15
|
||||
18:37:15 up 8 days 3:20, 0 users, load average: 1.44, 1.47, 1.36
|
||||
ludothinkpad ok: 25.9 GB free, 4 threads 23% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.8 GB free, 14 threads 86% busy, 1 sessions
|
||||
18:38:19
|
||||
18:38:19 up 8 days 3:21, 0 users, load average: 1.37, 1.45, 1.36
|
||||
ludothinkpad ok: 25.9 GB free, 4 threads 13% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.7 GB free, 14 threads 86% busy, 1 sessions
|
||||
18:39:24
|
||||
18:39:24 up 8 days 3:22, 0 users, load average: 2.27, 1.66, 1.44
|
||||
ludothinkpad ok: 28.3 GB free, 4 threads 62% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.1 GB free, 14 threads 70% busy, 1 sessions
|
||||
18:40:28
|
||||
18:40:28 up 8 days 3:23, 0 users, load average: 1.95, 1.72, 1.48
|
||||
ludothinkpad ok: 28.3 GB free, 4 threads 63% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.7 GB free, 14 threads 84% busy, 1 sessions
|
||||
18:41:32
|
||||
18:41:32 up 8 days 3:24, 0 users, load average: 3.32, 2.22, 1.67
|
||||
ludothinkpad ok: 28.2 GB free, 4 threads 61% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.8 GB free, 14 threads 85% busy, 1 sessions
|
||||
18:42:36
|
||||
18:42:36 up 8 days 3:25, 0 users, load average: 3.13, 2.33, 1.75
|
||||
ludothinkpad ok: 28.2 GB free, 4 threads 60% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.1 GB free, 14 threads 91% busy, 1 sessions
|
||||
18:43:40
|
||||
18:43:40 up 8 days 3:26, 0 users, load average: 3.27, 2.48, 1.83
|
||||
ludothinkpad busy: 28.1 GB free, 4 threads 90% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.3 GB free, 14 threads 92% busy, 1 sessions
|
||||
18:44:44
|
||||
18:44:44 up 8 days 3:27, 0 users, load average: 2.14, 2.32, 1.82
|
||||
ludothinkpad ok: 28.1 GB free, 4 threads 55% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 30.4 GB free, 14 threads 88% busy, 1 sessions
|
||||
18:45:48
|
||||
18:45:48 up 8 days 3:28, 0 users, load average: 4.94, 3.06, 2.11
|
||||
ludothinkpad busy: 25.9 GB free, 4 threads 86% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.7 GB free, 14 threads 84% busy, 1 sessions
|
||||
18:46:53
|
||||
18:46:53 up 8 days 3:29, 0 users, load average: 6.55, 3.92, 2.47
|
||||
ludothinkpad busy: 25.4 GB free, 4 threads 99% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.3 GB free, 14 threads 81% busy, 1 sessions
|
||||
18:47:57
|
||||
18:47:57 up 8 days 3:30, 0 users, load average: 8.50, 4.96, 2.93
|
||||
ludothinkpad busy: 24.0 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 27.9 GB free, 14 threads 90% busy, 1 sessions
|
||||
18:49:01
|
||||
18:49:01 up 8 days 3:31, 0 users, load average: 8.59, 5.68, 3.31
|
||||
ludothinkpad busy: 22.7 GB free, 4 threads 99% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.2 GB free, 14 threads 85% busy, 1 sessions
|
||||
18:50:05
|
||||
18:50:05 up 8 days 3:32, 0 users, load average: 7.81, 6.07, 3.61
|
||||
ludothinkpad busy: 24.5 GB free, 4 threads 90% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.6 GB free, 14 threads 96% busy, 1 sessions
|
||||
18:51:09
|
||||
18:51:09 up 8 days 3:33, 0 users, load average: 8.29, 6.50, 3.93
|
||||
ludothinkpad busy: 24.3 GB free, 4 threads 92% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.0 GB free, 14 threads 94% busy, 1 sessions
|
||||
18:52:14
|
||||
18:52:14 up 8 days 3:35, 0 users, load average: 5.58, 6.06, 3.95
|
||||
ludothinkpad busy: 26.0 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.3 GB free, 14 threads 87% busy, 1 sessions
|
||||
18:53:18
|
||||
18:53:18 up 8 days 3:36, 0 users, load average: 4.53, 5.69, 3.97
|
||||
ludothinkpad busy: 27.2 GB free, 4 threads 89% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.8 GB free, 14 threads 87% busy, 1 sessions
|
||||
18:54:22
|
||||
18:54:22 up 8 days 3:37, 0 users, load average: 5.31, 5.64, 4.07
|
||||
ludothinkpad busy: 26.3 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.3 GB free, 14 threads 91% busy, 1 sessions
|
||||
18:55:26
|
||||
18:55:26 up 8 days 3:38, 0 users, load average: 10.47, 6.99, 4.63
|
||||
ludothinkpad busy: 26.1 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.7 GB free, 14 threads 90% busy, 1 sessions
|
||||
18:56:30
|
||||
18:56:30 up 8 days 3:39, 0 users, load average: 9.27, 7.45, 4.96
|
||||
ludothinkpad busy: 26.2 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.5 GB free, 14 threads 92% busy, 1 sessions
|
||||
18:57:35
|
||||
18:57:35 up 8 days 3:40, 0 users, load average: 7.79, 7.39, 5.10
|
||||
ludothinkpad busy: 26.1 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.1 GB free, 14 threads 80% busy, 1 sessions
|
||||
18:58:39
|
||||
18:58:39 up 8 days 3:41, 0 users, load average: 8.06, 7.55, 5.32
|
||||
ludothinkpad busy: 26.4 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 31.8 GB free, 14 threads 95% busy, 1 sessions
|
||||
18:59:43
|
||||
18:59:43 up 8 days 3:42, 0 users, load average: 8.44, 7.65, 5.50
|
||||
ludothinkpad busy: 26.2 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 31.4 GB free, 14 threads 94% busy, 1 sessions
|
||||
19:00:47
|
||||
19:00:47 up 8 days 3:43, 0 users, load average: 11.04, 8.66, 6.00
|
||||
ludothinkpad busy: 24.9 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 31.8 GB free, 14 threads 88% busy, 1 sessions
|
||||
19:01:51
|
||||
19:01:51 up 8 days 3:44, 0 users, load average: 11.91, 9.37, 6.41
|
||||
ludothinkpad busy: 24.4 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 32.9 GB free, 14 threads 77% busy, 1 sessions
|
||||
19:02:56
|
||||
19:02:56 up 8 days 3:45, 0 users, load average: 11.64, 9.85, 6.79
|
||||
ludothinkpad ok: 25.5 GB free, 4 threads 70% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 30.9 GB free, 14 threads 91% busy, 1 sessions
|
||||
19:04:00
|
||||
19:04:00 up 8 days 3:46, 0 users, load average: 11.42, 10.06, 7.06
|
||||
ludothinkpad busy: 23.4 GB free, 4 threads 99% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.4 GB free, 14 threads 94% busy, 1 sessions
|
||||
19:05:04
|
||||
19:05:04 up 8 days 3:47, 0 users, load average: 9.83, 9.96, 7.24
|
||||
ludothinkpad busy: 23.2 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 31.4 GB free, 14 threads 80% busy, 1 sessions
|
||||
19:06:09
|
||||
19:06:09 up 8 days 3:48, 0 users, load average: 8.38, 9.68, 7.34
|
||||
ludothinkpad ok: 22.7 GB free, 4 threads 17% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.8 GB free, 14 threads 86% busy, 1 sessions
|
||||
19:07:13
|
||||
19:07:13 up 8 days 3:49, 0 users, load average: 4.51, 8.27, 7.00
|
||||
ludothinkpad ok: 25.7 GB free, 4 threads 75% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 26.5 GB free, 14 threads 89% busy, 1 sessions
|
||||
19:08:17
|
||||
19:08:17 up 8 days 3:51, 0 users, load average: 6.77, 8.13, 7.04
|
||||
ludothinkpad busy: 25.8 GB free, 4 threads 95% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 30.8 GB free, 14 threads 91% busy, 1 sessions
|
||||
19:09:22
|
||||
19:09:22 up 8 days 3:52, 0 users, load average: 8.27, 8.25, 7.14
|
||||
ludothinkpad busy: 25.2 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.3 GB free, 14 threads 91% busy, 1 sessions
|
||||
19:10:26
|
||||
19:10:26 up 8 days 3:53, 0 users, load average: 8.88, 8.57, 7.34
|
||||
ludothinkpad busy: 24.8 GB free, 4 threads 99% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 32.4 GB free, 14 threads 72% busy, 1 sessions
|
||||
19:11:30
|
||||
19:11:30 up 8 days 3:54, 0 users, load average: 13.33, 10.05, 7.94
|
||||
ludothinkpad busy: 24.7 GB free, 4 threads 97% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 30.1 GB free, 14 threads 87% busy, 1 sessions
|
||||
19:12:35
|
||||
19:12:35 up 8 days 3:55, 0 users, load average: 10.92, 10.13, 8.12
|
||||
ludothinkpad ok: 26.4 GB free, 4 threads 76% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.3 GB free, 14 threads 86% busy, 1 sessions
|
||||
19:13:39
|
||||
19:13:39 up 8 days 3:56, 0 users, load average: 9.98, 9.89, 8.16
|
||||
ludothinkpad busy: 25.8 GB free, 4 threads 90% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.8 GB free, 14 threads 93% busy, 1 sessions
|
||||
19:14:43
|
||||
19:14:43 up 8 days 3:57, 0 users, load average: 8.95, 9.63, 8.19
|
||||
ludothinkpad busy: 25.1 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 29.6 GB free, 14 threads 71% busy, 1 sessions
|
||||
19:15:47
|
||||
19:15:47 up 8 days 3:58, 0 users, load average: 12.02, 10.38, 8.55
|
||||
ludothinkpad busy: 24.5 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 28.1 GB free, 14 threads 93% busy, 1 sessions
|
||||
19:16:52
|
||||
19:16:52 up 8 days 3:59, 0 users, load average: 13.82, 11.21, 8.95
|
||||
ludothinkpad busy: 23.9 GB free, 4 threads 100% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.4 GB free, 14 threads 75% busy, 1 sessions
|
||||
19:17:56
|
||||
19:17:56 up 8 days 4:00, 0 users, load average: 11.95, 11.20, 9.10
|
||||
ludothinkpad busy: 25.0 GB free, 4 threads 99% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.4 GB free, 14 threads 81% busy, 1 sessions
|
||||
19:19:00
|
||||
19:19:00 up 8 days 4:01, 0 users, load average: 11.46, 11.14, 9.22
|
||||
ludothinkpad busy: 24.6 GB free, 4 threads 95% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.4 GB free, 14 threads 83% busy, 1 sessions
|
||||
19:20:04
|
||||
19:20:04 up 8 days 4:02, 0 users, load average: 11.11, 10.97, 9.28
|
||||
ludothinkpad busy: 24.6 GB free, 4 threads 93% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 26.7 GB free, 14 threads 85% busy, 1 sessions
|
||||
19:21:08
|
||||
19:21:08 up 8 days 4:03, 0 users, load average: 9.81, 10.60, 9.27
|
||||
ludothinkpad busy: 24.4 GB free, 4 threads 91% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 27.8 GB free, 14 threads 75% busy, 1 sessions
|
||||
19:22:13
|
||||
19:22:13 up 8 days 4:04, 0 users, load average: 5.98, 9.51, 9.00
|
||||
ludothinkpad ok: 23.8 GB free, 4 threads 18% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini busy: 29.7 GB free, 14 threads 85% busy, 1 sessions
|
||||
19:23:17
|
||||
19:23:17 up 8 days 4:06, 0 users, load average: 4.01, 8.27, 8.60
|
||||
ludothinkpad ok: 23.1 GB free, 4 threads 56% busy, 0 sessions
|
||||
desktop offline
|
||||
macmini ok: 28.2 GB free, 14 threads 79% busy, 1 sessions
|
||||
@@ -0,0 +1,367 @@
|
||||
{
|
||||
"kind": "horizon-server-benchmark",
|
||||
"date": "2026-10-18T17:23:30+00:00",
|
||||
"machine": {
|
||||
"system": "Linux",
|
||||
"machine": "x86_64",
|
||||
"cpus": 4,
|
||||
"note": "ThinkPad: Intel Core i7-7500U (2 cores, 4 threads), 32 GB, NixOS, Linux 6.18; the bots on the Mac mini (M4 Pro) over the tailnet"
|
||||
},
|
||||
"commit": "4ea2243e4d1a44f910857bd759845db70e3690a8",
|
||||
"java": [
|
||||
"openjdk 25.0.4.1 2026-08-18"
|
||||
],
|
||||
"settings": {
|
||||
"servers": "horizon,vanilla",
|
||||
"bots": "1,10,25,50",
|
||||
"behaviour": "mixed",
|
||||
"join_every": 1.0,
|
||||
"warmup": 60,
|
||||
"seconds": 300,
|
||||
"seed": 12345,
|
||||
"explore_speed": 0,
|
||||
"gamerule": "",
|
||||
"heap": "4g",
|
||||
"out": "mixed.json",
|
||||
"nice": 19,
|
||||
"bots_via": "ssh macmini",
|
||||
"bots_bin": "horizon-bots (on the Mac mini)",
|
||||
"connect": "<the ThinkPad's tailnet address>",
|
||||
"properties": {
|
||||
"level-seed": "12345",
|
||||
"view-distance": "10",
|
||||
"simulation-distance": "10",
|
||||
"online-mode": "false",
|
||||
"white-list": "false",
|
||||
"gamemode": "creative",
|
||||
"force-gamemode": "true",
|
||||
"spawn-protection": "0",
|
||||
"max-players": "200",
|
||||
"difficulty": "easy",
|
||||
"sync-chunk-writes": "true"
|
||||
}
|
||||
},
|
||||
"runs": [
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 1,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 10.92,
|
||||
"mspt": {
|
||||
"average": 2.38,
|
||||
"p50": 1.97,
|
||||
"p95": 5.17,
|
||||
"p99": 18.2
|
||||
},
|
||||
"mspt_worst_p99": 45.6,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 653.7,
|
||||
"max": 659.2
|
||||
},
|
||||
"cpu_percent": 24.51,
|
||||
"chunks_per_second": 9.9,
|
||||
"unique_per_second": 0.3,
|
||||
"forgotten_per_second": 9.93,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 3951,
|
||||
"chunks_per_bot": {
|
||||
"walk": 3951.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 699.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 0,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 1,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 1,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 14.75,
|
||||
"mspt": {
|
||||
"average": 17.9,
|
||||
"p50": 18.39,
|
||||
"p95": 27.58,
|
||||
"p99": 47.28
|
||||
},
|
||||
"mspt_worst_p99": 423.8,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 3382.06,
|
||||
"max": 3394.1
|
||||
},
|
||||
"cpu_percent": 64.02,
|
||||
"chunks_per_second": 9.92,
|
||||
"unique_per_second": 0.29,
|
||||
"forgotten_per_second": 9.95,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 3846,
|
||||
"chunks_per_bot": {
|
||||
"walk": 3846.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 699.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 0,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 1,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 10,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 10.22,
|
||||
"mspt": {
|
||||
"average": 12.39,
|
||||
"p50": 8.33,
|
||||
"p95": 35.99,
|
||||
"p99": 65.9
|
||||
},
|
||||
"mspt_worst_p99": 117.1,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 935.85,
|
||||
"max": 1008.6
|
||||
},
|
||||
"cpu_percent": 210.37,
|
||||
"chunks_per_second": 98.22,
|
||||
"unique_per_second": 36.49,
|
||||
"forgotten_per_second": 98.25,
|
||||
"waited_ticks_per_second": 0.0,
|
||||
"chunks_total": 39618,
|
||||
"chunks_per_bot": {
|
||||
"walk": 3992.17,
|
||||
"explore": 7359.5,
|
||||
"idle": 473.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 696.83,
|
||||
"explore": 6869.0,
|
||||
"idle": 473.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 6267,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 10,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 10,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 14.54,
|
||||
"mspt": {
|
||||
"average": 34.47,
|
||||
"p50": 29.67,
|
||||
"p95": 63.52,
|
||||
"p99": 138.58
|
||||
},
|
||||
"mspt_worst_p99": 884.7,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 3594.26,
|
||||
"max": 3661.7
|
||||
},
|
||||
"cpu_percent": 217.13,
|
||||
"chunks_per_second": 24.34,
|
||||
"unique_per_second": 19.13,
|
||||
"forgotten_per_second": 20.12,
|
||||
"waited_ticks_per_second": 0.62,
|
||||
"chunks_total": 10443,
|
||||
"chunks_per_bot": {
|
||||
"walk": 679.83,
|
||||
"explore": 2824.0,
|
||||
"idle": 358.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 389.17,
|
||||
"explore": 2824.0,
|
||||
"idle": 358.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 5500,
|
||||
"moved_too_quickly": 12,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 10,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 25,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 14.73,
|
||||
"mspt": {
|
||||
"average": 24.0,
|
||||
"p50": 21.07,
|
||||
"p95": 49.72,
|
||||
"p99": 80.57
|
||||
},
|
||||
"mspt_worst_p99": 168.8,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 1013.07,
|
||||
"max": 1179.4
|
||||
},
|
||||
"cpu_percent": 192.47,
|
||||
"chunks_per_second": 178.23,
|
||||
"unique_per_second": 31.85,
|
||||
"forgotten_per_second": 177.93,
|
||||
"waited_ticks_per_second": 60.59,
|
||||
"chunks_total": 73657,
|
||||
"chunks_per_bot": {
|
||||
"walk": 3927.87,
|
||||
"explore": 2474.8,
|
||||
"idle": 473.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 691.73,
|
||||
"explore": 2447.8,
|
||||
"idle": 473.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 5532,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 25,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 58
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 25,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 28.57,
|
||||
"mspt": {
|
||||
"average": 31.59,
|
||||
"p50": 25.18,
|
||||
"p95": 70.03,
|
||||
"p99": 222.74
|
||||
},
|
||||
"mspt_worst_p99": 2319.6,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 3742.51,
|
||||
"max": 4055.0
|
||||
},
|
||||
"cpu_percent": 218.34,
|
||||
"chunks_per_second": 30.37,
|
||||
"unique_per_second": 10.84,
|
||||
"forgotten_per_second": 29.44,
|
||||
"waited_ticks_per_second": 50.91,
|
||||
"chunks_total": 14193,
|
||||
"chunks_per_bot": {
|
||||
"walk": 640.2,
|
||||
"explore": 738.0,
|
||||
"idle": 180.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 211.33,
|
||||
"explore": 737.6,
|
||||
"idle": 180.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 4524,
|
||||
"moved_too_quickly": 324,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 25,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 56
|
||||
},
|
||||
{
|
||||
"server": "horizon",
|
||||
"bots": 50,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 19.84,
|
||||
"mspt": {
|
||||
"average": 35.2,
|
||||
"p50": 32.12,
|
||||
"p95": 69.04,
|
||||
"p99": 96.56
|
||||
},
|
||||
"mspt_worst_p99": 240.8,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 1013.2,
|
||||
"max": 1249.1
|
||||
},
|
||||
"cpu_percent": 217.68,
|
||||
"chunks_per_second": 273.18,
|
||||
"unique_per_second": 34.58,
|
||||
"forgotten_per_second": 268.19,
|
||||
"waited_ticks_per_second": 138.29,
|
||||
"chunks_total": 115527,
|
||||
"chunks_per_bot": {
|
||||
"walk": 3300.1,
|
||||
"explore": 1192.4,
|
||||
"idle": 460.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 632.67,
|
||||
"explore": 1186.9,
|
||||
"idle": 460.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 8369,
|
||||
"moved_too_quickly": 0,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 50,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 57
|
||||
},
|
||||
{
|
||||
"server": "vanilla",
|
||||
"bots": 50,
|
||||
"behaviour": "mixed",
|
||||
"start_seconds": 20.58,
|
||||
"mspt": {
|
||||
"average": 29.74,
|
||||
"p50": 23.6,
|
||||
"p95": 62.25,
|
||||
"p99": 137.41
|
||||
},
|
||||
"mspt_worst_p99": 489.3,
|
||||
"tps": 20.0,
|
||||
"rss_mb": {
|
||||
"mean": 3995.71,
|
||||
"max": 4597.8
|
||||
},
|
||||
"cpu_percent": 294.31,
|
||||
"chunks_per_second": 94.36,
|
||||
"unique_per_second": 17.76,
|
||||
"forgotten_per_second": 94.69,
|
||||
"waited_ticks_per_second": 101.48,
|
||||
"chunks_total": 41637,
|
||||
"chunks_per_bot": {
|
||||
"walk": 1104.97,
|
||||
"explore": 628.8,
|
||||
"idle": 220.0
|
||||
},
|
||||
"unique_chunks_per_bot": {
|
||||
"walk": 279.4,
|
||||
"explore": 626.4,
|
||||
"idle": 220.0
|
||||
},
|
||||
"resent": 0,
|
||||
"pulled_back": 12034,
|
||||
"moved_too_quickly": 2193,
|
||||
"moved_wrongly": 0,
|
||||
"bots_joined": 50,
|
||||
"bots_failed": [],
|
||||
"tick_queries": 57
|
||||
}
|
||||
],
|
||||
"horizon_build": "v2026.10.18.15 release binaries (horizon-client, the engine, at 6c078b28); horizon-server from #898 (4ea2243e, the supervisor only)"
|
||||
}
|
||||
@@ -31,7 +31,8 @@ toml = "1.1"
|
||||
naga = { version = "30.0.1", features = ["wgsl-in"] }
|
||||
# Java (OptiFine/Iris) shader packs, translated to WGSL.
|
||||
horizon-shaderpack = { path = "../horizon-shaderpack" }
|
||||
cpal = "0.16"
|
||||
# Sound (ALSA on Linux); the `audio` feature.
|
||||
cpal = { version = "0.16", optional = true }
|
||||
symphonia = { version = "0.5", default-features = false, features = ["ogg", "vorbis"] }
|
||||
miniz_oxide = "0.8"
|
||||
ab_glyph = "0.2.32"
|
||||
@@ -44,18 +45,28 @@ horizon-telemetry = { path = "../horizon-telemetry", default-features = false }
|
||||
horizon-bench = { path = "../horizon-bench" }
|
||||
arboard = { version = "3.6.1", default-features = false, features = ["wayland-data-control"] }
|
||||
zip = { version = "2", default-features = false, features = ["deflate"] }
|
||||
# Controllers (evdev + libudev on Linux, IOKit on macOS, Windows.Gaming.Input).
|
||||
gilrs = "0.11"
|
||||
# Controllers (evdev + libudev on Linux, IOKit on macOS, Windows.Gaming.Input); the `controllers` feature.
|
||||
gilrs = { version = "0.11", optional = true }
|
||||
# The DualSense's rumble, adaptive triggers and lights over HID (gilrs only reads it).
|
||||
horizon-dualsense = { path = "../horizon-dualsense" }
|
||||
horizon-dualsense = { path = "../horizon-dualsense", optional = true }
|
||||
# HTTPS to the Minecraft services (online-mode session join).
|
||||
ureq = { version = "2", default-features = false, features = ["tls"] }
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
# The server thread's CPU time per tick (`HORIZON_SPIKES`, spans.rs).
|
||||
rustix = { version = "1", default-features = false, features = ["std", "time"] }
|
||||
|
||||
[target.'cfg(windows)'.build-dependencies]
|
||||
# The icon resource in the .exe (build.rs).
|
||||
winresource = "0.1"
|
||||
|
||||
[features]
|
||||
default = ["audio", "controllers"]
|
||||
# Sound output. Without it (and `controllers`) the program links neither libasound nor libudev on
|
||||
# Linux: the server build (`--no-default-features`, released as horizon-engine; docs/server.md).
|
||||
audio = ["dep:cpal"]
|
||||
# Controllers: gilrs, and the DualSense's own output. Without it only `horizon-ctl pad`'s virtual pad.
|
||||
controllers = ["dep:gilrs", "dep:horizon-dualsense"]
|
||||
# Records the call sites of mob random draws (`mob_ai_probe` traces).
|
||||
rng-trace = ["horizon-core/rng-trace"]
|
||||
|
||||
|
||||
@@ -58,11 +58,12 @@ fn main() -> Result<()> {
|
||||
let root = PathBuf::from(&args[0]);
|
||||
let dir = PathBuf::from(&args[1]);
|
||||
let assets = Assets::load(&root)?;
|
||||
let mut scene = World::test_scene(&assets, 1)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let mut scene = World::test_scene(&assets, &render, 1)?;
|
||||
fs::write(
|
||||
dir.join("scene.json"),
|
||||
serde_json::to_vec(
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":assets.model_gallery}),
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":render.model_gallery}),
|
||||
)?,
|
||||
)?;
|
||||
if args[2] == "--describe" {
|
||||
|
||||
@@ -31,13 +31,14 @@ fn main() -> Result<()> {
|
||||
};
|
||||
let root = PathBuf::from(root);
|
||||
let assets = Assets::load(&root)?;
|
||||
let mut scene = World::test_scene(&assets, 1)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let mut scene = World::test_scene(&assets, &render, 1)?;
|
||||
let binding = collisions::load(&root, assets.registry)?;
|
||||
let resources = MotionResources::load(&root, &assets)?;
|
||||
fs::write(
|
||||
scene_json,
|
||||
serde_json::to_vec(&serde_json::json!({
|
||||
"radius": 1, "resident_chunks": scene.chunks.len(), "model_gallery": assets.model_gallery,
|
||||
"radius": 1, "resident_chunks": scene.chunks.len(), "model_gallery": render.model_gallery,
|
||||
}))?,
|
||||
)?;
|
||||
let mut out = BufWriter::new(fs::File::create(output)?);
|
||||
|
||||
@@ -12,9 +12,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
let root = Path::new(&args[1]);
|
||||
let assets = Assets::load(root)?;
|
||||
let render = assets.reload(root)?;
|
||||
let facts = BlockFacts::load(root, assets.registry)?;
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(root, assets.registry)?,
|
||||
)?;
|
||||
|
||||
@@ -18,9 +18,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
let root = Path::new(&args[1]);
|
||||
let assets = Assets::load(root)?;
|
||||
let render = assets.reload(root)?;
|
||||
let facts = BlockFacts::load(root, assets.registry)?;
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(root, assets.registry)?,
|
||||
)?;
|
||||
@@ -33,7 +35,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let mut vertices = Vec::new();
|
||||
let mut translucent = false;
|
||||
if facts.get(state).render_shape == RenderShape::Model {
|
||||
let models = assets
|
||||
let models = render
|
||||
.model_catalog
|
||||
.collect(state, BlockPos::new(p[0], p[1], p[2]))?;
|
||||
let offset = tables.offset(state, p[0], p[2]).unwrap_or([0.0; 3]);
|
||||
|
||||
@@ -31,10 +31,12 @@ fn main() -> Result<()> {
|
||||
};
|
||||
let (seed, size) = (flag("--seed", 12345), flag("--size", 8) as i32);
|
||||
let assets = Assets::load(&root)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let facts = BlockFacts::load(&root, assets.registry)?;
|
||||
let biomes = Biomes::load(&root)?;
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(&root, assets.registry)?,
|
||||
)?;
|
||||
@@ -132,6 +134,7 @@ fn main() -> Result<()> {
|
||||
let mut mesher = Mesher {
|
||||
nether_shading: false,
|
||||
assets: &assets,
|
||||
render: &render,
|
||||
tables: &tables,
|
||||
biomes: &biomes,
|
||||
visibility: tables.visibility.clone(),
|
||||
|
||||
@@ -233,22 +233,32 @@ fn mouse(c: &Value, out: &mut impl Write) -> Result<()> {
|
||||
fn scroll(c: &Value, out: &mut impl Write) -> Result<()> {
|
||||
let mut handler = MouseLook::default();
|
||||
let mut slot = c["slot"].as_i64().unwrap() as i32;
|
||||
let spectator = c["spectator"].as_bool().unwrap_or(false);
|
||||
let mut speed = 0.05;
|
||||
// OptionInstance.set quantises the wheel sensitivity.
|
||||
let mut file = OptionsFile::default();
|
||||
file.set("mouseWheelSensitivity", V::Double(db(&c["sens"])));
|
||||
let sensitivity = file.double("mouseWheelSensitivity");
|
||||
writeln!(out, "scroll")?;
|
||||
for op in c["ops"].as_array().unwrap() {
|
||||
if let Some((wheel, _)) =
|
||||
if let Some((wheel, (_, y))) =
|
||||
handler.on_scroll(db(&op[0]), db(&op[1]), b(&c["discrete"]), sensitivity)
|
||||
{
|
||||
slot = horizon_client::mouse::ScrollWheelHandler::next_selection(
|
||||
f64::from(wheel),
|
||||
slot,
|
||||
9,
|
||||
);
|
||||
if spectator {
|
||||
speed = horizon_client::mouse::spectator_flying_speed(speed, y);
|
||||
} else {
|
||||
slot = horizon_client::mouse::ScrollWheelHandler::next_selection(
|
||||
f64::from(wheel),
|
||||
slot,
|
||||
9,
|
||||
);
|
||||
}
|
||||
}
|
||||
if spectator {
|
||||
writeln!(out, "{slot} {}", fb(speed))?;
|
||||
} else {
|
||||
writeln!(out, "{slot}")?;
|
||||
}
|
||||
writeln!(out, "{slot}")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
use horizon_client::interaction_input::{
|
||||
Button, InteractionInput, InteractionWorld, TargetUseWorld, use_on_target,
|
||||
};
|
||||
use serde_json::Value;
|
||||
use std::io::{BufRead, Write};
|
||||
|
||||
struct World {
|
||||
using: bool,
|
||||
destroying: bool,
|
||||
entity: bool,
|
||||
dig_on_attack: bool,
|
||||
begin_using: bool,
|
||||
delay: u32,
|
||||
events: Vec<String>,
|
||||
passing: bool,
|
||||
}
|
||||
impl InteractionWorld for World {
|
||||
fn using_item(&self) -> bool {
|
||||
self.using
|
||||
}
|
||||
fn release_using(&mut self) {
|
||||
self.events.push("release".into());
|
||||
self.using = false;
|
||||
}
|
||||
fn start_attack(&mut self) -> bool {
|
||||
self.events.push("attack".into());
|
||||
if !self.entity {
|
||||
self.destroying = self.dig_on_attack;
|
||||
}
|
||||
false
|
||||
}
|
||||
fn start_use(&mut self) {
|
||||
if self.destroying {
|
||||
return;
|
||||
}
|
||||
self.delay = 4;
|
||||
let entity = self.entity;
|
||||
use_on_target(self, entity);
|
||||
}
|
||||
fn pick(&mut self) {
|
||||
self.events.push("pick".into());
|
||||
}
|
||||
fn use_delay(&self) -> u32 {
|
||||
self.delay
|
||||
}
|
||||
fn continue_attack(&mut self, down: bool) {
|
||||
if self.using {
|
||||
return;
|
||||
}
|
||||
let down = down && !self.entity;
|
||||
self.events.push(format!("continue {down}"));
|
||||
if !down {
|
||||
self.destroying = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TargetUseWorld for World {
|
||||
fn use_entity(&mut self) -> bool {
|
||||
self.events
|
||||
.push(if self.passing { "entity" } else { "use" }.into());
|
||||
if self.passing {
|
||||
false
|
||||
} else {
|
||||
self.using = self.begin_using;
|
||||
true
|
||||
}
|
||||
}
|
||||
fn use_block(&mut self) -> bool {
|
||||
self.events
|
||||
.push(if self.passing { "block" } else { "use" }.into());
|
||||
if self.passing {
|
||||
false
|
||||
} else {
|
||||
self.using = self.begin_using;
|
||||
true
|
||||
}
|
||||
}
|
||||
fn use_item(&mut self) {
|
||||
self.events.push("item".into());
|
||||
self.using = self.begin_using;
|
||||
}
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
let input = std::io::BufReader::new(std::fs::File::open(&args[1])?);
|
||||
let mut out = std::io::BufWriter::new(std::fs::File::create(&args[2])?);
|
||||
for (i, line) in input.lines().enumerate() {
|
||||
let row: Value = serde_json::from_str(&line?)?;
|
||||
let flag = |key: &str| row[key].as_bool().unwrap();
|
||||
let mut world = World {
|
||||
using: flag("using"),
|
||||
destroying: flag("destroying"),
|
||||
entity: flag("entity"),
|
||||
dig_on_attack: flag("dig_on_attack"),
|
||||
begin_using: flag("begin_using"),
|
||||
delay: row["delay"].as_u64().unwrap() as u32,
|
||||
events: vec![],
|
||||
passing: row["passing"].as_bool().unwrap_or(false),
|
||||
};
|
||||
let mut input = InteractionInput::default();
|
||||
for button in row["clicks"].as_array().unwrap() {
|
||||
input.press(match button.as_u64().unwrap() {
|
||||
0 => Button::Attack,
|
||||
1 => Button::Use,
|
||||
_ => Button::Pick,
|
||||
});
|
||||
}
|
||||
input.tick(&mut world, flag("attack_down"), flag("use_down"));
|
||||
writeln!(out, "== {i}")?;
|
||||
for event in world.events {
|
||||
writeln!(out, "{event}")?;
|
||||
}
|
||||
writeln!(
|
||||
out,
|
||||
"state {} {} {}",
|
||||
world.using, world.destroying, world.delay
|
||||
)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -101,6 +101,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
sprinting: false,
|
||||
equipment: Default::default(),
|
||||
health: 20.0,
|
||||
attributes: Vec::new(),
|
||||
living_flags: 0,
|
||||
};
|
||||
loop {
|
||||
world.game_time += 1;
|
||||
|
||||
@@ -206,7 +206,7 @@ fn incremental(
|
||||
sky_light: bool,
|
||||
edits: usize,
|
||||
) {
|
||||
use horizon_client::light::relight;
|
||||
use horizon_client::light::{LightChanges, relight};
|
||||
use std::sync::Arc;
|
||||
let mut world: HashMap<(i32, i32), Arc<Chunk>> = HashMap::new();
|
||||
let inner: Vec<(i32, i32)> = {
|
||||
@@ -285,7 +285,14 @@ fn incremental(
|
||||
if old == state || !tables.differs(old, state) {
|
||||
continue;
|
||||
}
|
||||
relight(&mut world, tables, sky_light, &[(x, y, z)], false);
|
||||
relight(
|
||||
&mut world,
|
||||
tables,
|
||||
sky_light,
|
||||
&[(x, y, z)],
|
||||
false,
|
||||
&mut LightChanges::default(),
|
||||
);
|
||||
for dz in -1..=1 {
|
||||
for dx in -1..=1 {
|
||||
let (kx, kz) = (cx + dx, cz + dz);
|
||||
|
||||
@@ -1024,6 +1024,7 @@ fn main() -> horizon_client::Result<()> {
|
||||
collision: &collision,
|
||||
data: &data,
|
||||
player: player.clone(),
|
||||
nearest_player: player.as_ref().filter(|p| !p.spectator).map(|p| p.position),
|
||||
others: $snapshot,
|
||||
others_grid: $grid,
|
||||
daylight: (world.day_time.rem_euclid(24000)) < 12000,
|
||||
|
||||
@@ -56,10 +56,11 @@ fn main() -> horizon_client::Result<()> {
|
||||
let initial = LIVE.load(Relaxed);
|
||||
let start = Instant::now();
|
||||
let assets = Assets::load(root)?;
|
||||
let render = assets.reload(root)?;
|
||||
let block_ms = start.elapsed().as_secs_f64() * 1000.;
|
||||
let block_retained = LIVE.load(Relaxed) - initial;
|
||||
let start_items = Instant::now();
|
||||
let items = ItemRenderer::load_with_library(root, assets.model_library.clone())?;
|
||||
let items = ItemRenderer::load_with_library(root, render.model_library.clone())?;
|
||||
let item_ms = start_items.elapsed().as_secs_f64() * 1000.;
|
||||
let total_ms = start.elapsed().as_secs_f64() * 1000.;
|
||||
let retained = LIVE.load(Relaxed) - initial;
|
||||
@@ -74,7 +75,7 @@ fn main() -> horizon_client::Result<()> {
|
||||
horizon_core::position::BlockPos::new(0, 0, 0),
|
||||
horizon_core::position::BlockPos::new(-17, 65, 31),
|
||||
] {
|
||||
if let Ok(selected) = assets.model_catalog.collect(id, pos) {
|
||||
if let Ok(selected) = render.model_catalog.collect(id, pos) {
|
||||
for (variant, model) in selected {
|
||||
format!("{variant:?}").hash(&mut hash);
|
||||
model.ambient_occlusion.hash(&mut hash);
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
use horizon_client::player_sync::{PositionSender, teleport_velocity};
|
||||
use horizon_core::geometry::Vec3;
|
||||
use horizon_protocol::packets::play::{PlayerPosition, Serverbound as S};
|
||||
use serde_json::Value;
|
||||
use std::io::{BufRead, Write};
|
||||
|
||||
fn number(value: &Value) -> f64 {
|
||||
f64::from_bits(u64::from_str_radix(value.as_str().unwrap(), 16).unwrap())
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let args: Vec<_> = std::env::args().collect();
|
||||
let input = std::io::BufReader::new(std::fs::File::open(&args[1])?);
|
||||
let mut out = std::io::BufWriter::new(std::fs::File::create(&args[2])?);
|
||||
for line in input.lines() {
|
||||
let row: Value = serde_json::from_str(&line?)?;
|
||||
if row["kind"] == "movement" {
|
||||
let mut sender = PositionSender::default();
|
||||
for op in row["ops"].as_array().unwrap() {
|
||||
let pos = std::array::from_fn(|i| number(&op[i]));
|
||||
let rot = (number(&op[3]) as f32, number(&op[4]) as f32);
|
||||
if let Some(packet) =
|
||||
sender.update(pos, rot, op[5].as_bool().unwrap(), op[6].as_bool().unwrap())
|
||||
{
|
||||
let name = match packet {
|
||||
S::MovePlayerPos(_) => "pos",
|
||||
S::MovePlayerPosRot(_) => "posrot",
|
||||
S::MovePlayerRot(_) => "rot",
|
||||
S::MovePlayerStatus(_) => "status",
|
||||
_ => unreachable!(),
|
||||
};
|
||||
write!(out, "{name} ")?;
|
||||
for byte in &packet.encode()[1..] {
|
||||
write!(out, "{byte:02x}")?;
|
||||
}
|
||||
writeln!(out)?;
|
||||
} else {
|
||||
writeln!(out, "-")?;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let vector = |key: &str| {
|
||||
Vec3::new(
|
||||
number(&row[key][0]),
|
||||
number(&row[key][1]),
|
||||
number(&row[key][2]),
|
||||
)
|
||||
};
|
||||
let rotation = |key: &str| (number(&row[key][0]) as f32, number(&row[key][1]) as f32);
|
||||
let old = rotation("old");
|
||||
let new = rotation("new");
|
||||
let delta = vector("delta");
|
||||
let packet = PlayerPosition {
|
||||
teleport: 0,
|
||||
position: [0.0; 3],
|
||||
delta: [delta.x, delta.y, delta.z],
|
||||
yaw: new.0,
|
||||
pitch: new.1,
|
||||
relatives: row["flags"].as_i64().unwrap() as i32,
|
||||
};
|
||||
let v = teleport_velocity(vector("velocity"), old, new, &packet);
|
||||
writeln!(
|
||||
out,
|
||||
"{:016x} {:016x} {:016x}",
|
||||
v.x.to_bits(),
|
||||
v.y.to_bits(),
|
||||
v.z.to_bits()
|
||||
)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -94,12 +94,13 @@ fn main() -> Result<()> {
|
||||
drop(registry);
|
||||
step("registry dropped");
|
||||
let assets = Assets::load(&root)?;
|
||||
let render = assets.reload(&root)?;
|
||||
step("assets");
|
||||
println!(
|
||||
" sprites: {} layers of {}px, {:.0} MB of pixels",
|
||||
assets.texture_layers,
|
||||
assets.sprite_size,
|
||||
assets.pixels.len() as f64 / MB
|
||||
render.texture_layers,
|
||||
render.sprite_size,
|
||||
render.pixels.len() as f64 / MB
|
||||
);
|
||||
// The game decodes gameplay facts once for both tables (BlockFacts::load_pair).
|
||||
let (facts, behaviours) = BlockFacts::load_pair(&root, assets.registry)?;
|
||||
@@ -114,6 +115,7 @@ fn main() -> Result<()> {
|
||||
step("light tables");
|
||||
let tables = MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(&root, assets.registry)?,
|
||||
)?;
|
||||
|
||||
@@ -66,7 +66,6 @@ fn fixture(per_chunk: usize) -> (Vec<Arc<Chunk>>, Entities, Names) {
|
||||
for s in &mut template.sections[..8] {
|
||||
Arc::make_mut(s).blocks = PalettedContainer::new(block_strategy(), 1);
|
||||
}
|
||||
template.heights = Arc::new([64; 256]);
|
||||
for i in 0..256 {
|
||||
let x = i % 16 - 8;
|
||||
let z = i / 16 - 8;
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
//! The region writer on real chunks, without a window: how long a world's
|
||||
//! chunks take to be encoded, compressed and written by `SaveDir`, against
|
||||
//! the same encoding and compression done one chunk after another (what the
|
||||
//! writer thread did alone before it had helpers).
|
||||
//!
|
||||
//! save_bench RESOURCES DIMENSION_DIR [--rounds N]
|
||||
//!
|
||||
//! DIMENSION_DIR is a saved dimension folder (`saves/W/dimensions/minecraft/
|
||||
//! overworld`); its chunks are read once, then each round saves them all into
|
||||
//! a scratch folder with `save_later` + `flush`, and times the one-thread
|
||||
//! baseline. The written chunks are checked byte for byte against the
|
||||
//! baseline's compressed records.
|
||||
use horizon_client::{
|
||||
assets::Assets,
|
||||
biome::Biomes,
|
||||
blocks::BlockFacts,
|
||||
save::{SaveDir, SaveTables, encode_with},
|
||||
};
|
||||
use horizon_core::position::ChunkPos;
|
||||
use horizon_world::{
|
||||
compression::Compression,
|
||||
nbt::Limits,
|
||||
region::{ChunkRecord, RegionFile},
|
||||
};
|
||||
use std::{path::PathBuf, sync::Arc, time::Instant};
|
||||
|
||||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
let usage = "usage: save_bench RESOURCES DIMENSION_DIR [--rounds N]";
|
||||
let root = PathBuf::from(args.first().ok_or(usage)?);
|
||||
let dimension = PathBuf::from(args.get(1).ok_or(usage)?);
|
||||
let rounds: usize = args
|
||||
.iter()
|
||||
.position(|a| a == "--rounds")
|
||||
.and_then(|i| args.get(i + 1))
|
||||
.and_then(|v| v.parse().ok())
|
||||
.unwrap_or(5);
|
||||
|
||||
let assets = Assets::load(&root)?;
|
||||
let facts = BlockFacts::load(&root, assets.registry)?;
|
||||
let biomes = Arc::new(Biomes::load(&root)?);
|
||||
let tables = Arc::new(SaveTables::new(&assets).with_block_entities(&facts));
|
||||
let registry = assets.registry;
|
||||
|
||||
let source = SaveDir::new(dimension.clone());
|
||||
let _ = source.tables.set(tables.clone());
|
||||
let mut chunks = Vec::new();
|
||||
for entry in std::fs::read_dir(dimension.join("region"))? {
|
||||
let path = entry?.path();
|
||||
if path.extension().is_none_or(|e| e != "mca") {
|
||||
continue;
|
||||
}
|
||||
let region = RegionFile::open(&path)?;
|
||||
for (pos, _) in region.chunks() {
|
||||
if let Some(chunk) = source.load(pos.x, pos.z, registry, &biomes) {
|
||||
chunks.push(Arc::new(chunk));
|
||||
}
|
||||
}
|
||||
}
|
||||
chunks.sort_by_key(|c| (c.x, c.z));
|
||||
println!("{} chunks from {}", chunks.len(), dimension.display());
|
||||
|
||||
let scratch = std::env::temp_dir().join(format!("save_bench_{}", std::process::id()));
|
||||
// Encoding and compressing on one thread (what the writer did alone),
|
||||
// then SaveDir's writer with its helpers.
|
||||
let mut times = [Vec::new(), Vec::new(), Vec::new()];
|
||||
let mut written = Vec::new();
|
||||
for round in 0..rounds {
|
||||
let started = Instant::now();
|
||||
let tags: Vec<_> = chunks
|
||||
.iter()
|
||||
.map(|c| encode_with(c, registry, &biomes, Some(&tables), true))
|
||||
.collect();
|
||||
times[0].push(started.elapsed().as_secs_f64());
|
||||
let started = Instant::now();
|
||||
let baseline: Vec<ChunkRecord> = tags
|
||||
.iter()
|
||||
.map(|tag| ChunkRecord::from_nbt(tag, Compression::Zlib, 0, Limits::default()))
|
||||
.collect::<std::io::Result<_>>()?;
|
||||
times[1].push(started.elapsed().as_secs_f64());
|
||||
drop(tags);
|
||||
|
||||
let _ = std::fs::remove_dir_all(&scratch);
|
||||
let save = SaveDir::new(scratch.clone());
|
||||
let _ = save.tables.set(tables.clone());
|
||||
let started = Instant::now();
|
||||
save.save_later(&chunks, registry, &biomes)?;
|
||||
save.flush();
|
||||
times[2].push(started.elapsed().as_secs_f64());
|
||||
drop(save);
|
||||
|
||||
if round == 0 {
|
||||
for (chunk, want) in chunks.iter().zip(&baseline) {
|
||||
let path = scratch.join(format!("region/r.{}.{}.mca", chunk.x >> 5, chunk.z >> 5));
|
||||
let got = RegionFile::open(&path)?
|
||||
.read(ChunkPos::new(chunk.x, chunk.z))?
|
||||
.ok_or("a saved chunk is missing")?;
|
||||
if got.compressed != want.compressed {
|
||||
return Err(format!("chunk {} {} differs", chunk.x, chunk.z).into());
|
||||
}
|
||||
}
|
||||
written = baseline.iter().map(|r| r.compressed.len()).collect();
|
||||
}
|
||||
}
|
||||
let _ = std::fs::remove_dir_all(&scratch);
|
||||
println!(
|
||||
"{} KiB compressed, identical to the one-thread records",
|
||||
written.iter().sum::<usize>() / 1024
|
||||
);
|
||||
let per_chunk = 1000.0 / chunks.len() as f64;
|
||||
let names = [
|
||||
"one thread: encode",
|
||||
"one thread: compress",
|
||||
"SaveDir (encode, compress, write)",
|
||||
];
|
||||
for (name, t) in names.iter().zip(&mut times) {
|
||||
t.sort_by(f64::total_cmp);
|
||||
println!(
|
||||
"{name}: best {:.0} ms, median {:.0} ms of {rounds} ({:.3} ms per chunk at best)",
|
||||
t[0] * 1000.0,
|
||||
t[t.len() / 2] * 1000.0,
|
||||
t[0] * per_chunk
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -40,7 +40,8 @@ fn main() -> Result<()> {
|
||||
return Err("radius must be 1..16".into());
|
||||
}
|
||||
let assets = assets::Assets::load(&resources)?;
|
||||
let world = world::World::test_scene(&assets, radius)?;
|
||||
let render = assets.reload(&resources)?;
|
||||
let world = world::World::test_scene(&assets, &render, radius)?;
|
||||
let binding = collisions::load(&resources, assets.registry)?;
|
||||
let mut scene = collisions::SceneCollisions {
|
||||
world: &world,
|
||||
@@ -50,7 +51,7 @@ fn main() -> Result<()> {
|
||||
fs::write(
|
||||
dir.join("scene.json"),
|
||||
serde_json::to_vec(&serde_json::json!({
|
||||
"radius":radius,"resident_chunks":world.chunks.len(),"model_gallery":assets.model_gallery,
|
||||
"radius":radius,"resident_chunks":world.chunks.len(),"model_gallery":render.model_gallery,
|
||||
}))?,
|
||||
)?;
|
||||
let mut output = std::io::BufWriter::new(fs::File::create(dir.join("rust.txt"))?);
|
||||
|
||||
@@ -243,13 +243,14 @@ fn main() -> Result<()> {
|
||||
let root = PathBuf::from(&args[0]);
|
||||
let dir = PathBuf::from(&args[1]);
|
||||
let assets = Assets::load(&root)?;
|
||||
let mut scene = World::test_scene(&assets, 1)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let mut scene = World::test_scene(&assets, &render, 1)?;
|
||||
let binding = collisions::load(&root, assets.registry)?;
|
||||
let resources = MotionResources::load(&root, &assets)?;
|
||||
fs::write(
|
||||
dir.join("scene.json"),
|
||||
serde_json::to_vec(
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":assets.model_gallery}),
|
||||
&serde_json::json!({"radius":1,"resident_chunks":scene.chunks.len(),"model_gallery":render.model_gallery}),
|
||||
)?,
|
||||
)?;
|
||||
if args[2] == "--describe" {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! the oracle's canonical form (vanilla ARGB colours and packed light coords).
|
||||
#![forbid(unsafe_code)]
|
||||
use horizon_client::{
|
||||
assets::Assets,
|
||||
assets::{Assets, RenderAssets},
|
||||
biome::{BiomeInfo, Biomes, GrassModifier},
|
||||
blocks::BlockFacts,
|
||||
chunk::{Chunk, Light, MIN_Y, index},
|
||||
@@ -48,6 +48,7 @@ fn chunk_index(x: i32, z: i32) -> Result<usize> {
|
||||
fn scene(
|
||||
row: &Value,
|
||||
assets: &Assets,
|
||||
render: &RenderAssets,
|
||||
tables: &MeshTables,
|
||||
biomes: &mut Biomes,
|
||||
pristine: &[BiomeInfo],
|
||||
@@ -127,6 +128,7 @@ fn scene(
|
||||
let mut mesher = Mesher {
|
||||
nether_shading: row["nether"].as_bool().unwrap_or(false),
|
||||
assets,
|
||||
render,
|
||||
tables,
|
||||
biomes: &*biomes,
|
||||
visibility: tables.visibility.clone(),
|
||||
@@ -159,15 +161,8 @@ fn scene(
|
||||
let vertices: Vec<Value> = quad
|
||||
.iter()
|
||||
.map(|v| {
|
||||
json!([
|
||||
v.pos[0],
|
||||
v.pos[1],
|
||||
v.pos[2],
|
||||
v.uv[0],
|
||||
v.uv[1],
|
||||
argb(v.color),
|
||||
light_coords(v.light)
|
||||
])
|
||||
let ([x, y, z], [u, w]) = (v.pos, v.uv());
|
||||
json!([x, y, z, u, w, argb(v.color), light_coords(v.light)])
|
||||
})
|
||||
.collect();
|
||||
quads.push(json!({"layer": layer, "sprite": sprite, "vertices": vertices}));
|
||||
@@ -184,11 +179,12 @@ fn main() -> Result<()> {
|
||||
}
|
||||
let root = PathBuf::from(&args[0]);
|
||||
let assets = Assets::load(&root)?;
|
||||
let render = assets.reload(&root)?;
|
||||
let facts = BlockFacts::load(&root, assets.registry)?;
|
||||
let mut biomes = Biomes::load(&root)?;
|
||||
let visibility = models::load_visibility(&root, assets.registry)?;
|
||||
let tables = MeshTables::new(&assets, &facts, visibility)?;
|
||||
let names: BTreeMap<u32, &str> = assets
|
||||
let tables = MeshTables::new(&assets, &render, &facts, visibility)?;
|
||||
let names: BTreeMap<u32, &str> = render
|
||||
.sprite_layers
|
||||
.iter()
|
||||
.map(|(name, layer)| (*layer, name.as_str()))
|
||||
@@ -222,6 +218,7 @@ fn main() -> Result<()> {
|
||||
let result = scene(
|
||||
&row,
|
||||
&assets,
|
||||
&render,
|
||||
&tables,
|
||||
&mut biomes,
|
||||
&pristine,
|
||||
|
||||
@@ -144,10 +144,12 @@ fn main() -> Result<()> {
|
||||
let hz = flag("--hz", 240.0);
|
||||
|
||||
let assets = Arc::new(Assets::load(&root)?);
|
||||
let render = Arc::new(assets.reload(&root)?);
|
||||
let facts = BlockFacts::load(&root, assets.registry)?;
|
||||
let biomes = Arc::new(Biomes::load(&root)?);
|
||||
let tables = Arc::new(MeshTables::new(
|
||||
&assets,
|
||||
&render,
|
||||
&facts,
|
||||
models::load_visibility(&root, assets.registry)?,
|
||||
)?);
|
||||
@@ -160,6 +162,7 @@ fn main() -> Result<()> {
|
||||
)?);
|
||||
let context = Arc::new(WorkerContext {
|
||||
assets,
|
||||
render: render.clone(),
|
||||
tables,
|
||||
biomes,
|
||||
light,
|
||||
|
||||
@@ -48,11 +48,20 @@ impl TerrainBlockStates for Properties {
|
||||
self.0[id.0 as usize]
|
||||
}
|
||||
}
|
||||
/// The block registry and the facts read from `facts.json` and the block tags:
|
||||
/// everything world generation and collisions need, with none of the block
|
||||
/// models or baked sprites.
|
||||
pub struct Assets {
|
||||
/// Leaked once per process: shared by world generation threads.
|
||||
pub registry: &'static BlockRegistry,
|
||||
pub properties: Properties,
|
||||
pub material_states: [BlockStateId; 6],
|
||||
/// Block names in `#minecraft:blocks_fluid_flow` (fluid flow vectors).
|
||||
pub blocks_fluid_flow: BTreeSet<String>,
|
||||
}
|
||||
/// The block models and their baked sprites, read from the pack at `root` over
|
||||
/// an existing block registry: everything the mesher and renderer need.
|
||||
pub struct RenderAssets {
|
||||
pub sprite_size: u32,
|
||||
pub sprite_minimum_size: u32,
|
||||
pub pixels: Vec<u8>,
|
||||
@@ -67,8 +76,6 @@ pub struct Assets {
|
||||
pub translucent_layers: Vec<bool>,
|
||||
/// Each layer's `MipmapGenerator` settings.
|
||||
pub sprite_mips: Vec<crate::mipmap::Settings>,
|
||||
/// Block names in `#minecraft:blocks_fluid_flow` (fluid flow vectors).
|
||||
pub blocks_fluid_flow: BTreeSet<String>,
|
||||
}
|
||||
fn invalid(message: &str) -> io::Error {
|
||||
io::Error::new(io::ErrorKind::InvalidData, message)
|
||||
@@ -152,33 +159,23 @@ impl Assets {
|
||||
// past vanilla's 16-bit global palette.
|
||||
crate::chunk::set_block_states(registry.len());
|
||||
let registry: &'static BlockRegistry = Box::leak(Box::new(registry));
|
||||
Self::with_models(
|
||||
root,
|
||||
Ok(Self {
|
||||
registry,
|
||||
properties,
|
||||
material_states,
|
||||
blocks_fluid_flow,
|
||||
)
|
||||
})
|
||||
}
|
||||
/// The same blocks with the models and sprites of another resource root
|
||||
/// The models and sprites of another resource root over these blocks
|
||||
/// (resource packs changed): the registry and block facts come from the
|
||||
/// game data, which resource packs do not touch.
|
||||
pub fn reload(&self, root: &Path) -> Result<Self> {
|
||||
Self::with_models(
|
||||
root,
|
||||
self.registry,
|
||||
self.properties.clone(),
|
||||
self.material_states,
|
||||
self.blocks_fluid_flow.clone(),
|
||||
)
|
||||
pub fn reload(&self, root: &Path) -> Result<RenderAssets> {
|
||||
RenderAssets::load(root, self)
|
||||
}
|
||||
fn with_models(
|
||||
root: &Path,
|
||||
registry: &'static BlockRegistry,
|
||||
properties: Properties,
|
||||
material_states: [BlockStateId; 6],
|
||||
blocks_fluid_flow: BTreeSet<String>,
|
||||
) -> Result<Self> {
|
||||
}
|
||||
impl RenderAssets {
|
||||
pub fn load(root: &Path, assets: &Assets) -> Result<Self> {
|
||||
let registry = assets.registry;
|
||||
let mut sprites = crate::sprites::Sprites::default();
|
||||
for name in MATERIALS {
|
||||
sprites.insert(root, &format!("minecraft:block/{name}"))?;
|
||||
@@ -202,9 +199,6 @@ impl Assets {
|
||||
}
|
||||
sprites.finish();
|
||||
Ok(Self {
|
||||
registry,
|
||||
properties,
|
||||
material_states,
|
||||
sprite_size: sprites.size,
|
||||
sprite_minimum_size: sprites.minimum_size,
|
||||
texture_layers: u32::try_from(sprites.count())?,
|
||||
@@ -217,7 +211,6 @@ impl Assets {
|
||||
sprite_layers: sprites.layers,
|
||||
translucent_layers: sprites.translucent,
|
||||
sprite_mips: sprites.mips,
|
||||
blocks_fluid_flow,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::sound_engine::{
|
||||
Sounds, TickContext,
|
||||
};
|
||||
use crate::sound_events::{Sound, SoundRegistry};
|
||||
#[cfg(feature = "audio")]
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
use horizon_core::random::{LegacyRandom, RandomSource};
|
||||
use std::{
|
||||
@@ -134,8 +135,14 @@ fn attach(mixer: &Mutex<Mixer>, channel: ChannelId, samples: Samples, looping: b
|
||||
c.looping |= looping;
|
||||
}
|
||||
}
|
||||
/// The open output stream. A build without the `audio` feature (the server build, which must not
|
||||
/// need libasound) never has one.
|
||||
#[cfg(feature = "audio")]
|
||||
type Stream = cpal::Stream;
|
||||
#[cfg(not(feature = "audio"))]
|
||||
type Stream = std::convert::Infallible;
|
||||
pub struct Audio {
|
||||
_stream: Option<cpal::Stream>,
|
||||
_stream: Option<Stream>,
|
||||
pub engine: SoundEngine,
|
||||
backend: MixerBackend,
|
||||
/// Record `Heard` sounds (the subtitle overlay is listening).
|
||||
@@ -333,6 +340,8 @@ fn distance_gain(linear: Option<f32>, distance: f32) -> f32 {
|
||||
Some(_) => 0.0,
|
||||
}
|
||||
}
|
||||
// Only the output stream mixes; a build without one (no `audio` feature) never does.
|
||||
#[cfg_attr(not(feature = "audio"), allow(dead_code))]
|
||||
fn mix(mixer: &mut Mixer, data: &mut [f32], channels: usize, rate: u32) {
|
||||
data.fill(0.0);
|
||||
let listener = mixer.listener;
|
||||
@@ -415,6 +424,7 @@ fn mix(mixer: &mut Mixer, data: &mut [f32], channels: usize, rate: u32) {
|
||||
/// `HORIZON_NO_AUDIO`, or a virtual screen (`vscreen`), where agents and
|
||||
/// harnesses run the game and must stay off the user's speakers.
|
||||
/// `HORIZON_AUDIO=1` opens the output anyway (testing into a null sink).
|
||||
#[cfg(any(feature = "audio", test))]
|
||||
fn output_disabled(var: impl Fn(&str) -> Option<std::ffi::OsString>) -> Option<String> {
|
||||
if var("HORIZON_NO_AUDIO").is_some() {
|
||||
return Some("audio off: HORIZON_NO_AUDIO is set".into());
|
||||
@@ -430,6 +440,7 @@ fn output_disabled(var: impl Fn(&str) -> Option<std::ffi::OsString>) -> Option<S
|
||||
}
|
||||
/// An output stream on `device` in its default configuration, whatever its
|
||||
/// sample format: the mixer works in f32 and converts.
|
||||
#[cfg(feature = "audio")]
|
||||
fn open_device(
|
||||
device: &cpal::Device,
|
||||
mixer: Arc<Mutex<Mixer>>,
|
||||
@@ -450,6 +461,7 @@ fn open_device(
|
||||
stream.play()?;
|
||||
Ok((stream, config))
|
||||
}
|
||||
#[cfg(feature = "audio")]
|
||||
fn build_stream<T: cpal::SizedSample + cpal::FromSample<f32>>(
|
||||
device: &cpal::Device,
|
||||
config: &cpal::SupportedStreamConfig,
|
||||
@@ -523,7 +535,12 @@ impl Audio {
|
||||
capture: None,
|
||||
}
|
||||
}
|
||||
fn open(mixer: Arc<Mutex<Mixer>>) -> Result<cpal::Stream> {
|
||||
#[cfg(not(feature = "audio"))]
|
||||
fn open(_: Arc<Mutex<Mixer>>) -> Result<Stream> {
|
||||
Err("this build has no sound output (built without the `audio` feature)".into())
|
||||
}
|
||||
#[cfg(feature = "audio")]
|
||||
fn open(mixer: Arc<Mutex<Mixer>>) -> Result<Stream> {
|
||||
if let Some(reason) = output_disabled(|name| std::env::var_os(name)) {
|
||||
return Err(reason.into());
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ pub const COMMANDS: &[Cmd] = &[
|
||||
cmd!("bench", Scripting, "bench SECONDS", "reset frame stats, wait, reply with the summary", "", ["horizon-ctl bench 10"], &[], mcp: false, local: false),
|
||||
cmd!("stats", Scripting, "stats [reset]", "frame-time summary since the last reset", "", ["horizon-ctl stats"], &[], mcp: false, local: false),
|
||||
cmd!("fly", Scripting, "fly X1 Y1 Z1 X2 Y2 Z2 SECONDS [PITCH [raw]]", "fly the camera along a line, then reply with the frame summary",
|
||||
"With raw, the reply also lists every frame time in milliseconds (frame_ms).",
|
||||
"The reply's tick_ms and tick_ms_max are the world's smoothed tick time over the flight (the server thread's when single player runs on one). With raw, the reply also lists every frame time in milliseconds (frame_ms).",
|
||||
["horizon-ctl fly 0 100 0 500 100 0 20"], &[], mcp: false, local: false),
|
||||
];
|
||||
|
||||
|
||||
@@ -215,7 +215,12 @@ impl Session {
|
||||
let deadline = Instant::now() + Duration::from_secs_f64(limit.max(0.0));
|
||||
loop {
|
||||
let status = self.game("status")?;
|
||||
if !status["player"].is_null() && status["pending_chunks"] == 0 {
|
||||
// On a server (single player's server thread too), also the
|
||||
// level around the player.
|
||||
if !status["player"].is_null()
|
||||
&& status["pending_chunks"] == 0
|
||||
&& status["server"]["loaded"] != false
|
||||
{
|
||||
return Ok(status);
|
||||
}
|
||||
if Instant::now() > deadline {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//! (copy-on-write through `Arc::make_mut`).
|
||||
use horizon_core::paletted::{PalettedContainer, Strategy};
|
||||
use horizon_world::registry::BlockStateId;
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
pub const MIN_Y: i32 = -64;
|
||||
pub const HEIGHT: i32 = 384;
|
||||
@@ -45,6 +45,10 @@ impl Light {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
fn column(x: i32, z: i32) -> usize {
|
||||
((z & 15) << 4 | (x & 15)) as usize
|
||||
}
|
||||
#[inline]
|
||||
pub fn index(x: i32, y: i32, z: i32) -> usize {
|
||||
((y & 15) << 8 | (z & 15) << 4 | (x & 15)) as usize
|
||||
}
|
||||
@@ -118,8 +122,10 @@ pub struct Chunk {
|
||||
pub x: i32,
|
||||
pub z: i32,
|
||||
pub sections: Vec<Arc<Section>>,
|
||||
/// Highest non-air, light-blocking-or-fluid Y per column (MOTION_BLOCKING-like), for rain/sky.
|
||||
pub heights: Arc<[i16; 256]>,
|
||||
/// `Heightmap.Types.WORLD_SURFACE` per column (`z << 4 | x`): one above
|
||||
/// the highest non-air block, or `MIN_Y`. Built on the first read; a
|
||||
/// `set` that can move a column's surface drops it.
|
||||
surface: OnceLock<Box<[i16; 256]>>,
|
||||
pub lit: bool,
|
||||
/// Light read from a save with `isLightOn`: no light job is needed.
|
||||
pub light_loaded: bool,
|
||||
@@ -148,7 +154,7 @@ impl Chunk {
|
||||
sections: (0..SECTIONS)
|
||||
.map(|_| Arc::new(Section::default()))
|
||||
.collect(),
|
||||
heights: Arc::new([MIN_Y as i16; 256]),
|
||||
surface: OnceLock::new(),
|
||||
lit: false,
|
||||
light_loaded: false,
|
||||
fresh: false,
|
||||
@@ -190,7 +196,52 @@ impl Chunk {
|
||||
if !(0..SECTIONS as i32).contains(&s) {
|
||||
return v;
|
||||
}
|
||||
Arc::make_mut(&mut self.sections[s as usize]).set(index(x, y, z), v)
|
||||
let previous = Arc::make_mut(&mut self.sections[s as usize]).set(index(x, y, z), v);
|
||||
// `Heightmap.update`: a write two or more below the surface can't
|
||||
// move it. Any other change rebuilds the map on the next read.
|
||||
if previous != v
|
||||
&& let Some(surface) = self.surface.get()
|
||||
&& y >= i32::from(surface[column(x, z)]) - 1
|
||||
{
|
||||
self.surface = OnceLock::new();
|
||||
}
|
||||
previous
|
||||
}
|
||||
/// `getHeight(Heightmap.Types.WORLD_SURFACE, x, z)` (`x`, `z` within the
|
||||
/// chunk): one above the highest block that isn't `air`, or `MIN_Y`.
|
||||
/// Sections must change only through `set` once this has been read.
|
||||
pub fn world_surface(&self, x: i32, z: i32, air: impl Fn(u32) -> bool) -> i32 {
|
||||
let surface = self.surface.get_or_init(|| self.prime_surface(air));
|
||||
i32::from(surface[column(x, z)])
|
||||
}
|
||||
/// `Heightmap.primeHeightmaps` for WORLD_SURFACE: each section from the
|
||||
/// top, skipping those of one air state, until every column is found.
|
||||
fn prime_surface(&self, air: impl Fn(u32) -> bool) -> Box<[i16; 256]> {
|
||||
let mut surface = Box::new([MIN_Y as i16; 256]);
|
||||
let mut found = [false; 256];
|
||||
let mut left = 256;
|
||||
let mut values = [0u32; 4096];
|
||||
for (s, section) in self.sections.iter().enumerate().rev() {
|
||||
if left == 0 {
|
||||
break;
|
||||
}
|
||||
if section.blocks.uniform().is_some_and(&air) {
|
||||
continue;
|
||||
}
|
||||
section.unpack(&mut values);
|
||||
let base = MIN_Y + s as i32 * 16;
|
||||
for i in 0..256 {
|
||||
if found[i] {
|
||||
continue;
|
||||
}
|
||||
if let Some(dy) = (0..16).rev().find(|&dy| !air(values[dy << 8 | i])) {
|
||||
surface[i] = (base + dy as i32 + 1) as i16;
|
||||
found[i] = true;
|
||||
left -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
surface
|
||||
}
|
||||
#[inline]
|
||||
pub fn light(&self, x: i32, y: i32, z: i32) -> u8 {
|
||||
@@ -261,4 +312,50 @@ mod tests {
|
||||
);
|
||||
assert_eq!(Chunk::empty(0, 0).highest(air, |_| unreachable!()), None);
|
||||
}
|
||||
/// The kept WORLD_SURFACE heights match a scan of every column after
|
||||
/// each of a few thousand writes (air, cave air, stone, whole sections).
|
||||
#[test]
|
||||
fn world_surface_follows_writes() {
|
||||
let (air, cave_air, stone) = (0, 7, 1);
|
||||
let is_air = |v: u32| v == air || v == cave_air;
|
||||
let scan = |c: &Chunk, x: i32, z: i32| {
|
||||
(MIN_Y..MIN_Y + HEIGHT)
|
||||
.rev()
|
||||
.find(|&y| !is_air(c.get(x, y, z)))
|
||||
.map_or(MIN_Y, |y| y + 1)
|
||||
};
|
||||
let mut chunk = Chunk::empty(0, 0);
|
||||
assert_eq!(chunk.world_surface(5, 5, is_air), MIN_Y);
|
||||
for y in MIN_Y..MIN_Y + 70 {
|
||||
for i in 0..256 {
|
||||
chunk.set(i & 15, y, i >> 4, stone);
|
||||
}
|
||||
}
|
||||
for i in 0..4096 {
|
||||
Arc::make_mut(&mut chunk.sections[8]).set(i, cave_air);
|
||||
}
|
||||
let mut random = horizon_core::random::LegacyRandom::new(9);
|
||||
use horizon_core::random::RandomSource;
|
||||
for step in 0..4000 {
|
||||
let x = random.next_int_bound(16).unwrap();
|
||||
let z = random.next_int_bound(16).unwrap();
|
||||
let y = MIN_Y + 40 + random.next_int_bound(120).unwrap();
|
||||
let v = [air, cave_air, stone][random.next_int_bound(3).unwrap() as usize];
|
||||
chunk.set(x, y, z, v);
|
||||
if step % 7 == 0 {
|
||||
for i in 0..256 {
|
||||
assert_eq!(
|
||||
chunk.world_surface(i & 15, i >> 4, is_air),
|
||||
scan(&chunk, i & 15, i >> 4)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Out-of-range writes and unchanged states keep the map.
|
||||
let before = chunk.world_surface(3, 3, is_air);
|
||||
chunk.set(3, MIN_Y + HEIGHT, 3, stone);
|
||||
chunk.set(3, before - 1, 3, chunk.get(3, before - 1, 3));
|
||||
assert!(chunk.surface.get().is_some());
|
||||
assert_eq!(chunk.world_surface(3, 3, |_| unreachable!()), before);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,73 +336,8 @@ impl PlayerEffects {
|
||||
pub fn modifiers(&self) -> Vec<(&'static str, &'static str, f64, &'static str)> {
|
||||
let mut out = Vec::new();
|
||||
for e in &self.list {
|
||||
let level = f64::from(e.amplifier + 1);
|
||||
let m = match e.id {
|
||||
"speed" => Some((
|
||||
"minecraft:movement_speed",
|
||||
"minecraft:effect.speed",
|
||||
0.2,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"slowness" => Some((
|
||||
"minecraft:movement_speed",
|
||||
"minecraft:effect.slowness",
|
||||
-0.15,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"haste" => Some((
|
||||
"minecraft:attack_speed",
|
||||
"minecraft:effect.haste",
|
||||
0.1,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"mining_fatigue" => Some((
|
||||
"minecraft:attack_speed",
|
||||
"minecraft:effect.mining_fatigue",
|
||||
-0.1,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"strength" => Some((
|
||||
"minecraft:attack_damage",
|
||||
"minecraft:effect.strength",
|
||||
3.0,
|
||||
"add_value",
|
||||
)),
|
||||
"weakness" => Some((
|
||||
"minecraft:attack_damage",
|
||||
"minecraft:effect.weakness",
|
||||
-4.0,
|
||||
"add_value",
|
||||
)),
|
||||
"jump_boost" => Some((
|
||||
"minecraft:safe_fall_distance",
|
||||
"minecraft:effect.jump_boost",
|
||||
1.0,
|
||||
"add_value",
|
||||
)),
|
||||
"health_boost" => Some((
|
||||
"minecraft:max_health",
|
||||
"minecraft:effect.health_boost",
|
||||
4.0,
|
||||
"add_value",
|
||||
)),
|
||||
"absorption" => Some((
|
||||
"minecraft:max_absorption",
|
||||
"minecraft:effect.absorption",
|
||||
4.0,
|
||||
"add_value",
|
||||
)),
|
||||
"luck" => Some(("minecraft:luck", "minecraft:effect.luck", 1.0, "add_value")),
|
||||
"unluck" => Some((
|
||||
"minecraft:luck",
|
||||
"minecraft:effect.unluck",
|
||||
-1.0,
|
||||
"add_value",
|
||||
)),
|
||||
_ => None,
|
||||
};
|
||||
if let Some((a, id, amount, op)) = m {
|
||||
out.push((a, id, amount * level, op));
|
||||
if let Some((a, id, amount, op)) = effect_modifier(e.id) {
|
||||
out.push((a, id, amount * f64::from(e.amplifier + 1), op));
|
||||
}
|
||||
}
|
||||
out
|
||||
@@ -445,6 +380,76 @@ impl StatusFlags {
|
||||
}
|
||||
}
|
||||
|
||||
/// The attribute modifier an effect adds at amplifier 0
|
||||
/// (`MobEffect.addAttributeModifier`): (attribute, id, amount, operation).
|
||||
/// Each level multiplies the amount (`amplifier + 1`).
|
||||
pub fn effect_modifier(effect: &str) -> Option<(&'static str, &'static str, f64, &'static str)> {
|
||||
match effect {
|
||||
"speed" => Some((
|
||||
"minecraft:movement_speed",
|
||||
"minecraft:effect.speed",
|
||||
0.2,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"slowness" => Some((
|
||||
"minecraft:movement_speed",
|
||||
"minecraft:effect.slowness",
|
||||
-0.15,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"haste" => Some((
|
||||
"minecraft:attack_speed",
|
||||
"minecraft:effect.haste",
|
||||
0.1,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"mining_fatigue" => Some((
|
||||
"minecraft:attack_speed",
|
||||
"minecraft:effect.mining_fatigue",
|
||||
-0.1,
|
||||
"add_multiplied_total",
|
||||
)),
|
||||
"strength" => Some((
|
||||
"minecraft:attack_damage",
|
||||
"minecraft:effect.strength",
|
||||
3.0,
|
||||
"add_value",
|
||||
)),
|
||||
"weakness" => Some((
|
||||
"minecraft:attack_damage",
|
||||
"minecraft:effect.weakness",
|
||||
-4.0,
|
||||
"add_value",
|
||||
)),
|
||||
"jump_boost" => Some((
|
||||
"minecraft:safe_fall_distance",
|
||||
"minecraft:effect.jump_boost",
|
||||
1.0,
|
||||
"add_value",
|
||||
)),
|
||||
"health_boost" => Some((
|
||||
"minecraft:max_health",
|
||||
"minecraft:effect.health_boost",
|
||||
4.0,
|
||||
"add_value",
|
||||
)),
|
||||
"absorption" => Some((
|
||||
"minecraft:max_absorption",
|
||||
"minecraft:effect.absorption",
|
||||
4.0,
|
||||
"add_value",
|
||||
)),
|
||||
"luck" => Some(("minecraft:luck", "minecraft:effect.luck", 1.0, "add_value")),
|
||||
"unluck" => Some((
|
||||
"minecraft:luck",
|
||||
"minecraft:effect.unluck",
|
||||
-1.0,
|
||||
"add_value",
|
||||
)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -602,9 +602,10 @@ mod fire_environment_tests {
|
||||
return;
|
||||
}
|
||||
let assets = crate::assets::Assets::load(&root).unwrap();
|
||||
let render = assets.reload(&root).unwrap();
|
||||
let facts = BlockFacts::load(&root, assets.registry).unwrap();
|
||||
let items = crate::items::Items::load(&root, assets.registry, &facts).unwrap();
|
||||
let mut world = World::test_scene(&assets, 3).unwrap();
|
||||
let mut world = World::test_scene(&assets, &render, 3).unwrap();
|
||||
let at = Vec3::new(20.5, 4.0, 20.5);
|
||||
world
|
||||
.set(
|
||||
|
||||
@@ -840,9 +840,12 @@ pub fn mob_from_nbt(tag: &Tag, types: &HashMap<String, Arc<MobType>>, id: u32) -
|
||||
m.species(),
|
||||
crate::mobs::Species::Slime | crate::mobs::Species::MagmaCube
|
||||
) {
|
||||
let health = m.health;
|
||||
// AbstractCubeMob.readAdditionalSaveData: the size's attributes, then
|
||||
// the saved health, the max health when there is none.
|
||||
crate::mobs::cube::set_size(&mut m, number(tag.get("Size")).unwrap_or(0) as i32 + 1);
|
||||
m.health = health;
|
||||
if let Some(h) = float(tag.get("Health")) {
|
||||
m.health = h as f32;
|
||||
}
|
||||
m.extra.flag2 = flag(tag, "wasOnGround");
|
||||
}
|
||||
// Zombie, Piglin and Zoglin.readAdditionalSaveData: IsBaby (the baby
|
||||
|
||||
@@ -32,6 +32,7 @@ pub struct FogData {
|
||||
}
|
||||
|
||||
/// Per-biome water fog end multipliers (`visual/water_fog_end_distance`).
|
||||
#[derive(Default)]
|
||||
pub struct FogTables {
|
||||
water_fog_end: Vec<f32>,
|
||||
}
|
||||
|
||||
+1120
-444
File diff suppressed because it is too large
Load Diff
@@ -106,7 +106,7 @@ impl adv::World for View<'_, '_> {
|
||||
.map(|c| {
|
||||
self.0
|
||||
.res
|
||||
.biomes
|
||||
.biomes()
|
||||
.get(c.biome(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone()
|
||||
@@ -118,7 +118,7 @@ impl adv::World for View<'_, '_> {
|
||||
}
|
||||
fn block(&self, p: [i32; 3]) -> (String, BTreeMap<String, String>) {
|
||||
let state = self.0.world.block(p[0], p[1], p[2]);
|
||||
let name = self.0.res.facts.get(state).name.to_string();
|
||||
let name = self.0.res.facts().get(state).name.to_string();
|
||||
let props = self
|
||||
.0
|
||||
.pack
|
||||
@@ -138,7 +138,7 @@ impl adv::World for View<'_, '_> {
|
||||
match self
|
||||
.0
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.0.world.block(p[0], p[1], p[2]))
|
||||
.fluid
|
||||
{
|
||||
@@ -152,7 +152,7 @@ impl adv::World for View<'_, '_> {
|
||||
!self
|
||||
.0
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.0.world.block(p[0], y, p[2]))
|
||||
.full_collision
|
||||
})
|
||||
@@ -165,19 +165,19 @@ impl adv::World for View<'_, '_> {
|
||||
(1..=5).any(|d| {
|
||||
self.0
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.0.world.block(p[0], p[1] - d, p[2]))
|
||||
.name
|
||||
.ends_with("campfire")
|
||||
})
|
||||
}
|
||||
fn in_tag(&self, registry: &str, tag: &str, id: &str) -> bool {
|
||||
let items = &self.0.res.items;
|
||||
let items = &self.0.res.items();
|
||||
match registry {
|
||||
"item" => items.item_tags.get(tag).is_some_and(|t| t.contains(id)),
|
||||
"block" => items.block_tags.get(tag).is_some_and(|t| t.contains(id)),
|
||||
"entity_type" => self.0.res.mob_data.entity_has(tag, id),
|
||||
"worldgen/biome" => self.0.res.mob_data.biome_has(tag, id),
|
||||
"entity_type" => self.0.res.mob_data().entity_has(tag, id),
|
||||
"worldgen/biome" => self.0.res.mob_data().biome_has(tag, id),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -408,6 +408,9 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if hits.is_empty() {
|
||||
return;
|
||||
}
|
||||
let date = now_text();
|
||||
for (ai, ci) in hits {
|
||||
let a = &tree.list[ai];
|
||||
@@ -454,17 +457,17 @@ impl Game<'_> {
|
||||
.rewards
|
||||
.recipes
|
||||
.iter()
|
||||
.filter(|r| self.res.stations.recipe_index.contains(r))
|
||||
.filter(|r| self.res.stations().recipe_index.contains(r))
|
||||
.cloned()
|
||||
.collect();
|
||||
let (_, unlocked) = self
|
||||
.level
|
||||
.recipe_book
|
||||
.add_recipes(&self.res.stations.recipe_index, &rewards);
|
||||
.add_recipes(&self.res.stations().recipe_index, &rewards);
|
||||
for table in &a.rewards.loot {
|
||||
let items = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(table, false, None, &mut self.world.random);
|
||||
for s in items {
|
||||
if let Some(rest) = self.give(s)
|
||||
@@ -497,10 +500,13 @@ impl Game<'_> {
|
||||
// PlayerList.broadcastSystemMessage: everyone hears of a
|
||||
// network player's advancement.
|
||||
match self.lan_acting_name.clone() {
|
||||
Some(player) => self
|
||||
.adv
|
||||
.announced
|
||||
.push(Text::translate(key, &[Text::literal(&player), name])),
|
||||
// Player.getDisplayName.
|
||||
Some(_) => {
|
||||
let player = self.target_name(super::commands::Target::Player);
|
||||
self.adv
|
||||
.announced
|
||||
.push(Text::translate(key, &[player, name]));
|
||||
}
|
||||
None => self.system_message(Text::translate(
|
||||
key,
|
||||
&[Text::literal(super::chat::PLAYER_NAME), name],
|
||||
@@ -549,7 +555,7 @@ impl Game<'_> {
|
||||
.filter_map(|s| s.as_ref())
|
||||
.filter(|s| {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.get(&s.item)
|
||||
.is_some_and(|i| s.count >= i.max_stack)
|
||||
})
|
||||
@@ -790,11 +796,11 @@ impl Game<'_> {
|
||||
if let Some((station, item)) = recipe {
|
||||
// RecipeToast: black description under a purple title, the
|
||||
// station at 0.6 scale in the corner over the cycling result.
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite(atlas, "gui/sprites/toast/recipe", x, 0.0);
|
||||
let title = self.translate("recipe.toast.title", "New Recipe(s) Unlocked!");
|
||||
let description = self.translate("recipe.toast.description", "Check your recipe book");
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.text(atlas, &title, x + 30.0, 7.0, 0xFF50_0050, false);
|
||||
batch.text(atlas, &description, x + 30.0, 18.0, 0xFF00_0000, false);
|
||||
let start = batch.vertices.len();
|
||||
@@ -803,7 +809,7 @@ impl Game<'_> {
|
||||
self.draw_item_model(batch, &item, x + 8.0, 8.0);
|
||||
return;
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite(atlas, "gui/sprites/toast/advancement", x, 0.0);
|
||||
let (key, color) = match frame {
|
||||
Frame::Task => ("advancements.toast.task", 0xFF00_FFFF),
|
||||
@@ -832,18 +838,25 @@ pub(super) fn adv_name(a: &adv::Advancement) -> Text {
|
||||
Frame::Challenge => text::DARK_PURPLE,
|
||||
_ => text::GREEN,
|
||||
};
|
||||
let tooltip = text_of(&d.title)
|
||||
.with_color(color)
|
||||
// Advancement.decorateName: the title in the frame's colour (styles
|
||||
// merged into it), a new line and the description.
|
||||
let coloured = text_of(&d.title).with_color(color);
|
||||
let mut component = coloured.component();
|
||||
if let Some(o) = component.as_object_mut() {
|
||||
o.insert(
|
||||
"extra".into(),
|
||||
serde_json::json!(["\n", text_of(&d.description).component()]),
|
||||
);
|
||||
}
|
||||
let tooltip = coloured
|
||||
.append("\n")
|
||||
.append(text_of(&d.description));
|
||||
.append(text_of(&d.description))
|
||||
.with_component(component);
|
||||
let title = text_of(&d.title).with_style(&Style {
|
||||
hover: Some(Box::new(tooltip)),
|
||||
..Style::default()
|
||||
});
|
||||
Text::literal("[")
|
||||
.append(title)
|
||||
.append("]")
|
||||
.with_color(color)
|
||||
Text::translate("chat.square_brackets", &[title]).with_color(color)
|
||||
}
|
||||
impl Game<'_> {
|
||||
/// `AdvancementCommands.Action.GRANT` on one advancement (or one of
|
||||
|
||||
@@ -269,7 +269,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `AdvancementWidget`'s title lines, description lines and width.
|
||||
fn adv_widget_text(&self, i: usize) -> (Vec<Text>, Vec<Text>, f32) {
|
||||
let font = &self.atlas.font;
|
||||
let font = &self.gui.atlas.font;
|
||||
let a = &self.adv.tree.list[i];
|
||||
let Some(d) = &a.display else {
|
||||
return (Vec::new(), Vec::new(), 0.0);
|
||||
@@ -332,7 +332,7 @@ impl Game<'_> {
|
||||
let (sx, sy) = self.adv_ui.scroll.unwrap_or_default();
|
||||
let (sx, sy) = (sx.floor() as i32, sy.floor() as i32);
|
||||
self.adv_tick_hover(&view, sx, sy, left, top);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
|
||||
let title = Text::translate("gui.advancements", &[]);
|
||||
let tw = atlas.font.width_text(&title);
|
||||
@@ -444,7 +444,7 @@ impl Game<'_> {
|
||||
}
|
||||
let (x, y) = pos(i);
|
||||
let (x, y) = ((ox + x) as f32, (oy + y) as f32);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite_scaled(
|
||||
atlas,
|
||||
frame_sprite(d.frame, done),
|
||||
@@ -461,7 +461,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
// The window, tabs and title.
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite_region(
|
||||
atlas,
|
||||
"gui/advancements/window",
|
||||
@@ -475,7 +475,7 @@ impl Game<'_> {
|
||||
let (x, y) = tab_pos(ty, i);
|
||||
let sprite = tab_sprite(ty, i, ty.3, Some(t) == tab);
|
||||
batch.sprite_scaled(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
&sprite,
|
||||
left + x,
|
||||
top + y,
|
||||
@@ -494,7 +494,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let title = tab.and_then(|t| tree.list[t].display.as_ref()).map_or_else(
|
||||
|| Text::translate("gui.advancements", &[]),
|
||||
|d| text_of(&d.title),
|
||||
@@ -509,7 +509,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
// Done.
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (bx, by) = ((w / 2.0 - 100.0).floor(), h - FOOTER + 6.0);
|
||||
let hover = ui::hovered(self.cursor, bx, by, 200.0, 20.0);
|
||||
ui::button(
|
||||
@@ -532,7 +532,7 @@ impl Game<'_> {
|
||||
let (cx, cy) = self.cursor;
|
||||
if cx > x && cx < x + ty.1 && cy > y && cy < y + ty.2 {
|
||||
if let Some(d) = &tree.list[t].display {
|
||||
ui::tooltip(batch, &self.atlas, &[text_of(&d.title)], self.cursor);
|
||||
ui::tooltip(batch, &self.gui.atlas, &[text_of(&d.title)], self.cursor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -616,7 +616,7 @@ impl Game<'_> {
|
||||
],
|
||||
)
|
||||
});
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let progress_w = progress.as_ref().map_or(0.0, |t| atlas.font.width_text(t)) as i32;
|
||||
let top_side = title_bottom + desc_h >= INSIDE_H;
|
||||
let amount = if a.criteria.is_empty() || total == 0 {
|
||||
|
||||
@@ -325,7 +325,7 @@ impl Game<'_> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let mut v = json!({
|
||||
"pos": pos,
|
||||
"block": &*self.res.facts.get(state).name,
|
||||
"block": &*self.res.facts().get(state).name,
|
||||
"state": self.state_string(state),
|
||||
"loaded": self.world.chunks.contains_key(&(pos[0] >> 4, pos[2] >> 4)),
|
||||
});
|
||||
@@ -477,6 +477,8 @@ impl Game<'_> {
|
||||
"sleeping": self.sleeping,
|
||||
// The item in use: its slot and for how many ticks.
|
||||
"using": self.using.map(|(slot, ticks)| json!({ "slot": slot, "ticks": ticks })),
|
||||
// The arm swings started (LivingEntity.swing).
|
||||
"swings": self.swings_started,
|
||||
"time": { "day_time": self.world.day_time, "day": self.world.day_time.div_euclid(24000), "time_of_day": self.world.day_time.rem_euclid(24000) },
|
||||
"weather": { "raining": self.world.weather.raining, "thundering": self.world.weather.thundering },
|
||||
"paused": self.pause,
|
||||
@@ -579,7 +581,7 @@ impl Game<'_> {
|
||||
push(
|
||||
[m.position.x, m.position.y, m.position.z],
|
||||
m.kind.id.as_ref(),
|
||||
json!({ "id": m.id, "kind": "mob", "health": m.health, "baby": m.is_baby() }),
|
||||
json!({ "id": m.id, "kind": "mob", "health": m.health, "baby": m.is_baby(), "hurt_time": m.hurt_time }),
|
||||
);
|
||||
}
|
||||
for item in &self.dropped {
|
||||
@@ -677,17 +679,25 @@ impl Game<'_> {
|
||||
|
||||
/// Whether a block stops movement, for the path finder.
|
||||
fn blocks_motion(&self, pos: [i32; 3]) -> bool {
|
||||
let f = self.res.facts.get(self.world.block(pos[0], pos[1], pos[2]));
|
||||
let f = self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1], pos[2]));
|
||||
f.full_collision || f.legacy_solid
|
||||
}
|
||||
fn walkable(&self, n: Node) -> bool {
|
||||
let below = self.world.block(n[0], n[1] - 1, n[2]);
|
||||
let lava = |p: [i32; 3]| {
|
||||
&*self.res.facts.get(self.world.block(p[0], p[1], p[2])).name == "minecraft:lava"
|
||||
&*self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
== "minecraft:lava"
|
||||
};
|
||||
self.world.chunks.contains_key(&(n[0] >> 4, n[2] >> 4))
|
||||
&& (self.blocks_motion([n[0], n[1] - 1, n[2]])
|
||||
|| self.res.facts.get(below).fluid != horizon_client::blocks::Fluid::None)
|
||||
|| self.res.facts().get(below).fluid != horizon_client::blocks::Fluid::None)
|
||||
&& !self.blocks_motion(n)
|
||||
&& !self.blocks_motion([n[0], n[1] + 1, n[2]])
|
||||
&& !lava(n)
|
||||
@@ -748,7 +758,11 @@ impl Game<'_> {
|
||||
if !clear || !self.walkable(m) {
|
||||
continue;
|
||||
}
|
||||
let water = self.res.facts.get(self.world.block(m[0], m[1], m[2])).fluid
|
||||
let water = self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(m[0], m[1], m[2]))
|
||||
.fluid
|
||||
!= horizon_client::blocks::Fluid::None;
|
||||
let step = 10 + if dy != 0 { 5 } else { 0 } + if water { 30 } else { 0 };
|
||||
let c = base + step;
|
||||
@@ -958,10 +972,10 @@ impl Game<'_> {
|
||||
for z in lo[2]..=hi[2] {
|
||||
for x in lo[0]..=hi[0] {
|
||||
let state = self.world.block(x, y, z);
|
||||
if self.res.facts.is_air(state) {
|
||||
if self.res.facts().is_air(state) {
|
||||
continue;
|
||||
}
|
||||
let name = self.res.facts.get(state).name.to_string();
|
||||
let name = self.res.facts().get(state).name.to_string();
|
||||
*census.entry(name).or_insert(0) += 1;
|
||||
list.push(json!([x, y, z, self.state_string(state)]));
|
||||
}
|
||||
@@ -1013,7 +1027,7 @@ impl Game<'_> {
|
||||
for z in c[2] - radius..=c[2] + radius {
|
||||
for x in c[0] - radius..=c[0] + radius {
|
||||
let state = self.world.block(x, y, z);
|
||||
if *self.res.facts.get(state).name == *want {
|
||||
if *self.res.facts().get(state).name == *want {
|
||||
let d = dist(eye, [x, y, z].map(|v| f64::from(v) + 0.5));
|
||||
found.push((d, [x, y, z]));
|
||||
}
|
||||
@@ -1221,7 +1235,7 @@ impl Game<'_> {
|
||||
self.playing()?;
|
||||
let pos = a.block_pos(0)?;
|
||||
let before = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if self.res.facts.is_air(before) {
|
||||
if self.res.facts().is_air(before) {
|
||||
return Err(format!("there is no block at {pos:?}").into());
|
||||
}
|
||||
self.aim_block(pos, None)?;
|
||||
@@ -1250,24 +1264,24 @@ impl Game<'_> {
|
||||
.ok_or("nothing in hand to place; select an item")?;
|
||||
let held = held.item.clone();
|
||||
let before = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if !self.res.facts.get(before).replaceable && !self.res.facts.is_air(before) {
|
||||
if !self.res.facts().get(before).replaceable && !self.res.facts().is_air(before) {
|
||||
return Err(format!(
|
||||
"{pos:?} holds {}; break it first",
|
||||
self.res.facts.get(before).name
|
||||
self.res.facts().get(before).name
|
||||
)
|
||||
.into());
|
||||
}
|
||||
// A replaceable block there (grass, snow) is clicked itself, as
|
||||
// a player would; otherwise the face of a neighbour touching it.
|
||||
let mut aimed = !self.res.facts.is_air(before)
|
||||
&& !self.res.facts.get(before).outline.is_empty()
|
||||
let mut aimed = !self.res.facts().is_air(before)
|
||||
&& !self.res.facts().get(before).outline.is_empty()
|
||||
&& self.aim_block(pos, None).is_ok();
|
||||
for (_, d) in FACES.iter().filter(|_| !aimed) {
|
||||
let d = *d;
|
||||
let support = add(pos, d);
|
||||
let state = self.world.block(support[0], support[1], support[2]);
|
||||
let f = self.res.facts.get(state);
|
||||
if self.res.facts.is_air(state)
|
||||
let f = self.res.facts().get(state);
|
||||
if self.res.facts().is_air(state)
|
||||
|| f.replaceable
|
||||
|| f.fluid != horizon_client::blocks::Fluid::None && !f.waterlogged
|
||||
{
|
||||
@@ -1534,6 +1548,13 @@ impl Game<'_> {
|
||||
return Err("command TEXT".into());
|
||||
}
|
||||
let command = format!("/{text}");
|
||||
// Single player's console is its server thread's.
|
||||
if let Some(server) = &self.integrated {
|
||||
let chat = server
|
||||
.call(move |g| g.owner_console_command(&command))
|
||||
.ok_or("the integrated server stopped")?;
|
||||
return ok(json!({ "ok": true, "chat": chat }));
|
||||
}
|
||||
if self.remote.is_some() {
|
||||
self.send_chat(&command);
|
||||
return ok(json!({ "ok": true }));
|
||||
@@ -1933,7 +1954,10 @@ impl Game<'_> {
|
||||
// Step up onto the next block, or out of water.
|
||||
let in_water = {
|
||||
let b = p.map(|v| v.floor() as i32);
|
||||
self.res.facts.get(self.world.block(b[0], b[1], b[2])).fluid
|
||||
self.res
|
||||
.facts()
|
||||
.get(self.world.block(b[0], b[1], b[2]))
|
||||
.fluid
|
||||
!= horizon_client::blocks::Fluid::None
|
||||
};
|
||||
if aim[1] > p[1] + 0.5 && horizontal(p, aim) < 1.6 && on_ground {
|
||||
|
||||
@@ -29,7 +29,11 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let carried = self.mobs[i].extra.ints[1];
|
||||
let max = self.res.items.get(&held).map_or(64, |i| i.max_stack as i32);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&held)
|
||||
.map_or(64, |i| i.max_stack as i32);
|
||||
// GoToWantedItem / wantsToPickUp: the same item within 32.
|
||||
let wanted = if griefing && carried < max && self.mobs[i].extra.ints[3] <= 0 {
|
||||
self.dropped
|
||||
|
||||
@@ -111,7 +111,12 @@ impl Game<'_> {
|
||||
let Some(item) = item else {
|
||||
continue;
|
||||
};
|
||||
let Some(asset) = self.res.items.get(item).and_then(|i| i.equip_asset.clone()) else {
|
||||
let Some(asset) = self
|
||||
.res
|
||||
.items()
|
||||
.get(item)
|
||||
.and_then(|i| i.equip_asset.clone())
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let kind = if layer == "leggings" {
|
||||
@@ -124,7 +129,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let (Some(r), Some(part)) = (
|
||||
self.atlas.sprites.get(texture.as_str()),
|
||||
self.gui.atlas.sprites.get(texture.as_str()),
|
||||
assets.player.get(layer),
|
||||
) else {
|
||||
continue;
|
||||
@@ -144,7 +149,7 @@ impl Game<'_> {
|
||||
// BlockPlaceContext: a replaceable clicked block is replaced.
|
||||
let clicked = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]));
|
||||
let pos = if clicked.replaceable {
|
||||
hit.pos
|
||||
@@ -230,7 +235,7 @@ impl Game<'_> {
|
||||
fn equipment_slot(&self, stack: &ItemStack) -> usize {
|
||||
match self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.and_then(|i| i.equip_slot.as_deref())
|
||||
{
|
||||
@@ -377,9 +382,14 @@ impl Game<'_> {
|
||||
subject: None,
|
||||
};
|
||||
let mut dead = Vec::new();
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
for (i, a) in self.armor_stands.iter_mut().enumerate() {
|
||||
if !ticking(a.position.x.floor() as i32, a.position.z.floor() as i32) {
|
||||
continue;
|
||||
}
|
||||
a.tick(&mut scene);
|
||||
if !a.environment_tick(&self.world, &self.res.facts, self.pack.assets.registry) {
|
||||
if !a.environment_tick(&self.world, self.res.facts(), self.pack.assets.registry) {
|
||||
dead.push(i);
|
||||
}
|
||||
}
|
||||
@@ -403,7 +413,7 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let assets = &self.armor_stand_assets;
|
||||
let sprites = &self.atlas.sprites;
|
||||
let sprites = &self.gui.atlas.sprites;
|
||||
let uv_of = |name: &str| sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
let Some(wood) = uv_of("entity/armorstand/armorstand") else {
|
||||
return;
|
||||
@@ -516,7 +526,7 @@ impl Game<'_> {
|
||||
};
|
||||
let Some(asset) = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.and_then(|i| i.equip_asset.clone())
|
||||
else {
|
||||
@@ -568,7 +578,7 @@ impl Game<'_> {
|
||||
/// `Equippable.swapWithEquipmentSlot`: right-clicking armor swaps it into
|
||||
/// its slot (the worn piece comes back to the hand).
|
||||
pub(super) fn equip_from_hand(&mut self, stack: &ItemStack) -> bool {
|
||||
let Some(info) = self.res.items.get(&stack.item) else {
|
||||
let Some(info) = self.res.items().get(&stack.item) else {
|
||||
return false;
|
||||
};
|
||||
let index = match info.equip_slot.as_deref() {
|
||||
@@ -699,7 +709,7 @@ impl Game<'_> {
|
||||
&serde_json::Value::Null,
|
||||
false,
|
||||
pose,
|
||||
&self.atlas.sprites,
|
||||
&self.gui.atlas.sprites,
|
||||
&self.item_host(),
|
||||
&mut sink,
|
||||
);
|
||||
@@ -709,7 +719,7 @@ impl Game<'_> {
|
||||
if let Some(stack) = &a.equipment[5]
|
||||
&& self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.is_none_or(|i| i.equip_asset.is_none())
|
||||
&& let Some(head) = part_matrix(model, base, poses, "head", 0.0)
|
||||
|
||||
@@ -71,8 +71,10 @@ impl Game<'_> {
|
||||
}
|
||||
/// Called every frame while the title is up.
|
||||
pub(super) fn update_backdrop(&mut self) -> Result<()> {
|
||||
let wanted = self.title.is_some()
|
||||
let wanted = self.pending_entry.is_none()
|
||||
&& self.title.is_some()
|
||||
&& horizon_client::ui_theme::horizon()
|
||||
&& self.world_renderer_ready
|
||||
&& self.renderer.is_some()
|
||||
&& self.options.frames.is_none();
|
||||
if !wanted {
|
||||
@@ -127,6 +129,10 @@ impl Game<'_> {
|
||||
.is_some_and(|r| r.section_count() > 40)
|
||||
{
|
||||
self.backdrop.ready = Some(Instant::now());
|
||||
log::info!(
|
||||
"Horizon: title backdrop ready; world rest ready: {}",
|
||||
self.res.rest.get().is_some()
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -139,10 +145,14 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
fn surface_y(&self, x: i32, z: i32) -> Option<i32> {
|
||||
let air = self.res.facts.air;
|
||||
let air = self.res.facts().air;
|
||||
(-60..320).rev().find(|&y| self.world.block(x, y, z) != air)
|
||||
}
|
||||
fn start_backdrop(&mut self) -> Result<()> {
|
||||
log::info!(
|
||||
"Horizon: starting title backdrop after {} ms",
|
||||
self.started.elapsed().as_millis()
|
||||
);
|
||||
let seed = seed();
|
||||
let root = std::env::current_dir()?
|
||||
.join("saves")
|
||||
@@ -155,7 +165,7 @@ impl Game<'_> {
|
||||
VanillaTerrain::new(
|
||||
&self.options.resources.join("worldgen"),
|
||||
pack.assets.registry,
|
||||
&res.biomes,
|
||||
res.biomes(),
|
||||
seed,
|
||||
)
|
||||
.map_err(|e| format!("title backdrop: {e}"))?,
|
||||
@@ -165,10 +175,10 @@ impl Game<'_> {
|
||||
inner: inner.clone(),
|
||||
save: save.clone(),
|
||||
registry: pack.assets.clone(),
|
||||
biomes: res.biomes.clone(),
|
||||
biomes: res.biomes().clone(),
|
||||
}),
|
||||
pack.context.clone(),
|
||||
res.threads.min(6),
|
||||
res.threads().min(6),
|
||||
);
|
||||
streaming.radius = self.settings.render_distance.clamp(4, 10);
|
||||
streaming.biome_blend = self.settings.biome_blend;
|
||||
@@ -179,7 +189,7 @@ impl Game<'_> {
|
||||
streaming.paused = true;
|
||||
self.streaming = streaming;
|
||||
self.save = save;
|
||||
let mut world = World::new(self.res.facts.air, seed);
|
||||
let mut world = World::new(self.res.facts().air, seed);
|
||||
world.day_time = DAY_TIME;
|
||||
world.game_time = 6000;
|
||||
// Light snow: the weather renders as snow in frozen biomes.
|
||||
@@ -237,7 +247,7 @@ impl Game<'_> {
|
||||
}
|
||||
fn stop_backdrop(&mut self) {
|
||||
self.streaming.paused = true;
|
||||
self.world = World::new(self.res.facts.air, 0);
|
||||
self.world = World::new(self.res.facts().air, 0);
|
||||
if let Some(r) = self.renderer.as_mut() {
|
||||
r.clear_sections();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl Game<'_> {
|
||||
else {
|
||||
return Vec::new();
|
||||
};
|
||||
layer_textures(&self.res.stations.banners, &b.layers)
|
||||
layer_textures(&self.res.stations().banners, &b.layers)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -99,11 +99,8 @@ impl Game<'_> {
|
||||
}
|
||||
/// `getHeight(WORLD_SURFACE)`: above the highest non-air block.
|
||||
pub(super) fn world_surface(&self, x: i32, z: i32) -> i32 {
|
||||
let (min, max) = (super::MIN_Y, super::MIN_Y + super::HEIGHT);
|
||||
(min..max)
|
||||
.rev()
|
||||
.find(|&y| !self.res.facts.is_air(self.world.block(x, y, z)))
|
||||
.map_or(min, |y| y + 1)
|
||||
self.world
|
||||
.world_surface(x, z, |id| self.res.facts().is_air(id))
|
||||
}
|
||||
/// `BeaconBlockEntity.tick` of the beacon at `key`.
|
||||
pub(super) fn tick_beacon_at(&mut self, key: (i32, i32, i32)) {
|
||||
@@ -125,7 +122,7 @@ impl Game<'_> {
|
||||
let mut i = 0;
|
||||
while i < 10 && check <= surface {
|
||||
let state = self.world.block(x, check, z);
|
||||
let f = self.res.facts.get(state);
|
||||
let f = self.res.facts().get(state);
|
||||
if let Some(color) = self.beam_color(&f.name) {
|
||||
if b.checking.len() <= 1 {
|
||||
b.checking.push((color, 1));
|
||||
@@ -186,7 +183,7 @@ impl Game<'_> {
|
||||
fn beacon_base(&self, x: i32, y: i32, z: i32) -> i32 {
|
||||
let base = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:beacon_base_blocks");
|
||||
let mut levels = 0;
|
||||
@@ -197,7 +194,7 @@ impl Game<'_> {
|
||||
}
|
||||
let ok = (x - step..=x + step).all(|lx| {
|
||||
(z - step..=z + step).all(|lz| {
|
||||
let name = &self.res.facts.get(self.world.block(lx, ly, lz)).name;
|
||||
let name = &self.res.facts().get(self.world.block(lx, ly, lz)).name;
|
||||
base.is_some_and(|t| t.contains(&**name))
|
||||
})
|
||||
});
|
||||
@@ -378,7 +375,7 @@ impl Game<'_> {
|
||||
let levels = self.beacon_levels();
|
||||
let sel = self.station.as_ref().map_or([None; 2], |s| s.beacon);
|
||||
let paid = self.station.as_ref().is_some_and(|s| s.inputs[0].is_some());
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.fill(
|
||||
atlas,
|
||||
0.0,
|
||||
@@ -399,7 +396,7 @@ impl Game<'_> {
|
||||
("block.minecraft.beacon.secondary", "Secondary Power", 169.0),
|
||||
] {
|
||||
let text = self.translate(key, fallback);
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let w = HudBatch::text_width(atlas, &text);
|
||||
batch.text(
|
||||
atlas,
|
||||
@@ -414,7 +411,7 @@ impl Game<'_> {
|
||||
let x = [20.0, 41.0, 63.0, 86.0, 108.0][i];
|
||||
self.draw_item(batch, &ItemStack::new(item, 1), bx + x, by + 109.0);
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let mut tooltip = None;
|
||||
let button =
|
||||
|batch: &mut HudBatch, x: f32, y: f32, active: bool, selected: bool, icon: &str| {
|
||||
@@ -496,7 +493,7 @@ impl Game<'_> {
|
||||
if let Some(slot) = self.slot_at(batch, self.cursor.0, self.cursor.1) {
|
||||
let (sx, sy) = self.slot_position(slot);
|
||||
batch.fill(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
ox + sx,
|
||||
oy + sy,
|
||||
16.0,
|
||||
@@ -517,7 +514,13 @@ impl Game<'_> {
|
||||
}
|
||||
/// `BeaconRenderer`: each section's rotating solid beam and its glow.
|
||||
pub(super) fn beacon_geometry(&self, camera: glam::DVec3, alpha: f64, out: &mut Vec<Vertex>) {
|
||||
let Some(s) = self.atlas.sprites.get("entity/beacon/beacon_beam").copied() else {
|
||||
let Some(s) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/beacon/beacon_beam")
|
||||
.copied()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let time = (self.world.game_time.rem_euclid(40)) as f32 + alpha as f32;
|
||||
|
||||
@@ -41,7 +41,7 @@ impl HiveHost for GameHive<'_, '_> {
|
||||
if !self
|
||||
.game
|
||||
.res
|
||||
.mob_data
|
||||
.mob_data()
|
||||
.entity_has("minecraft:beehive_inhabitors", &kind)
|
||||
{
|
||||
return None;
|
||||
@@ -72,10 +72,10 @@ impl Game<'_> {
|
||||
/// The hive's honey level and front, from its block state.
|
||||
pub(super) fn hive_state(&self, at: [i32; 3]) -> Option<(Option<i32>, [i32; 2])> {
|
||||
let state = self.world.block(at[0], at[1], at[2]);
|
||||
let name = &self.res.facts.get(state).name;
|
||||
let name = &self.res.facts().get(state).name;
|
||||
if !self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:beehives")
|
||||
.is_some_and(|t| t.contains(&**name))
|
||||
@@ -108,7 +108,7 @@ impl Game<'_> {
|
||||
.iter()
|
||||
.any(|d| {
|
||||
let state = self.world.block(at[0] + d[0], at[1] + d[1], at[2] + d[2]);
|
||||
&*self.res.facts.get(state).name == "minecraft:fire"
|
||||
&*self.res.facts().get(state).name == "minecraft:fire"
|
||||
});
|
||||
let mut host = GameHive { game: self };
|
||||
if fire && !hive.bees.is_empty() {
|
||||
|
||||
@@ -193,7 +193,7 @@ impl Game<'_> {
|
||||
};
|
||||
let raiders = self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.entity_tags
|
||||
.get("minecraft:raiders")
|
||||
@@ -201,7 +201,7 @@ impl Game<'_> {
|
||||
.unwrap_or_default();
|
||||
let frames = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:conduit_effect_block")
|
||||
.cloned()
|
||||
@@ -285,7 +285,7 @@ impl Game<'_> {
|
||||
}
|
||||
Ticker::Conduit => {
|
||||
let world = &self.world;
|
||||
let facts = &self.res.facts;
|
||||
let facts = self.res.facts();
|
||||
let registry = self.pack.assets.registry;
|
||||
let is_water = |p: [i32; 3]| {
|
||||
facts.get(world.block(p[0], p[1], p[2])).fluid
|
||||
@@ -372,7 +372,7 @@ impl Game<'_> {
|
||||
/// pot's saved `sherds` (back, left, right, front).
|
||||
pub(super) fn block_anim(&self, pos: [i32; 3], partial: f32) -> BlockAnim {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let sherds = if &*self.res.facts.get(state).name == "minecraft:decorated_pot" {
|
||||
let sherds = if &*self.res.facts().get(state).name == "minecraft:decorated_pot" {
|
||||
let sherds = self.saved_tag(pos).and_then(|t| t.get("sherds"));
|
||||
["back", "left", "right", "front"].map(|side| match sherds.and_then(|s| s.get(side)) {
|
||||
// An item id, or the item stack the processed templates hold.
|
||||
|
||||
@@ -76,7 +76,7 @@ impl Game<'_> {
|
||||
(0..registry.len())
|
||||
.map(|i| {
|
||||
let state = BlockStateId(i as u32);
|
||||
let name: &str = &self.res.facts.get(state).name;
|
||||
let name: &str = &self.res.facts().get(state).name;
|
||||
match name {
|
||||
"minecraft:hopper"
|
||||
| "minecraft:crafter"
|
||||
@@ -101,27 +101,12 @@ impl Game<'_> {
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
/// `ServerLevel.shouldTickBlocksAt`: chunks within the simulation
|
||||
/// distance plus one (`DistanceManager.inBlockTickingRange`, Chebyshev
|
||||
/// in chunks) of the player or a guest. With nobody there, a dedicated
|
||||
/// server ticks none; the game alone (no player yet, headless fixtures)
|
||||
/// ticks every chunk.
|
||||
/// `ServerLevel.shouldTickBlocksAt` in a block-ticking chunk
|
||||
/// (`LevelChunk.isTicking`, block coordinates), from every player's
|
||||
/// tickets (`update_chunk_tickets`).
|
||||
fn block_ticking_area(&self) -> impl Fn(i32, i32) -> bool + use<> {
|
||||
let d = self.settings.simulation_distance.max(2) + 1;
|
||||
let mut centres: Vec<(i32, i32)> = self.streaming.extra.iter().map(|&(c, _)| c).collect();
|
||||
if let Some(p) = &self.player {
|
||||
centres.push((
|
||||
(p.position.x.floor() as i32) >> 4,
|
||||
(p.position.z.floor() as i32) >> 4,
|
||||
));
|
||||
}
|
||||
let everywhere = centres.is_empty() && self.options.dedicated.is_none();
|
||||
move |x, z| {
|
||||
everywhere
|
||||
|| centres
|
||||
.iter()
|
||||
.any(|&(cx, cz)| ((x >> 4) - cx).abs().max(((z >> 4) - cz).abs()) <= d)
|
||||
}
|
||||
let levels = self.tickets.levels();
|
||||
move |x, z| levels.block_ticking_at(x, z)
|
||||
}
|
||||
/// `AbstractFurnaceBlockEntity.serverTick` of the furnace at `pos`, and
|
||||
/// its block's `lit` following it.
|
||||
@@ -129,7 +114,7 @@ impl Game<'_> {
|
||||
let Some(BlockEntity::Furnace(f)) = self.world.block_entities.get_mut(&pos) else {
|
||||
return Ok(());
|
||||
};
|
||||
let Some(lit) = f.tick(&self.res.recipes, &self.res.items, &self.res.providers) else {
|
||||
let Some(lit) = f.tick(self.res.recipes(), self.res.items(), self.res.providers()) else {
|
||||
return Ok(());
|
||||
};
|
||||
let state = self.world.block(pos.0, pos.1, pos.2);
|
||||
|
||||
@@ -22,7 +22,7 @@ impl Game<'_> {
|
||||
let entity = self.world.block_entities.get(&key)?;
|
||||
let block = &self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(key.0, key.1, key.2))
|
||||
.name;
|
||||
let mut tag = save::encode_block_entity(key, entity, block);
|
||||
@@ -37,7 +37,7 @@ impl Game<'_> {
|
||||
pub(super) fn picked_stack(&self, pos: [i32; 3], include_data: bool) -> Option<ItemStack> {
|
||||
let key = (pos[0], pos[1], pos[2]);
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let facts = self.res.facts.get(state);
|
||||
let facts = self.res.facts().get(state);
|
||||
if &*facts.item == "minecraft:air" {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ impl Game<'_> {
|
||||
format!("{}[{}]", s.name, props.join(","))
|
||||
}
|
||||
fn put_block(&mut self, pos: [i32; 3], state: BlockStateId) -> Result<()> {
|
||||
let name = self.res.facts.get(state).name.clone();
|
||||
let name = self.res.facts().get(state).name.clone();
|
||||
self.world.block_entities.remove(&(pos[0], pos[1], pos[2]));
|
||||
self.level_set(pos, state)?;
|
||||
if let Some(entity) = BlockEntity::for_block(&name) {
|
||||
|
||||
@@ -180,11 +180,11 @@ impl BoatModels {
|
||||
}
|
||||
impl Game<'_> {
|
||||
fn fluid_height(&self, x: i32, y: i32, z: i32) -> Option<(f32, bool)> {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if f.fluid != Fluid::Water {
|
||||
return None;
|
||||
}
|
||||
let above = self.res.facts.get(self.world.block(x, y + 1, z));
|
||||
let above = self.res.facts().get(self.world.block(x, y + 1, z));
|
||||
// FluidState.getHeight: 1 under the same fluid, else amount / 9.
|
||||
let height = if above.fluid == Fluid::Water {
|
||||
1.0
|
||||
@@ -277,7 +277,7 @@ impl Game<'_> {
|
||||
&& f64::from(x + 1) > lo.x
|
||||
&& f64::from(z) < hi.z
|
||||
&& f64::from(z + 1) > lo.z;
|
||||
let f = self.res.facts.get(self.world.block(x, y0, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y0, z));
|
||||
if inside && (f.full_collision || f.legacy_solid) && !f.has_class("LilyPadBlock") {
|
||||
friction += f.friction;
|
||||
count += 1;
|
||||
@@ -443,8 +443,13 @@ impl Game<'_> {
|
||||
}
|
||||
/// Every boat but the ridden one (which ticks with its rider).
|
||||
pub(super) fn tick_boats(&mut self) {
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
for i in 0..self.boats.len() {
|
||||
if Some(self.boats[i].id) == self.riding {
|
||||
let p = self.boats[i].position;
|
||||
if Some(self.boats[i].id) == self.riding
|
||||
|| !ticking(p.x.floor() as i32, p.z.floor() as i32)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let b = self.boats[i].clone();
|
||||
@@ -495,8 +500,8 @@ impl Game<'_> {
|
||||
);
|
||||
let top = b.bounds().max_position().y;
|
||||
let (bx, by, bz) = (x.floor() as i32, top.floor() as i32, z.floor() as i32);
|
||||
let below = self.res.facts.get(self.world.block(bx, by - 1, bz));
|
||||
let here = self.res.facts.get(self.world.block(bx, by, bz));
|
||||
let below = self.res.facts().get(self.world.block(bx, by - 1, bz));
|
||||
let here = self.res.facts().get(self.world.block(bx, by, bz));
|
||||
let target = if below.fluid != Fluid::Water
|
||||
&& !here.full_collision
|
||||
&& (below.full_collision || below.legacy_solid)
|
||||
@@ -723,6 +728,7 @@ impl Game<'_> {
|
||||
};
|
||||
let folder = if b.chest { "chest_boat" } else { "boat" };
|
||||
let Some(uv) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get(&format!("entity/{folder}/{}", b.wood))
|
||||
|
||||
@@ -45,7 +45,7 @@ pub(super) enum BookScreen {
|
||||
}
|
||||
impl Game<'_> {
|
||||
fn book_lines(&self, page: &str) -> Vec<Text> {
|
||||
self.atlas.font.split(&Text::literal(page), 114.0)
|
||||
self.gui.atlas.font.split(&Text::literal(page), 114.0)
|
||||
}
|
||||
/// `WritableBookItem.use` / `WrittenBookItem.use`.
|
||||
pub(super) fn use_book(&mut self, stack: &ItemStack) -> bool {
|
||||
@@ -242,7 +242,7 @@ impl Game<'_> {
|
||||
/// the page (`MultilineTextField.insertText`: line breaks kept, cut to
|
||||
/// the 1024 characters left, rejected when it overflows the 14 lines).
|
||||
fn book_shortcut(&mut self, shortcut: horizon_client::clipboard::EditShortcut) {
|
||||
let font = &self.atlas.font;
|
||||
let font = &self.gui.atlas.font;
|
||||
match self.book.as_mut() {
|
||||
Some(BookScreen::Edit {
|
||||
signing: true,
|
||||
@@ -397,7 +397,7 @@ impl Game<'_> {
|
||||
let key = (pos[0], pos[1], pos[2]);
|
||||
if &*self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1], pos[2]))
|
||||
.name
|
||||
!= "minecraft:lectern"
|
||||
@@ -549,7 +549,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn draw_book(&self, batch: &mut HudBatch) {
|
||||
let Some(book) = &self.book else { return };
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
let (mx, my) = self.cursor;
|
||||
let hover =
|
||||
|
||||
@@ -40,7 +40,7 @@ impl Game<'_> {
|
||||
m.position.z.floor() as i32,
|
||||
);
|
||||
let mut state = self.world.block(x, y, z);
|
||||
if self.res.facts.is_air(state) {
|
||||
if self.res.facts().is_air(state) {
|
||||
state = self.world.block(x, (m.position.y - 0.2).floor() as i32, z);
|
||||
}
|
||||
let Some((sprite, tint)) = self.particle_sprite(state) else {
|
||||
|
||||
@@ -89,17 +89,17 @@ impl Game<'_> {
|
||||
if is_locked {
|
||||
locked = true;
|
||||
if scaling || locking {
|
||||
batch.sprite(&self.atlas, error, ox + 35.0, oy + 31.0);
|
||||
batch.sprite(&self.gui.atlas, error, ox + 35.0, oy + 31.0);
|
||||
}
|
||||
}
|
||||
if scaling && scale >= 4 {
|
||||
locked = true;
|
||||
batch.sprite(&self.atlas, error, ox + 35.0, oy + 31.0);
|
||||
batch.sprite(&self.gui.atlas, error, ox + 35.0, oy + 31.0);
|
||||
}
|
||||
}
|
||||
let sprite = |batch: &mut HudBatch, game: &Self, name: &str, x: f32, y: f32| {
|
||||
batch.sprite(
|
||||
&game.atlas,
|
||||
&game.gui.atlas,
|
||||
&format!("gui/sprites/container/cartography_table/{name}"),
|
||||
ox + x,
|
||||
oy + y,
|
||||
|
||||
@@ -219,12 +219,18 @@ impl Game<'_> {
|
||||
.map(|a| format!("minecraft:{a}"))
|
||||
.collect();
|
||||
let reg = &mut self.ui.registries;
|
||||
let mut items: Vec<String> = self.res.items.order.iter().map(|s| s.to_string()).collect();
|
||||
let mut items: Vec<String> = self
|
||||
.res
|
||||
.items()
|
||||
.order
|
||||
.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
items.sort();
|
||||
reg.items = items;
|
||||
reg.item_tags = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.keys()
|
||||
.map(|k| horizon_client::command::args::normalize(k))
|
||||
@@ -232,7 +238,7 @@ impl Game<'_> {
|
||||
reg.item_tags.sort();
|
||||
reg.block_tags = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.keys()
|
||||
.map(|k| horizon_client::command::args::normalize(k))
|
||||
@@ -259,7 +265,7 @@ impl Game<'_> {
|
||||
.collect();
|
||||
let mut summonable: Vec<String> = self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.keys()
|
||||
.map(|k| horizon_client::command::args::normalize(k))
|
||||
.collect();
|
||||
@@ -405,7 +411,7 @@ impl Game<'_> {
|
||||
.as_ref()
|
||||
.map_or([1280, 720], |r| [r.config.width, r.config.height]);
|
||||
let b = HudBatch::new(size);
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -450,7 +456,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
let heard = self.mods.mods.is_running().then(|| text.plain());
|
||||
self.ui.chat.add(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
text,
|
||||
Some(SYSTEM_INDICATOR),
|
||||
self.ticks,
|
||||
@@ -463,7 +469,7 @@ impl Game<'_> {
|
||||
/// Keys while the chat screen is open.
|
||||
pub(super) fn chat_key(&mut self, event: &KeyEvent) {
|
||||
if let Some(shortcut) = self.edit_shortcut(event) {
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -509,7 +515,7 @@ impl Game<'_> {
|
||||
let Some(mut screen) = self.ui.chat_screen.take() else {
|
||||
return;
|
||||
};
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -541,7 +547,7 @@ impl Game<'_> {
|
||||
range: (usize, usize),
|
||||
list: Vec<(String, Option<String>)>,
|
||||
) {
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -552,7 +558,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Text typed into the chat box (control socket `chat`).
|
||||
pub(super) fn chat_type(&mut self, text: &str) {
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -580,7 +586,7 @@ impl Game<'_> {
|
||||
let heard = self.mods.mods.is_running().then(|| line.plain());
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.gui.atlas, line, None, self.ticks, focused);
|
||||
if let Some(line) = heard {
|
||||
self.mods_chat(&line);
|
||||
}
|
||||
@@ -608,7 +614,7 @@ impl Game<'_> {
|
||||
let height = self.renderer.as_ref().map_or(720.0, |r| {
|
||||
HudBatch::new([r.config.width, r.config.height]).height
|
||||
});
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -621,7 +627,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
match self.ui.chat.click_at(
|
||||
&self.atlas.font,
|
||||
&self.gui.atlas.font,
|
||||
height as i32,
|
||||
cursor.0 as f64,
|
||||
cursor.1 as f64,
|
||||
@@ -647,13 +653,15 @@ impl Game<'_> {
|
||||
if self.ui.hide_gui && !focused {
|
||||
return;
|
||||
}
|
||||
self.ui.chat.draw(batch, &self.atlas, self.ticks, focused);
|
||||
self.ui
|
||||
.chat
|
||||
.draw(batch, &self.gui.atlas, self.ticks, focused);
|
||||
}
|
||||
pub(super) fn draw_chat_screen(&mut self, batch: &mut HudBatch) {
|
||||
let Some(mut screen) = self.ui.chat_screen.take() else {
|
||||
return;
|
||||
};
|
||||
let m = Measure(&self.atlas.font);
|
||||
let m = Measure(&self.gui.atlas.font);
|
||||
let c = Commands {
|
||||
dispatcher: chat_tree(&self.remote, &self.mods),
|
||||
registries: &self.ui.registries,
|
||||
@@ -671,7 +679,7 @@ impl Game<'_> {
|
||||
.chat_opened
|
||||
.map_or(0, |t| t.elapsed().as_millis() as u64);
|
||||
let draws = screen.draw(&m, mouse, blink, background);
|
||||
horizon_client::screen_draw::paint(batch, &self.atlas, &draws);
|
||||
horizon_client::screen_draw::paint(batch, &self.gui.atlas, &draws);
|
||||
self.ui.chat_screen = Some(screen);
|
||||
}
|
||||
/// Advance the overworld clock (ServerClockManager.tick) when
|
||||
@@ -689,6 +697,16 @@ impl Game<'_> {
|
||||
c.partial -= whole;
|
||||
self.world.day_time += whole as i64;
|
||||
}
|
||||
/// `ServerClockInstance.packNetworkState`: the rate players' clients
|
||||
/// advance the overworld clock at, 0 while it is paused (`/time pause`)
|
||||
/// or `advance_time` is off.
|
||||
pub(super) fn network_clock_rate(&self) -> f32 {
|
||||
if self.ui.rules.bool("advance_time") && !self.ui.clock.paused {
|
||||
self.ui.clock.rate
|
||||
} else {
|
||||
0.0
|
||||
}
|
||||
}
|
||||
/// The engine-side rule values (block behaviour and health).
|
||||
pub(super) fn level_rules(&self) -> horizon_world::level::GameRules {
|
||||
let r = &self.ui.rules;
|
||||
@@ -863,11 +881,11 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.atlas, message, None, self.ticks, focused);
|
||||
.add(&self.gui.atlas, message, None, self.ticks, focused);
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
fn chat_debug_fill(&self, batch: &mut HudBatch) {
|
||||
batch.fill(&self.atlas, 0.0, 0.0, 1.0, 1.0, rgba(0, 0, 0, 0));
|
||||
batch.fill(&self.gui.atlas, 0.0, 0.0, 1.0, 1.0, rgba(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
/// `yyyy-MM-dd_HH.mm.ss[_n].png` (Util.getFilenameFormattedDateTime, local time
|
||||
|
||||
@@ -114,7 +114,7 @@ impl Game<'_> {
|
||||
let location = if let Some(c) = p.last_climbable {
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(c.x, c.y, c.z))
|
||||
.name
|
||||
.clone();
|
||||
@@ -127,7 +127,7 @@ impl Game<'_> {
|
||||
_ => "other_climbable",
|
||||
})
|
||||
} else {
|
||||
let f = self.res.facts.get(self.world.block(
|
||||
let f = self.res.facts().get(self.world.block(
|
||||
p.position.x.floor() as i32,
|
||||
(p.position.y + 0.1).floor() as i32,
|
||||
p.position.z.floor() as i32,
|
||||
|
||||
@@ -356,7 +356,7 @@ impl Game<'_> {
|
||||
eyes: false,
|
||||
silent: false,
|
||||
store: None,
|
||||
elsewhere: false,
|
||||
dimension: self.dim,
|
||||
level: None,
|
||||
block: Some(pos),
|
||||
};
|
||||
@@ -459,7 +459,7 @@ impl Game<'_> {
|
||||
self.close_command_block();
|
||||
return;
|
||||
}
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let (w, h) = (batch.width, batch.height);
|
||||
let mid = (w / 2.0).floor();
|
||||
ui::menu_background(batch, atlas, 0.0, 0.0, w, h, true);
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
//! command as the player (Commands.performPrefixedCommand) and records every
|
||||
//! system message it produced, as styled spans, with the results reported to
|
||||
//! the player's `CommandResultCallback`; `tick` advances the game; `settle`
|
||||
//! waits until the terrain around the player is loaded.
|
||||
//! waits until the terrain and entities around the player are loaded;
|
||||
//! `portal` sends the player through the nether portal it stands in.
|
||||
use super::Game;
|
||||
use horizon_client::{Result, text::Text};
|
||||
use serde_json::{Value, json};
|
||||
@@ -40,6 +41,19 @@ pub(super) fn spans(text: &Text) -> Value {
|
||||
}
|
||||
|
||||
impl Game<'_> {
|
||||
/// The player's portal process finished in the nether portal it stands
|
||||
/// in (the oracle's player is not ticked, so neither is the wait).
|
||||
fn harness_portal(&mut self) -> Result<()> {
|
||||
let Some(p) = &self.player else {
|
||||
return Err("command harness: portal without a player".into());
|
||||
};
|
||||
let entry = horizon_core::position::BlockPos::containing(p.position);
|
||||
let block = self.world.block(entry.x, entry.y, entry.z);
|
||||
if &*self.res.facts().get(block).name != "minecraft:nether_portal" {
|
||||
return Err("command harness: the player is not in a nether portal".into());
|
||||
}
|
||||
self.player_through_nether_portal(entry)
|
||||
}
|
||||
/// Load terrain until the player stands in lit chunks.
|
||||
fn harness_settle(&mut self, deadline: Instant) -> Result<()> {
|
||||
loop {
|
||||
@@ -51,6 +65,10 @@ impl Game<'_> {
|
||||
(p.position.z.floor() as i32) >> 4,
|
||||
);
|
||||
if (-1..=1).all(|dz| (-1..=1).all(|dx| self.streaming.is_lit(cx + dx, cz + dz))) {
|
||||
// The oracle's settle also waits for the entities saved
|
||||
// in those chunks (areEntitiesActuallyLoadedAndTicking):
|
||||
// after a dimension change they come back from the save.
|
||||
self.spawn_loaded_entities();
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
@@ -130,6 +148,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
"settle" => self.harness_settle(deadline)?,
|
||||
"portal" => self.harness_portal()?,
|
||||
other => return Err(format!("command harness: unknown op {other}").into()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ pub(super) mod extra;
|
||||
mod items;
|
||||
mod misc;
|
||||
mod place;
|
||||
mod players;
|
||||
mod raid;
|
||||
mod terrain_cmds;
|
||||
mod text_commands;
|
||||
@@ -33,7 +34,11 @@ pub(super) type R<T> = Result<T, CommandError>;
|
||||
/// An entity a selector found.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub(super) enum Target {
|
||||
/// The player in place: the host's, or the guest whose turn it is.
|
||||
Player,
|
||||
/// Another player of a hosted world or server: a guest by connection
|
||||
/// (game/commands/players.rs).
|
||||
Guest(u32),
|
||||
Mob(u32),
|
||||
Item(u32),
|
||||
Orb(usize),
|
||||
@@ -232,9 +237,16 @@ impl Game<'_> {
|
||||
}
|
||||
match &self.player {
|
||||
Some(p) => [p.position.x, p.position.y, p.position.z],
|
||||
None => self.spawn.map_or([0.0, 64.0, 0.0], |s| [s.x, s.y, s.z]),
|
||||
None => self.server_position(),
|
||||
}
|
||||
}
|
||||
/// MinecraftServer.createCommandSourceStack's position: the corner of
|
||||
/// the respawn block (`Vec3.atLowerCornerOf`).
|
||||
pub(super) fn server_position(&self) -> [f64; 3] {
|
||||
self.spawn.map_or([0.0, 64.0, 0.0], |s| {
|
||||
[s.x.floor(), s.y.floor(), s.z.floor()]
|
||||
})
|
||||
}
|
||||
fn source_rotation(&self) -> [f32; 2] {
|
||||
self.command_source
|
||||
.map_or([self.yaw, self.pitch], |s| s.rot)
|
||||
@@ -263,8 +275,8 @@ impl Game<'_> {
|
||||
.ok_or_else(|| err("argument.pos.missing.int", &[]))?;
|
||||
// BlockPos.containing(getPosition)
|
||||
let p = self.resolve_coords(&c).map(|v| v.floor() as i32);
|
||||
let elsewhere = self.command_source.is_some_and(|s| s.elsewhere);
|
||||
if elsewhere || !self.world.chunks.contains_key(&(p[0] >> 4, p[2] >> 4)) {
|
||||
let dimension = self.command_source.map_or(self.dim, |s| s.dimension);
|
||||
if dimension != self.dim || !self.world.chunks.contains_key(&(p[0] >> 4, p[2] >> 4)) {
|
||||
return Err(err("argument.pos.unloaded", &[]));
|
||||
}
|
||||
if p[1] < horizon_client::chunk::MIN_Y
|
||||
@@ -288,6 +300,7 @@ impl Game<'_> {
|
||||
.player
|
||||
.as_ref()
|
||||
.map(|p| [p.position.x, p.position.y, p.position.z]),
|
||||
Target::Guest(conn) => self.command_guest(conn).map(|g| g.position),
|
||||
Target::Mob(id) => self
|
||||
.mobs
|
||||
.iter()
|
||||
@@ -347,7 +360,7 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn target_type(&self, t: Target) -> String {
|
||||
match t {
|
||||
Target::Player => "minecraft:player".into(),
|
||||
Target::Player | Target::Guest(_) => "minecraft:player".into(),
|
||||
Target::Mob(id) => self
|
||||
.mobs
|
||||
.iter()
|
||||
@@ -394,12 +407,19 @@ impl Game<'_> {
|
||||
match t {
|
||||
Target::Player => {
|
||||
let name = self.acting_player_name();
|
||||
if let Some(uuid) = self.lan_acting_uuid {
|
||||
return self.player_text(name, uuid);
|
||||
}
|
||||
match self.score.board.players_team(name) {
|
||||
// PlayerTeam.formatNameForTeam.
|
||||
Some(team) => team.formatted_name(Text::literal(name)),
|
||||
None => Text::literal(name),
|
||||
}
|
||||
}
|
||||
Target::Guest(conn) => match self.command_guest(conn) {
|
||||
Some(g) => self.player_text(&g.name, g.uuid),
|
||||
None => Text::empty(),
|
||||
},
|
||||
Target::Item(id) => {
|
||||
let item = self
|
||||
.dropped
|
||||
@@ -446,11 +466,10 @@ impl Game<'_> {
|
||||
/// EntitySelector.findEntities.
|
||||
pub(super) fn select(&mut self, s: &Selector) -> Vec<Target> {
|
||||
if let Some(name) = &s.player_name {
|
||||
return if name.eq_ignore_ascii_case(PLAYER_NAME) && self.player.is_some() {
|
||||
vec![Target::Player]
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
return self.player_named(name).into_iter().collect();
|
||||
}
|
||||
if let Some(uuid) = s.uuid {
|
||||
return self.target_by_uuid(uuid).into_iter().collect();
|
||||
}
|
||||
let origin = {
|
||||
let p = self.source_position();
|
||||
@@ -464,10 +483,15 @@ impl Game<'_> {
|
||||
match (s.kind, self.command_source) {
|
||||
// @s: the executing entity (none for a server source).
|
||||
('s', Some(source)) => candidates.extend(source.entity),
|
||||
_ if self.player.is_some() => candidates.push(Target::Player),
|
||||
('s', None) => candidates.extend(self.source_entity()),
|
||||
// A guest in place is among the players, in join order.
|
||||
_ if self.player.is_some() && self.lan_acting.is_none() => {
|
||||
candidates.push(Target::Player);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if s.kind != 's' {
|
||||
candidates.extend(self.player_candidates(s));
|
||||
candidates.extend(
|
||||
self.mobs
|
||||
.iter()
|
||||
@@ -511,7 +535,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
if !s.include_entities
|
||||
&& t != Target::Player
|
||||
&& !t.is_player()
|
||||
&& s.types.iter().all(|(w, n)| *n || w != &ty)
|
||||
&& s.kind != 'e'
|
||||
&& s.kind != 'n'
|
||||
@@ -527,16 +551,20 @@ impl Game<'_> {
|
||||
if !passing.contains(&t) {
|
||||
return None;
|
||||
}
|
||||
let player = match t {
|
||||
Target::Player => Some((level, if creative { "creative" } else { "survival" })),
|
||||
Target::Guest(conn) => self.guest_level_and_mode(conn),
|
||||
_ => None,
|
||||
};
|
||||
if let Some((lo, hi)) = s.level
|
||||
&& (t != Target::Player
|
||||
|| lo.is_some_and(|l| level < l)
|
||||
|| hi.is_some_and(|h| level > h))
|
||||
&& player.is_none_or(|(level, _)| {
|
||||
lo.is_some_and(|l| level < l) || hi.is_some_and(|h| level > h)
|
||||
})
|
||||
{
|
||||
return None;
|
||||
}
|
||||
for (mode, neg) in &s.gamemodes {
|
||||
let current = if creative { "creative" } else { "survival" };
|
||||
if t != Target::Player || (current == mode) == *neg {
|
||||
if player.is_none_or(|(_, current)| (current == mode) == *neg) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
@@ -595,12 +623,12 @@ impl Game<'_> {
|
||||
/// EntityArgument.getEntities / getPlayers / getEntity / getPlayer.
|
||||
pub(super) fn entities(&mut self, ctx: &Context, name: &str, players: bool) -> R<Vec<Target>> {
|
||||
let Some(Arg::Entity(s)) = ctx.get(name).cloned() else {
|
||||
return Ok(vec![Target::Player]);
|
||||
return Ok(vec![self.implied_player()]);
|
||||
};
|
||||
let found: Vec<Target> = self
|
||||
.select(&s)
|
||||
.into_iter()
|
||||
.filter(|t| !players || *t == Target::Player)
|
||||
.filter(|t| !players || t.is_player())
|
||||
.collect();
|
||||
if found.is_empty() {
|
||||
return Err(err(
|
||||
@@ -806,63 +834,63 @@ impl Game<'_> {
|
||||
let targets = if ctx.get("target").is_some() {
|
||||
self.entities(ctx, "target", true)?
|
||||
} else {
|
||||
vec![Target::Player]
|
||||
vec![self.implied_player()]
|
||||
};
|
||||
let mut count = 0;
|
||||
for t in targets {
|
||||
if t != Target::Player || !self.set_game_mode(mode) {
|
||||
let mode_name = Text::translate(&format!("gameMode.{}", mode.name()), &[]);
|
||||
// GameModeCommand.logGamemodeChange: the source's own entity.
|
||||
let own = self.source_entity() == Some(t);
|
||||
let told = !own && self.ui.rules.bool("send_command_feedback");
|
||||
let changed = self.for_player(t, |g| {
|
||||
if !g.set_game_mode(mode) {
|
||||
return false;
|
||||
}
|
||||
if told {
|
||||
g.system_message(Text::translate(
|
||||
"gameMode.changed",
|
||||
std::slice::from_ref(&mode_name),
|
||||
));
|
||||
}
|
||||
true
|
||||
});
|
||||
if changed != Some(true) {
|
||||
continue;
|
||||
}
|
||||
count += 1;
|
||||
let mode_name = Text::translate(&format!("gameMode.{}", mode.name()), &[]);
|
||||
// GameModeCommand.logGamemodeChange: the source's own entity.
|
||||
let own = match self.command_source {
|
||||
None => true,
|
||||
Some(s) => s.entity == Some(t),
|
||||
};
|
||||
if own {
|
||||
self.feedback(Text::translate(
|
||||
"commands.gamemode.success.self",
|
||||
&[mode_name],
|
||||
));
|
||||
} else {
|
||||
if self.ui.rules.bool("send_command_feedback") {
|
||||
self.system_message(Text::translate(
|
||||
"gameMode.changed",
|
||||
std::slice::from_ref(&mode_name),
|
||||
));
|
||||
}
|
||||
self.feedback(Text::translate(
|
||||
"commands.gamemode.success.other",
|
||||
&[Text::literal(self.acting_player_name()), mode_name],
|
||||
&[self.target_name(t), mode_name],
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(count)
|
||||
}
|
||||
/// ItemStack.getDisplayName: "[Name]" in the rarity colour.
|
||||
/// ItemStack.getDisplayName of one `item` with no components.
|
||||
pub(super) fn item_display_name(&self, item: &str) -> Text {
|
||||
let rarity = self.item_rarity(item);
|
||||
let color = match rarity.as_str() {
|
||||
"uncommon" => text::YELLOW,
|
||||
"rare" => text::AQUA,
|
||||
"epic" => text::LIGHT_PURPLE,
|
||||
_ => text::WHITE,
|
||||
};
|
||||
Text::literal("[")
|
||||
.append(Text::literal(self.pack.names.item(item)))
|
||||
.append("]")
|
||||
.with_color(color)
|
||||
self.stack_display_name(&ItemStack {
|
||||
item: item.into(),
|
||||
count: 1,
|
||||
damage: 0,
|
||||
extra: None,
|
||||
})
|
||||
}
|
||||
/// `ItemStack.getDisplayName`: the hover name (custom name in italics,
|
||||
/// a written book's title, a potion's effect name...) in brackets, in the
|
||||
/// rarity colour unless the stack is empty.
|
||||
/// a written book's title, a potion's effect name, else the item's
|
||||
/// translated name) in brackets, in the rarity colour and showing the
|
||||
/// stack on hover unless it is empty.
|
||||
pub(super) fn stack_display_name(&self, s: &ItemStack) -> Text {
|
||||
let item = &*s.item;
|
||||
let empty = item == "minecraft:air" || s.count == 0;
|
||||
let custom = s.custom_name();
|
||||
let hover = if let Some(c) = custom {
|
||||
Text::literal(c).italic()
|
||||
Text::literal(c)
|
||||
} else if let Some(title) = s
|
||||
.data()
|
||||
.and_then(|d| d.written.as_ref())
|
||||
@@ -883,9 +911,22 @@ impl Game<'_> {
|
||||
&[],
|
||||
)
|
||||
} else {
|
||||
Text::literal(self.pack.names.item(item))
|
||||
// Item.getDescriptionId: a block item's is the block's.
|
||||
let (namespace, path) = item.split_once(':').unwrap_or(("minecraft", item));
|
||||
let key = format!("item.{namespace}.{path}");
|
||||
let key = if self.pack.names.get(&key).is_some() {
|
||||
key
|
||||
} else {
|
||||
format!("block.{namespace}.{path}")
|
||||
};
|
||||
Text::translate(&key, &[])
|
||||
};
|
||||
let wrapped = Text::translate("chat.square_brackets", &[hover]);
|
||||
// Component.empty().append(getHoverName()), italic for a custom name.
|
||||
let mut name = Text::empty().append(hover);
|
||||
if custom.is_some() {
|
||||
name = name.italic();
|
||||
}
|
||||
let wrapped = Text::translate("chat.square_brackets", &[name]);
|
||||
if empty {
|
||||
return wrapped;
|
||||
}
|
||||
@@ -903,7 +944,14 @@ impl Game<'_> {
|
||||
"epic" => text::LIGHT_PURPLE,
|
||||
_ => text::WHITE,
|
||||
};
|
||||
wrapped.with_color(color)
|
||||
// HoverEvent.ShowItem: the count only when it is not one.
|
||||
let mut shown = serde_json::json!({"action": "show_item", "id": item});
|
||||
if s.count != 1 {
|
||||
shown["count"] = s.count.into();
|
||||
}
|
||||
wrapped
|
||||
.with_color(color)
|
||||
.with_component_fields(vec![("hover_event".into(), shown)])
|
||||
}
|
||||
pub(super) fn item_rarity(&self, item: &str) -> String {
|
||||
static RARITY: std::sync::OnceLock<std::collections::HashMap<String, String>> =
|
||||
@@ -941,7 +989,7 @@ impl Game<'_> {
|
||||
};
|
||||
let count = Self::int(ctx, "count").unwrap_or(1);
|
||||
let targets = self.entities(ctx, "targets", true)?;
|
||||
let max_stack = self.res.items.get(&id).map_or(64, |i| i.max_stack) as i32;
|
||||
let max_stack = self.res.items().get(&id).map_or(64, |i| i.max_stack) as i32;
|
||||
if count > max_stack * 100 {
|
||||
return Err(CommandError::new(Text::translate(
|
||||
"commands.give.failed.toomanyitems",
|
||||
@@ -953,33 +1001,38 @@ impl Game<'_> {
|
||||
}
|
||||
// An air stack is empty: nothing is given (but the message still is).
|
||||
let empty = id == "minecraft:air";
|
||||
for _ in targets.iter().filter(|_| !empty) {
|
||||
let mut remaining = count;
|
||||
while remaining > 0 {
|
||||
let size = remaining.min(max_stack);
|
||||
remaining -= size;
|
||||
let left = self.give(ItemStack {
|
||||
item: id.as_str().into(),
|
||||
count: size as u32,
|
||||
damage,
|
||||
extra: extra.clone(),
|
||||
});
|
||||
if let Some(rest) = left {
|
||||
// Inventory full: drop the rest at the player's feet without pickup delay.
|
||||
let p = self.source_position();
|
||||
self.spawn_item(rest, [p[0], p[1] + 1.32, p[2]], [0.0, 0.0, 0.0], 0);
|
||||
} else {
|
||||
let r = &mut self.world.random;
|
||||
let pitch = ((r.next_float() - r.next_float()) * 0.7 + 1.0) * 2.0;
|
||||
let p = self.source_position();
|
||||
self.audio
|
||||
.play("minecraft:entity.item.pickup", Some(p), 0.2, pitch);
|
||||
for &t in targets.iter().filter(|_| !empty) {
|
||||
self.for_player(t, |g| {
|
||||
let mut remaining = count;
|
||||
while remaining > 0 {
|
||||
let size = remaining.min(max_stack);
|
||||
remaining -= size;
|
||||
let left = g.give(ItemStack {
|
||||
item: id.as_str().into(),
|
||||
count: size as u32,
|
||||
damage,
|
||||
extra: extra.clone(),
|
||||
});
|
||||
// At the player who gets them.
|
||||
let p = g
|
||||
.target_position(Target::Player)
|
||||
.unwrap_or(g.source_position());
|
||||
if let Some(rest) = left {
|
||||
// Inventory full: drop the rest at the player's feet without pickup delay.
|
||||
g.spawn_item(rest, [p[0], p[1] + 1.32, p[2]], [0.0, 0.0, 0.0], 0);
|
||||
} else {
|
||||
let r = &mut g.world.random;
|
||||
let pitch = ((r.next_float() - r.next_float()) * 0.7 + 1.0) * 2.0;
|
||||
g.audio
|
||||
.play("minecraft:entity.item.pickup", Some(p), 0.2, pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// The prototype stack: one item.
|
||||
let name = self.stack_display_name(&ItemStack {
|
||||
item: id.as_str().into(),
|
||||
count: count.max(1) as u32,
|
||||
count: 1,
|
||||
damage,
|
||||
extra: extra.clone(),
|
||||
});
|
||||
@@ -989,7 +1042,7 @@ impl Game<'_> {
|
||||
&[
|
||||
Text::literal(count.to_string()),
|
||||
name,
|
||||
Text::literal(self.acting_player_name()),
|
||||
self.target_name(targets[0]),
|
||||
],
|
||||
)
|
||||
} else {
|
||||
@@ -1008,6 +1061,9 @@ impl Game<'_> {
|
||||
fn teleport_to(&mut self, t: Target, pos: [f64; 3], rotation: Option<[f32; 2]>) {
|
||||
let v = Vec3::new(pos[0], pos[1], pos[2]);
|
||||
match t {
|
||||
Target::Guest(_) => {
|
||||
self.for_player(t, |g| g.teleport_to(Target::Player, pos, rotation));
|
||||
}
|
||||
Target::Player => {
|
||||
if let Some(p) = self.player.as_mut() {
|
||||
p.position = v;
|
||||
@@ -1088,17 +1144,96 @@ impl Game<'_> {
|
||||
Target::Frame(_) | Target::Painting(_) => {}
|
||||
}
|
||||
}
|
||||
/// Teleport the local player into the command source's dimension. Unlike
|
||||
/// portal travel, `/tp` keeps the coordinates given by the command.
|
||||
fn teleport_player_to_dimension(
|
||||
&mut self,
|
||||
dimension: Dim,
|
||||
pos: [f64; 3],
|
||||
rotation: Option<[f32; 2]>,
|
||||
) -> R<()> {
|
||||
let Some(mut player) = self.player.take() else {
|
||||
return Ok(());
|
||||
};
|
||||
let from = self.dim;
|
||||
if self.switch_level(dimension, player.position).is_err() {
|
||||
self.player = Some(player);
|
||||
return Err(err("command.failed", &[]));
|
||||
}
|
||||
self.trigger_dimension(from, dimension);
|
||||
let target = Vec3::new(pos[0], pos[1], pos[2]);
|
||||
player.position = target;
|
||||
player.velocity = Vec3::ZERO;
|
||||
player.fall_distance = 0.0;
|
||||
player.ground.on_ground = false;
|
||||
if let Some([yaw, pitch]) = rotation {
|
||||
let pitch = pitch.clamp(-90.0, 90.0);
|
||||
self.yaw = yaw;
|
||||
self.pitch = pitch;
|
||||
player.yaw = yaw;
|
||||
player.head_yaw = yaw;
|
||||
player.pitch = pitch;
|
||||
}
|
||||
self.travelling = Some((player, target));
|
||||
self.portals.travel = None;
|
||||
self.end_travel = false;
|
||||
self.end_portal_travel = false;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A server's player teleported into another level than theirs
|
||||
/// (ServerPlayer.teleport): queued to move after the command. False
|
||||
/// when `t` is not a player in another level.
|
||||
fn teleport_across(
|
||||
&mut self,
|
||||
t: Target,
|
||||
level: super::Dim,
|
||||
pos: [f64; 3],
|
||||
rotation: Option<[f32; 2]>,
|
||||
) -> bool {
|
||||
let (conn, at) = match t {
|
||||
Target::Player => (self.lan_acting, self.dim),
|
||||
Target::Guest(conn) => (
|
||||
Some(conn),
|
||||
self.command_guest(conn)
|
||||
.map_or(self.dim, |g| super::Dim::from_id(&g.dimension)),
|
||||
),
|
||||
_ => (None, self.dim),
|
||||
};
|
||||
let Some(conn) = conn.filter(|_| at != level && self.options.dedicated.is_some()) else {
|
||||
return false;
|
||||
};
|
||||
self.level_teleports
|
||||
.push(super::server_travel::LevelTeleport {
|
||||
conn,
|
||||
dim: level,
|
||||
at: pos,
|
||||
rotation,
|
||||
});
|
||||
true
|
||||
}
|
||||
fn cmd_teleport(&mut self, id: &str, ctx: &Context) -> R<i32> {
|
||||
let targets = if id.starts_with("teleport.targets") {
|
||||
self.entities(ctx, "targets", false)?
|
||||
} else {
|
||||
vec![Target::Player]
|
||||
vec![self.implied_player()]
|
||||
};
|
||||
if id.ends_with("destination") {
|
||||
let dest = self.entities(ctx, "destination", false)?[0];
|
||||
let pos = self.target_position(dest).unwrap_or(self.source_position());
|
||||
// Into the destination's level.
|
||||
let level = match dest {
|
||||
Target::Guest(conn) => self
|
||||
.command_guest(conn)
|
||||
.map_or(self.dim, |g| super::Dim::from_id(&g.dimension)),
|
||||
_ => self.dim,
|
||||
};
|
||||
// TeleportCommand.teleportToEntity: the destination's rotation too.
|
||||
let rotation = Some(self.target_rotation(dest));
|
||||
for &t in &targets {
|
||||
self.teleport_to(t, pos, None);
|
||||
if !self.teleport_across(t, level, pos, rotation) {
|
||||
self.teleport_to(t, pos, rotation);
|
||||
}
|
||||
}
|
||||
let message = if targets.len() == 1 {
|
||||
Text::translate(
|
||||
@@ -1156,24 +1291,24 @@ impl Game<'_> {
|
||||
(-(dy.atan2(horizontal).to_degrees())) as f32,
|
||||
]);
|
||||
}
|
||||
// `execute in` another dimension: a server's player moves to that
|
||||
// level (ServerPlayer.teleport into another level), after the command.
|
||||
let level = self
|
||||
.command_source
|
||||
.and_then(|s| s.level)
|
||||
.filter(|d| *d != self.dim && self.options.dedicated.is_some());
|
||||
// A server's player in another level than the source's (`execute
|
||||
// in`, the console's Overworld) moves there (ServerPlayer.teleport
|
||||
// into another level), after the command.
|
||||
let source_level = match self.command_source.and_then(|s| s.level) {
|
||||
Some(level) => level,
|
||||
None if self.source_entity().is_none() => super::Dim::Overworld,
|
||||
None => self.dim,
|
||||
};
|
||||
for &t in &targets {
|
||||
if let (Some(dim), Target::Player, Some(conn)) = (level, t, self.lan_acting) {
|
||||
self.level_teleports
|
||||
.push(super::server_travel::LevelTeleport {
|
||||
conn,
|
||||
dim,
|
||||
at: pos,
|
||||
rotation,
|
||||
});
|
||||
if self.teleport_across(t, source_level, pos, rotation) {
|
||||
continue;
|
||||
}
|
||||
self.teleport_to(t, pos, rotation);
|
||||
let dimension = self.command_source.map_or(self.dim, |s| s.dimension);
|
||||
if t == Target::Player && dimension != self.dim {
|
||||
self.teleport_player_to_dimension(dimension, pos, rotation)?;
|
||||
} else {
|
||||
self.teleport_to(t, pos, rotation);
|
||||
}
|
||||
}
|
||||
let [x, y, z] = pos.map(|v| Text::literal(format_double(v)));
|
||||
let message = if targets.len() == 1 {
|
||||
@@ -1373,6 +1508,9 @@ impl Game<'_> {
|
||||
}
|
||||
fn kill_target(&mut self, t: Target) {
|
||||
match t {
|
||||
Target::Guest(_) => {
|
||||
self.for_player(t, |g| g.kill_target(Target::Player));
|
||||
}
|
||||
Target::Player => {
|
||||
if let Some(p) = self.player.as_mut() {
|
||||
let _ = p.set_health(0.0, false);
|
||||
@@ -1415,7 +1553,7 @@ impl Game<'_> {
|
||||
let targets = if ctx.get("targets").is_some() {
|
||||
self.entities(ctx, "targets", false)?
|
||||
} else {
|
||||
vec![Target::Player]
|
||||
vec![self.implied_player()]
|
||||
};
|
||||
let names: Vec<Text> = targets.iter().map(|&t| self.target_name(t)).collect();
|
||||
// Remove indexed entities from the back so earlier indices stay valid.
|
||||
@@ -1468,7 +1606,7 @@ impl Game<'_> {
|
||||
if self.ui.difficulty == 0
|
||||
&& self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.get(&format!("minecraft:{short}"))
|
||||
.is_some_and(|t| t.category == "monster")
|
||||
{
|
||||
@@ -1485,7 +1623,7 @@ impl Game<'_> {
|
||||
let name;
|
||||
if let Some(t) = self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.get(&format!("minecraft:{short}"))
|
||||
.cloned()
|
||||
{
|
||||
@@ -1561,10 +1699,10 @@ impl Game<'_> {
|
||||
let name_ok = if b.tag {
|
||||
let tag = b.id.trim_start_matches("minecraft:");
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag)
|
||||
.or_else(|| self.res.items.block_tags.get(&b.id))
|
||||
.or_else(|| self.res.items().block_tags.get(&b.id))
|
||||
.is_some_and(|set| {
|
||||
set.contains(&s.name) || set.contains(s.name.trim_start_matches("minecraft:"))
|
||||
})
|
||||
@@ -1589,8 +1727,8 @@ impl Game<'_> {
|
||||
}
|
||||
// A different block replaces the block entity (Level.setBlock).
|
||||
let (old, new) = (
|
||||
self.res.facts.get(previous).name.clone(),
|
||||
self.res.facts.get(state).name.clone(),
|
||||
self.res.facts().get(previous).name.clone(),
|
||||
self.res.facts().get(state).name.clone(),
|
||||
);
|
||||
// The command clears the old block entity without its side effects
|
||||
// (UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS); the new block gets a fresh one.
|
||||
@@ -2184,10 +2322,10 @@ impl Game<'_> {
|
||||
let tag = predicate.id.trim_start_matches("minecraft:");
|
||||
return self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get(tag)
|
||||
.or_else(|| self.res.items.item_tags.get(&predicate.id))
|
||||
.or_else(|| self.res.items().item_tags.get(&predicate.id))
|
||||
.is_some_and(|s| {
|
||||
s.contains(item) || s.contains(item.trim_start_matches("minecraft:"))
|
||||
});
|
||||
@@ -2633,7 +2771,7 @@ impl Game<'_> {
|
||||
let focused = self.screen == Screen::Chat;
|
||||
self.ui
|
||||
.chat
|
||||
.add(&self.atlas, line, None, self.ticks, focused);
|
||||
.add(&self.gui.atlas, line, None, self.ticks, focused);
|
||||
Ok(1)
|
||||
}
|
||||
/// MessageArgument: `@p`-style selectors in a message become names.
|
||||
|
||||
@@ -502,7 +502,7 @@ impl Game<'_> {
|
||||
Some(Value::String(b)) => match b.strip_prefix('#') {
|
||||
Some(tag) => self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag.trim_start_matches("minecraft:"))
|
||||
.is_some_and(|set| {
|
||||
|
||||
@@ -35,6 +35,11 @@ impl Game<'_> {
|
||||
pub(in crate::game) fn entity_nbt(&mut self, t: Target) -> Option<Tag> {
|
||||
let player_uuid = self.level.player_uuid;
|
||||
Some(match t {
|
||||
Target::Guest(_) => {
|
||||
return self
|
||||
.for_player(t, |g| g.entity_nbt(Target::Player))
|
||||
.flatten();
|
||||
}
|
||||
Target::Player => {
|
||||
self.player.as_ref()?;
|
||||
self.sync_level();
|
||||
@@ -142,7 +147,7 @@ impl Game<'_> {
|
||||
set_key(&mut tag, "id", Tag::String(k.as_str().into()));
|
||||
}
|
||||
let new =
|
||||
entity_nbt::mob_from_nbt(&tag, &self.res.mob_types, id).ok_or_else(stale)?;
|
||||
entity_nbt::mob_from_nbt(&tag, self.res.mob_types(), id).ok_or_else(stale)?;
|
||||
if let Some(slot) = self.mobs.iter_mut().find(|m| m.id == id) {
|
||||
// Runtime-only state (AI, animation) carries over.
|
||||
let old = std::mem::replace(slot, new);
|
||||
@@ -661,13 +666,20 @@ impl Game<'_> {
|
||||
/// Spawn an entity from its compound (`EntityType.loadEntityRecursive`);
|
||||
/// returns what was created.
|
||||
pub(super) fn spawn_entity_from_nbt(&mut self, tag: Tag) -> Option<Target> {
|
||||
let before = self.next_entity;
|
||||
let key = {
|
||||
let p = entity_nbt::position(&tag)?;
|
||||
((p.x.floor() as i32) >> 4, (p.z.floor() as i32) >> 4)
|
||||
};
|
||||
// Only this stack spawns now: the entities of chunks that finished
|
||||
// loading wait for the level's entity tick, as in vanilla
|
||||
// (PersistentEntitySectionManager.processPendingLoads), and must not
|
||||
// take the ids counted as this stack's.
|
||||
let mut waiting = std::mem::take(&mut self.world.loaded_entities);
|
||||
let before = self.next_entity;
|
||||
self.world.loaded_entities.push((key, vec![tag]));
|
||||
self.spawn_loaded_entities();
|
||||
waiting.append(&mut self.world.loaded_entities);
|
||||
self.world.loaded_entities = waiting;
|
||||
if self.next_entity == before {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ impl Game<'_> {
|
||||
if ctx.get("targets").is_some() {
|
||||
self.entities(ctx, "targets", false)
|
||||
} else {
|
||||
Ok(vec![Target::Player])
|
||||
Ok(vec![self.implied_player()])
|
||||
}
|
||||
}
|
||||
/// `EffectCommands.giveEffect`.
|
||||
@@ -83,10 +83,11 @@ impl Game<'_> {
|
||||
let mut tracker = Tracker::default();
|
||||
for t in self.living_targets(ctx)? {
|
||||
let changed = match t {
|
||||
Target::Player => {
|
||||
Target::Player | Target::Guest(_) => {
|
||||
let mut instance = EffectInstance::new(effect.id, duration, amplifier);
|
||||
instance.visible = particles;
|
||||
self.add_player_effect(instance)
|
||||
self.for_player(t, |g| g.add_player_effect(instance))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
Target::Mob(id) => match self.mobs.iter_mut().find(|m| m.id == id) {
|
||||
Some(m) => {
|
||||
@@ -131,18 +132,22 @@ impl Game<'_> {
|
||||
let mut tracker = Tracker::default();
|
||||
for t in self.living_targets(ctx)? {
|
||||
let changed = match (t, effect) {
|
||||
(Target::Player, None) => {
|
||||
let any = !self.potions.effects.list.is_empty();
|
||||
self.potions.effects.clear();
|
||||
self.apply_effect_status();
|
||||
any
|
||||
}
|
||||
(Target::Player, Some(e)) => {
|
||||
let before = self.potions.effects.list.len();
|
||||
self.potions.effects.list.retain(|x| x.id != e.id);
|
||||
self.apply_effect_status();
|
||||
self.potions.effects.list.len() != before
|
||||
}
|
||||
(Target::Player | Target::Guest(_), None) => self
|
||||
.for_player(t, |g| {
|
||||
let any = !g.potions.effects.list.is_empty();
|
||||
g.potions.effects.clear();
|
||||
g.apply_effect_status();
|
||||
any
|
||||
})
|
||||
.unwrap_or(false),
|
||||
(Target::Player | Target::Guest(_), Some(e)) => self
|
||||
.for_player(t, |g| {
|
||||
let before = g.potions.effects.list.len();
|
||||
g.potions.effects.list.retain(|x| x.id != e.id);
|
||||
g.apply_effect_status();
|
||||
g.potions.effects.list.len() != before
|
||||
})
|
||||
.unwrap_or(false),
|
||||
(Target::Mob(id), e) => match self.mobs.iter_mut().find(|m| m.id == id) {
|
||||
Some(m) => {
|
||||
let before = m.extra.effects.len();
|
||||
@@ -187,7 +192,7 @@ impl Game<'_> {
|
||||
return Ok(0);
|
||||
};
|
||||
let level = Self::int(ctx, "level").unwrap_or(1);
|
||||
let enchantments = &self.res.stations.enchantments;
|
||||
let enchantments = &self.res.stations().enchantments;
|
||||
let Some(def) = enchantments.get(&id) else {
|
||||
return Err(err(
|
||||
"argument.resource.not_found",
|
||||
@@ -213,8 +218,8 @@ impl Game<'_> {
|
||||
}
|
||||
continue;
|
||||
};
|
||||
let e = &self.res.stations.enchantments;
|
||||
let compatible = e.can_enchant(&self.res.items, &id, &stack.item)
|
||||
let e = &self.res.stations().enchantments;
|
||||
let compatible = e.can_enchant(self.res.items(), &id, &stack.item)
|
||||
&& stack
|
||||
.crafting_enchantments()
|
||||
.iter()
|
||||
@@ -265,7 +270,7 @@ impl Game<'_> {
|
||||
}
|
||||
let (name, curse) = self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.full_name(&id, level.max(0) as u32);
|
||||
let style = Style {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! `/execute` (ExecuteCommand): walk the parsed redirect chain, forking and
|
||||
//! filtering command sources, then run the final command once per source,
|
||||
//! reporting each result to the `store` callbacks of its source.
|
||||
use super::{Arg, Context, Game, R, Target, data::DataRef, err};
|
||||
use super::{Arg, Context, Dim, Game, R, Target, data::DataRef, err};
|
||||
use horizon_client::{
|
||||
command::{CommandError, vanilla},
|
||||
nbt_path::NbtPath,
|
||||
@@ -23,9 +23,9 @@ pub(in crate::game) struct Source {
|
||||
pub silent: bool,
|
||||
/// Index of the newest `store` in `ExecState::stores`.
|
||||
pub store: Option<u32>,
|
||||
/// `execute in` another dimension than the one Horizon has loaded: none
|
||||
/// of its chunks are loaded.
|
||||
pub elsewhere: bool,
|
||||
/// The level this command source uses. Horizon has only this dimension's
|
||||
/// chunks loaded in the single-player client.
|
||||
pub dimension: Dim,
|
||||
/// The dimension `execute in` named, if any: a server teleports its
|
||||
/// players there (`TeleportCommand` into the source's level).
|
||||
pub level: Option<super::super::Dim>,
|
||||
@@ -73,13 +73,14 @@ impl Game<'_> {
|
||||
/// The source a command typed by the player starts from.
|
||||
pub(in crate::game) fn player_source(&self) -> Source {
|
||||
Source {
|
||||
entity: Some(Target::Player),
|
||||
// The server console has no entity (CommandSourceStack of the server).
|
||||
entity: self.player.is_some().then_some(Target::Player),
|
||||
pos: self.source_position(),
|
||||
rot: self.source_rotation(),
|
||||
eyes: false,
|
||||
silent: false,
|
||||
store: None,
|
||||
elsewhere: false,
|
||||
dimension: self.dim,
|
||||
level: None,
|
||||
block: None,
|
||||
}
|
||||
@@ -88,12 +89,12 @@ impl Game<'_> {
|
||||
pub(in crate::game) fn server_source(&self) -> Source {
|
||||
Source {
|
||||
entity: None,
|
||||
pos: self.spawn.map_or([0.0, 64.0, 0.0], |s| [s.x, s.y, s.z]),
|
||||
pos: self.server_position(),
|
||||
rot: [0.0, 0.0],
|
||||
eyes: false,
|
||||
silent: true,
|
||||
store: None,
|
||||
elsewhere: false,
|
||||
dimension: self.dim,
|
||||
level: None,
|
||||
block: None,
|
||||
}
|
||||
@@ -101,6 +102,9 @@ impl Game<'_> {
|
||||
pub(super) fn target_rotation(&self, t: Target) -> [f32; 2] {
|
||||
match t {
|
||||
Target::Player => [self.yaw, self.pitch],
|
||||
Target::Guest(conn) => self
|
||||
.command_guest(conn)
|
||||
.map_or([0.0; 2], |g| [g.yaw, g.pitch]),
|
||||
Target::Mob(id) => self
|
||||
.mobs
|
||||
.iter()
|
||||
@@ -135,6 +139,7 @@ impl Game<'_> {
|
||||
.player
|
||||
.as_ref()
|
||||
.map_or(1.62, |p| f64::from(p.dimensions.eye_height)),
|
||||
Target::Guest(conn) => self.command_guest(conn).map_or(1.62, |g| g.eye_height()),
|
||||
Target::Mob(id) => self
|
||||
.mobs
|
||||
.iter()
|
||||
@@ -445,7 +450,7 @@ impl Game<'_> {
|
||||
Some(Source {
|
||||
pos: self.target_position(t)?,
|
||||
rot: self.target_rotation(t),
|
||||
elsewhere: false,
|
||||
dimension: self.dim,
|
||||
level: None,
|
||||
..s
|
||||
})
|
||||
@@ -537,8 +542,8 @@ impl Game<'_> {
|
||||
..s
|
||||
}],
|
||||
"in" => {
|
||||
// Horizon keeps one dimension loaded: in another one, no
|
||||
// chunk is loaded (as in vanilla without a player there).
|
||||
// CommandSourceStack.withLevel scales the source position;
|
||||
// absolute coordinates passed to /tp are unaffected.
|
||||
let Some(Arg::Resource(dim)) = c.get("dimension") else {
|
||||
return Ok(vec![s]);
|
||||
};
|
||||
@@ -548,8 +553,12 @@ impl Game<'_> {
|
||||
) {
|
||||
return Err(err("argument.dimension.invalid", &[dim]));
|
||||
}
|
||||
let dimension = Dim::from_id(dim);
|
||||
let coordinate_scale = |dim| if dim == Dim::Nether { 8.0 } else { 1.0 };
|
||||
let scale = coordinate_scale(s.dimension) / coordinate_scale(dimension);
|
||||
vec![Source {
|
||||
elsewhere: dim != self.dim.id(),
|
||||
pos: [s.pos[0] * scale, s.pos[1], s.pos[2] * scale],
|
||||
dimension,
|
||||
level: Some(super::super::Dim::from_id(dim)),
|
||||
..s
|
||||
}]
|
||||
@@ -633,7 +642,7 @@ impl Game<'_> {
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
fn target_with_uuid(&self, uuid: [i32; 4]) -> Option<Target> {
|
||||
pub(super) fn target_with_uuid(&self, uuid: [i32; 4]) -> Option<Target> {
|
||||
if Some(uuid) == self.level.player_uuid {
|
||||
return Some(Target::Player);
|
||||
}
|
||||
@@ -656,7 +665,7 @@ impl Game<'_> {
|
||||
if state == self.world.air {
|
||||
continue;
|
||||
}
|
||||
let facts = self.res.facts.get(state);
|
||||
let facts = self.res.facts().get(state);
|
||||
let blocks = facts.legacy_solid || facts.fluid != horizon_client::blocks::Fluid::None;
|
||||
let leaves = self
|
||||
.pack
|
||||
@@ -792,14 +801,16 @@ impl Game<'_> {
|
||||
let p = self
|
||||
.coords(c, "pos")
|
||||
.map(|co| co.block(self.source_position(), self.source_rotation()));
|
||||
return Ok(flag(p.is_some_and(|p| {
|
||||
self.world.chunks.contains_key(&(p[0] >> 4, p[2] >> 4))
|
||||
})));
|
||||
let dimension = self.command_source.map_or(self.dim, |s| s.dimension);
|
||||
return Ok(flag(
|
||||
dimension == self.dim
|
||||
&& p.is_some_and(|p| self.world.chunks.contains_key(&(p[0] >> 4, p[2] >> 4))),
|
||||
));
|
||||
}
|
||||
if c.has("dimension") {
|
||||
return Ok(flag(
|
||||
matches!(c.get("dimension"), Some(Arg::Resource(d)) if d == self.dim.id()),
|
||||
));
|
||||
let dimension = self.command_source.map_or(self.dim, |s| s.dimension);
|
||||
return Ok(flag(matches!(c.get("dimension"), Some(Arg::Resource(d))
|
||||
if d.as_str() == dimension.id())));
|
||||
}
|
||||
if c.has("block") {
|
||||
let p = self.block_pos_arg(c, "pos")?;
|
||||
@@ -948,7 +959,7 @@ impl Game<'_> {
|
||||
let chunk = self.world.chunks.get(&(p[0] >> 4, p[2] >> 4))?;
|
||||
Some(
|
||||
self.res
|
||||
.biomes
|
||||
.biomes()
|
||||
.get(chunk.biome(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone(),
|
||||
@@ -971,7 +982,7 @@ impl Game<'_> {
|
||||
.resources
|
||||
.join(format!("data/{ns}/tags/worldgen/biome/{path}.json"));
|
||||
let Ok(bytes) = std::fs::read(file) else {
|
||||
return self.res.mob_data.biome_has(tag, biome);
|
||||
return self.res.mob_data().biome_has(tag, biome);
|
||||
};
|
||||
let v: serde_json::Value = serde_json::from_slice(&bytes).unwrap_or_default();
|
||||
v["values"].as_array().is_some_and(|a| {
|
||||
|
||||
@@ -586,7 +586,7 @@ impl Game<'_> {
|
||||
);
|
||||
let hit = traverse_blocks(eye, end, 256, |b: BlockPos| {
|
||||
let state = self.world.block(b.x, b.y, b.z);
|
||||
(!self.res.facts.is_air(state)).then_some([b.x, b.y, b.z])
|
||||
(!self.res.facts().is_air(state)).then_some([b.x, b.y, b.z])
|
||||
});
|
||||
hit.ok().flatten().unwrap_or([
|
||||
end.x.floor() as i32,
|
||||
|
||||
@@ -375,7 +375,11 @@ impl Game<'_> {
|
||||
} else {
|
||||
0
|
||||
};
|
||||
let max = self.res.items.get(&stack.item).map_or(64, |i| i.max_stack);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.map_or(64, |i| i.max_stack);
|
||||
stack.count = (base + n).clamp(0, max as i32) as u32;
|
||||
}
|
||||
"minecraft:limit_count" => {
|
||||
@@ -389,7 +393,11 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
"minecraft:set_damage" => {
|
||||
let max = self.res.items.get(&stack.item).map_or(0, |i| i.max_damage);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.map_or(0, |i| i.max_damage);
|
||||
if max > 0 {
|
||||
let f = match m["damage"].as_f64() {
|
||||
Some(f) => f as f32,
|
||||
@@ -587,7 +595,7 @@ impl Game<'_> {
|
||||
if let Some(Tag::Int(n)) = s.data().and_then(|d| d.other("minecraft:max_stack_size")) {
|
||||
return (*n).clamp(1, 99) as u32;
|
||||
}
|
||||
self.res.items.get(&s.item).map_or(64, |i| i.max_stack)
|
||||
self.res.items().get(&s.item).map_or(64, |i| i.max_stack)
|
||||
}
|
||||
/// `ResourceOrIdArgument.getItemModifier`: an inline modifier (SNBT) or
|
||||
/// a registered one.
|
||||
|
||||
@@ -53,13 +53,7 @@ impl Game<'_> {
|
||||
let Ok(raw) = Compression::Gzip.decode(&bytes, 1 << 28) else {
|
||||
continue;
|
||||
};
|
||||
let Ok((named, _)) = nbt::read_named(
|
||||
&raw,
|
||||
Limits {
|
||||
max_bytes: 1 << 28,
|
||||
..Limits::default()
|
||||
},
|
||||
) else {
|
||||
let Ok((named, _)) = nbt::read_named(&raw, Limits::templates()) else {
|
||||
continue;
|
||||
};
|
||||
return Some(Arc::new(StructureTemplate::from_nbt(
|
||||
@@ -79,10 +73,10 @@ impl Game<'_> {
|
||||
}
|
||||
/// `PlaceCommand.checkLoaded`: every chunk of the inclusive range.
|
||||
fn place_check_loaded(&self, min: [i32; 2], max: [i32; 2]) -> R<()> {
|
||||
let elsewhere = self.command_source.is_some_and(|s| s.elsewhere);
|
||||
let dimension = self.command_source.map_or(self.dim, |s| s.dimension);
|
||||
for cx in min[0]..=max[0] {
|
||||
for cz in min[1]..=max[1] {
|
||||
if elsewhere || !self.world.chunks.contains_key(&(cx, cz)) {
|
||||
if dimension != self.dim || !self.world.chunks.contains_key(&(cx, cz)) {
|
||||
return Err(err("argument.pos.unloaded", &[]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
//! Commands acting on the other players of a hosted world or a server
|
||||
//! (EntitySelector.findPlayers and EntityArgument's player targets). The
|
||||
//! player in place (the host's, or the guest whose turn it is) is
|
||||
//! `Target::Player`; every other guest is `Target::Guest`, found by name,
|
||||
//! UUID or selector, and what a command does to them runs with their state
|
||||
//! swapped in (`for_player`), as their own turn, what it tells them going to
|
||||
//! their chat.
|
||||
use super::{Game, Target};
|
||||
use horizon_client::{command::args::Selector, lan::guest::Guest, text::Text};
|
||||
use horizon_protocol::packets::play::{self, Clientbound as C};
|
||||
|
||||
impl Target {
|
||||
/// A player, in place or not (`instanceof ServerPlayer`).
|
||||
pub(in crate::game) fn is_player(self) -> bool {
|
||||
matches!(self, Target::Player | Target::Guest(_))
|
||||
}
|
||||
}
|
||||
|
||||
/// GameType.getName for a guest's game mode id.
|
||||
fn mode_name(id: i32) -> &'static str {
|
||||
match id {
|
||||
1 => "creative",
|
||||
2 => "adventure",
|
||||
3 => "spectator",
|
||||
_ => "survival",
|
||||
}
|
||||
}
|
||||
|
||||
impl Game<'_> {
|
||||
/// The guest `conn`, while the hub is in `self.lan`.
|
||||
pub(in crate::game) fn command_guest(&self, conn: u32) -> Option<&Guest> {
|
||||
self.lan.as_ref()?.hub.guest(conn)
|
||||
}
|
||||
|
||||
/// `PlayerList.getPlayers` but the player in place: the guests who
|
||||
/// joined the world.
|
||||
fn command_players(&self) -> impl Iterator<Item = &Guest> {
|
||||
let acting = self.lan_acting;
|
||||
self.lan
|
||||
.iter()
|
||||
.flat_map(|h| h.hub.guests.iter())
|
||||
.filter(move |g| g.placed && Some(g.conn) != acting)
|
||||
}
|
||||
|
||||
/// The entity the command runs as (`CommandSourceStack.getEntity`): a
|
||||
/// command typed by the player in place runs as them, the server
|
||||
/// console's as nobody.
|
||||
pub(in crate::game) fn source_entity(&self) -> Option<Target> {
|
||||
match self.command_source {
|
||||
Some(s) => s.entity,
|
||||
None => self.player.is_some().then_some(Target::Player),
|
||||
}
|
||||
}
|
||||
|
||||
/// `CommandSourceStack.getPlayerOrException` for the commands whose
|
||||
/// player argument is optional: the source's player (the player in
|
||||
/// place when it has none, as before).
|
||||
pub(in crate::game) fn implied_player(&self) -> Target {
|
||||
self.source_entity()
|
||||
.filter(|t| t.is_player())
|
||||
.unwrap_or(Target::Player)
|
||||
}
|
||||
|
||||
/// `PlayerList.getPlayerByName`: names are not case sensitive.
|
||||
pub(super) fn player_named(&self, name: &str) -> Option<Target> {
|
||||
if self.player.is_some() && name.eq_ignore_ascii_case(self.acting_player_name()) {
|
||||
return Some(Target::Player);
|
||||
}
|
||||
self.command_players()
|
||||
.find(|g| g.name.eq_ignore_ascii_case(name))
|
||||
.map(|g| Target::Guest(g.conn))
|
||||
}
|
||||
|
||||
/// `EntitySelector.findEntities` with a UUID: the player with it, else
|
||||
/// the entity.
|
||||
pub(super) fn target_by_uuid(&self, uuid: u128) -> Option<Target> {
|
||||
let own = self.lan_acting_uuid.or_else(|| {
|
||||
self.level.player_uuid.map(|[a, b, c, d]| {
|
||||
(u128::from(a as u32) << 96)
|
||||
| (u128::from(b as u32) << 64)
|
||||
| (u128::from(c as u32) << 32)
|
||||
| u128::from(d as u32)
|
||||
})
|
||||
});
|
||||
if self.player.is_some() && own == Some(uuid) {
|
||||
return Some(Target::Player);
|
||||
}
|
||||
if let Some(g) = self.command_players().find(|g| g.uuid == uuid) {
|
||||
return Some(Target::Guest(g.conn));
|
||||
}
|
||||
let words = [96, 64, 32, 0].map(|shift| (uuid >> shift) as u32 as i32);
|
||||
self.target_with_uuid(words)
|
||||
}
|
||||
|
||||
/// The guests a selector looks at, in join order (`PlayerList.getPlayers`),
|
||||
/// the one in place as `Target::Player`: all of them, or those in the
|
||||
/// source's level when it limits the search to a place
|
||||
/// (`isWorldLimited`); `@e` and `@n` skip the dead (`Entity::isAlive`).
|
||||
pub(super) fn player_candidates(&self, s: &Selector) -> Vec<Target> {
|
||||
let limited = s.distance.is_some()
|
||||
|| s.pos.iter().any(Option::is_some)
|
||||
|| s.delta.iter().any(Option::is_some);
|
||||
let alive = matches!(s.kind, 'e' | 'n');
|
||||
let here = self.dim.id();
|
||||
let in_place = self.lan_acting.filter(|_| self.player.is_some());
|
||||
self.lan
|
||||
.iter()
|
||||
.flat_map(|h| h.hub.guests.iter())
|
||||
.filter(|g| g.placed)
|
||||
.filter(|g| !limited || g.dimension == here || Some(g.conn) == in_place)
|
||||
.filter(|g| !alive || (!g.dead && g.health > 0.0))
|
||||
.map(|g| {
|
||||
if Some(g.conn) == in_place {
|
||||
Target::Player
|
||||
} else {
|
||||
Target::Guest(g.conn)
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// A guest's experience level and game mode, for `level=` and `gamemode=`.
|
||||
pub(super) fn guest_level_and_mode(&self, conn: u32) -> Option<(i32, &'static str)> {
|
||||
self.command_guest(conn)
|
||||
.map(|g| (g.xp_level, mode_name(g.game_mode)))
|
||||
}
|
||||
|
||||
/// `Player.getDisplayName`: the name as its team shows it, suggesting a
|
||||
/// `/tell`, showing the player on hover, inserting the name.
|
||||
pub(in crate::game) fn player_text(&self, name: &str, uuid: u128) -> Text {
|
||||
let shown = match self.score.board.players_team(name) {
|
||||
Some(team) => team.formatted_name(Text::literal(name)),
|
||||
None => Text::literal(name),
|
||||
};
|
||||
shown.with_component_fields(vec![
|
||||
(
|
||||
"click_event".into(),
|
||||
serde_json::json!({"action": "suggest_command", "command": format!("/tell {name} ")}),
|
||||
),
|
||||
(
|
||||
"hover_event".into(),
|
||||
serde_json::json!({"action": "show_entity", "id": "minecraft:player",
|
||||
"uuid": horizon_protocol::crypto::uuid_string(uuid), "name": name}),
|
||||
),
|
||||
("insertion".into(), name.into()),
|
||||
])
|
||||
}
|
||||
|
||||
/// Run `f` for the player `t` (None for anything else): in place, or
|
||||
/// with the guest's state swapped in, in their level, as their own turn.
|
||||
/// What `f` tells the player (`system_message`) goes to their chat; the
|
||||
/// command's own feedback is the caller's to send.
|
||||
pub(in crate::game) fn for_player<T>(
|
||||
&mut self,
|
||||
t: Target,
|
||||
f: impl FnOnce(&mut Self) -> T,
|
||||
) -> Option<T> {
|
||||
let conn = match t {
|
||||
Target::Player => return Some(f(self)),
|
||||
Target::Guest(conn) if self.lan_acting == Some(conn) => return Some(f(self)),
|
||||
Target::Guest(conn) => conn,
|
||||
_ => return None,
|
||||
};
|
||||
let mut host = self.lan.take()?;
|
||||
let back = self.dim;
|
||||
let theirs = host
|
||||
.hub
|
||||
.guest(conn)
|
||||
.map(|g| super::super::Dim::from_id(&g.dimension));
|
||||
if let Some(dim) = theirs.filter(|d| *d != back)
|
||||
&& let Err(e) = self.enter_level(Some(&mut host), dim)
|
||||
{
|
||||
log::error!("could not open {}: {e}", dim.id());
|
||||
}
|
||||
let Some(swap) = self.enter_guest(&mut host, conn) else {
|
||||
if self.dim != back
|
||||
&& let Err(e) = self.enter_level(Some(&mut host), back)
|
||||
{
|
||||
log::error!("could not reopen {}: {e}", back.id());
|
||||
}
|
||||
self.lan = Some(host);
|
||||
return None;
|
||||
};
|
||||
self.lan = Some(host);
|
||||
let source = self.chat_capture.replace(Vec::new());
|
||||
let out = f(self);
|
||||
let told = std::mem::replace(&mut self.chat_capture, source).unwrap_or_default();
|
||||
let mut host = self
|
||||
.lan
|
||||
.take()
|
||||
.expect("the hub is back after a player's turn");
|
||||
self.leave_guest(&mut host, swap);
|
||||
for line in told {
|
||||
host.hub.send_to(
|
||||
conn,
|
||||
&C::SystemChat(play::SystemChat {
|
||||
content: horizon_client::lan::data::component_nbt(&line.component()),
|
||||
overlay: false,
|
||||
}),
|
||||
);
|
||||
}
|
||||
if self.dim != back
|
||||
&& let Err(e) = self.enter_level(Some(&mut host), back)
|
||||
{
|
||||
log::error!("could not reopen {}: {e}", back.id());
|
||||
}
|
||||
self.lan = Some(host);
|
||||
Some(out)
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ impl Game<'_> {
|
||||
if volume > i64::from(limit) {
|
||||
return Err(err("commands.fillbiome.toobig", &[&limit, &volume]));
|
||||
}
|
||||
let Some(target) = self.res.biomes.list.iter().position(|b| b.name == biome) else {
|
||||
let Some(target) = self.res.biomes().list.iter().position(|b| b.name == biome) else {
|
||||
return Err(err(
|
||||
"argument.resource.not_found",
|
||||
&[&biome, &"minecraft:worldgen/biome"],
|
||||
@@ -201,7 +201,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
};
|
||||
let current = chunk.biome(x, y, z);
|
||||
let current_name = &self.res.biomes.list[usize::from(current)].name;
|
||||
let current_name = &self.res.biomes().list[usize::from(current)].name;
|
||||
if let Some(f) = &filter
|
||||
&& !self.biome_matches(f, current_name)
|
||||
{
|
||||
@@ -474,11 +474,11 @@ impl Game<'_> {
|
||||
let json = horizon_client::scoreboard::tag_to_json(&tag);
|
||||
let drops = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.inline_loot_table(&json, &mut self.world.random);
|
||||
(drops, None)
|
||||
} else {
|
||||
if !self.res.items.has_loot_table(&table) {
|
||||
if !self.res.items().has_loot_table(&table) {
|
||||
return Err(err("argument.resource_or_id.failed_to_parse", &[&table]));
|
||||
}
|
||||
let held = if id == "loot.fish" {
|
||||
@@ -486,14 +486,14 @@ impl Game<'_> {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let drops = match self.res.items.loot_sequence(&table) {
|
||||
let drops = match self.res.items().loot_sequence(&table) {
|
||||
Some(seq) => {
|
||||
let random = self.rand_sequences.get(&seq, self.level.seed);
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(&table, false, held.as_ref(), random)
|
||||
}
|
||||
None => self.res.items.loot_table(
|
||||
None => self.res.items().loot_table(
|
||||
&table,
|
||||
false,
|
||||
held.as_ref(),
|
||||
@@ -510,7 +510,7 @@ impl Game<'_> {
|
||||
};
|
||||
let ty = self.target_type(t);
|
||||
let table = format!("minecraft:entities/{}", ty.trim_start_matches("minecraft:"));
|
||||
if t == Target::Player || !self.res.items.has_loot_table(&table) {
|
||||
if t == Target::Player || !self.res.items().has_loot_table(&table) {
|
||||
return Err(err(
|
||||
"commands.drop.no_loot_table.entity",
|
||||
&[&self.target_name(t).plain()],
|
||||
@@ -521,14 +521,14 @@ impl Game<'_> {
|
||||
None | Some(Some(Target::Player))
|
||||
);
|
||||
let held = self.slot_get(&super::items::Slot::Inv(self.selected));
|
||||
let drops = match self.res.items.loot_sequence(&table) {
|
||||
let drops = match self.res.items().loot_sequence(&table) {
|
||||
Some(seq) => {
|
||||
let random = self.rand_sequences.get(&seq, self.level.seed);
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.entity_drops(&ty, by_player, held.as_ref(), random)
|
||||
}
|
||||
None => self.res.items.entity_drops(
|
||||
None => self.res.items().entity_drops(
|
||||
&ty,
|
||||
by_player,
|
||||
held.as_ref(),
|
||||
@@ -543,21 +543,21 @@ impl Game<'_> {
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
let name = self.data_block_name(p);
|
||||
let table = format!("minecraft:blocks/{}", name.trim_start_matches("minecraft:"));
|
||||
if !self.res.items.has_loot_table(&table) {
|
||||
if !self.res.items().has_loot_table(&table) {
|
||||
return Err(err("commands.drop.no_loot_table.block", &[&name]));
|
||||
}
|
||||
let tool = self.tool_stack(ctx)?;
|
||||
let drops = match self.res.items.loot_sequence(&table) {
|
||||
let drops = match self.res.items().loot_sequence(&table) {
|
||||
Some(seq) => {
|
||||
let random = self.rand_sequences.get(&seq, self.level.seed);
|
||||
self.res.items.block_drops(
|
||||
self.res.items().block_drops(
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
tool.as_ref(),
|
||||
random,
|
||||
)
|
||||
}
|
||||
None => self.res.items.block_drops(
|
||||
None => self.res.items().block_drops(
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
tool.as_ref(),
|
||||
@@ -624,7 +624,7 @@ impl Game<'_> {
|
||||
&& cur.damage == left.damage
|
||||
&& cur.extra == left.extra =>
|
||||
{
|
||||
let max = self.res.items.get(&cur.item).map_or(64, |i| i.max_stack);
|
||||
let max = self.res.items().get(&cur.item).map_or(64, |i| i.max_stack);
|
||||
let take = left.count.min(max.saturating_sub(cur.count));
|
||||
if take > 0 {
|
||||
cur.count += take;
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Game<'_> {
|
||||
|
||||
/// Every recipe id of the recipe manager (what `/recipe` resolves and suggests).
|
||||
pub(super) fn learnable_recipes(&self) -> Vec<String> {
|
||||
self.res.stations.recipe_index.ids().cloned().collect()
|
||||
self.res.stations().recipe_index.ids().cloned().collect()
|
||||
}
|
||||
pub(super) fn cmd_recipe(&mut self, id: &str, ctx: &Context) -> R<i32> {
|
||||
let targets = self.entities(ctx, "targets", true)?;
|
||||
@@ -52,7 +52,7 @@ impl Game<'_> {
|
||||
// displays (a transmute recipe has one per material count).
|
||||
let mut n = 0;
|
||||
// ServerPlayer.awardRecipes / resetRecipes: the displays changed.
|
||||
let index = &self.res.stations.recipe_index;
|
||||
let index = &self.res.stations().recipe_index;
|
||||
n += if give {
|
||||
let (count, unlocked) = self.level.recipe_book.add_recipes(index, &recipes);
|
||||
self.recipe_unlocked(&unlocked);
|
||||
@@ -1267,7 +1267,7 @@ impl Game<'_> {
|
||||
fn spread_spawn_y(&self, p: [f64; 2], max_y: i32) -> i32 {
|
||||
let (x, z) = (p[0].floor() as i32, p[1].floor() as i32);
|
||||
let air = |y: i32| {
|
||||
let name: &str = &self.res.facts.get(self.world.block(x, y, z)).name;
|
||||
let name: &str = &self.res.facts().get(self.world.block(x, y, z)).name;
|
||||
matches!(
|
||||
name,
|
||||
"minecraft:air" | "minecraft:cave_air" | "minecraft:void_air"
|
||||
@@ -1292,16 +1292,16 @@ impl Game<'_> {
|
||||
fn spread_safe(&self, p: [f64; 2], max_y: i32) -> bool {
|
||||
let y = self.spread_spawn_y(p, max_y) - 1;
|
||||
let (x, z) = (p[0].floor() as i32, p[1].floor() as i32);
|
||||
let name = self.res.facts.get(self.world.block(x, y, z)).name.clone();
|
||||
let name = self.res.facts().get(self.world.block(x, y, z)).name.clone();
|
||||
let liquid = matches!(&*name, "minecraft:water" | "minecraft:lava");
|
||||
let teleportable = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("entities_can_teleport_to")
|
||||
.or_else(|| {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:entities_can_teleport_to")
|
||||
})
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// The item's `compostable` layers provider.
|
||||
fn compostable(&self, stack: &ItemStack) -> Option<serde_json::Value> {
|
||||
self.res.items.get(&stack.item)?.compostable.clone()
|
||||
self.res.items().get(&stack.item)?.compostable.clone()
|
||||
}
|
||||
/// `ComposterBlock.addLayer` and level event 1500: the provider is
|
||||
/// evaluated in the composter's block-interaction loot context (its
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
//! Finishing a consumable (`Consumable.onConsume` and the use remainder),
|
||||
//! its particles and sounds, and `TeleportRandomlyConsumeEffect` (chorus
|
||||
//! fruit) for the local player. The level random stands in for the player's
|
||||
//! own, as for every other player draw.
|
||||
use super::{Dim, Game};
|
||||
use horizon_client::{
|
||||
items::{ConsumeEffect, ItemInfo, ItemStack},
|
||||
mobs::Who,
|
||||
particles::{ParticleOptions, ParticleType},
|
||||
};
|
||||
use horizon_core::{
|
||||
geometry::Vec3, position::BlockPos, random::LegacyRandom, random::RandomSource,
|
||||
};
|
||||
use horizon_world::{
|
||||
consumable::{Consumable, EmissionWorld, UseAnimation},
|
||||
teleport_consume::{TeleportConsume, TeleportConsumeWorld},
|
||||
};
|
||||
use std::convert::Infallible;
|
||||
|
||||
type ItemConsumable = Consumable<String, ConsumeEffect>;
|
||||
|
||||
impl Game<'_> {
|
||||
/// `Consumable.emitParticlesAndSounds(user.getRandom(), user, stack, count)`.
|
||||
pub(super) fn emit_consume(
|
||||
&mut self,
|
||||
consumable: &ItemConsumable,
|
||||
stack: &ItemStack,
|
||||
count: i32,
|
||||
) {
|
||||
let Ok(()) = consumable.emit(&mut Emitter(self), (), stack.clone(), count);
|
||||
}
|
||||
/// `LivingEntity.completeUsingItem` for a consumable: `Consumable.onConsume`,
|
||||
/// then `ItemStack.applyAfterUseComponentSideEffects`' use remainder.
|
||||
pub(super) fn finish_consuming(
|
||||
&mut self,
|
||||
info: &ItemInfo,
|
||||
consumable: &ItemConsumable,
|
||||
stack: &ItemStack,
|
||||
) {
|
||||
self.emit_consume(consumable, stack, 16);
|
||||
// ServerPlayer: the used statistic and the consume_item trigger.
|
||||
self.stats.add("used", &stack.item, 1);
|
||||
self.trigger_item("minecraft:consume_item", stack);
|
||||
// FoodProperties.onConsume, the player's one ConsumableListener.
|
||||
if let Some((nutrition, saturation)) = info.food {
|
||||
let at = self.feet();
|
||||
let pitch = self.world.random.triangle_float(1.0, 0.4);
|
||||
self.audio.play(&consumable.sound, at, 1.0, pitch);
|
||||
if let Some(p) = self.player.as_mut() {
|
||||
// FoodData.eat(nutrition, saturation)
|
||||
let food = &mut p.health.food;
|
||||
food.food = (food.food + nutrition as i32).clamp(0, 20);
|
||||
food.saturation = (food.saturation + saturation).clamp(0.0, food.food as f32);
|
||||
}
|
||||
// Mth.randomBetween(random, 0.9, 1.0)
|
||||
let pitch = self.world.random.next_float() * (1.0f32 - 0.9f32) + 0.9;
|
||||
self.audio
|
||||
.play("minecraft:entity.player.burp", self.feet(), 0.5, pitch);
|
||||
}
|
||||
for effect in &consumable.effects {
|
||||
self.apply_consume_effect(effect);
|
||||
}
|
||||
let event = if consumable.animation == UseAnimation::Drink {
|
||||
"minecraft:drink"
|
||||
} else {
|
||||
"minecraft:eat"
|
||||
};
|
||||
self.post_entity_event(event, Who::Player);
|
||||
// ItemStack.consume, then UseRemainder.convertIntoRemainder: nothing
|
||||
// with infinite materials, the hand when emptied, else the inventory
|
||||
// (ServerPlayer.handleExtraItemsCreatedOnUse) or a drop.
|
||||
self.consume_held();
|
||||
if let Some(remainder) = &info.use_remainder
|
||||
&& !self.creative
|
||||
{
|
||||
let remainder = ItemStack::new(remainder, 1);
|
||||
if self.held().is_none() {
|
||||
*self.held_mut() = Some(remainder);
|
||||
} else if let Some(rest) = self.give(remainder) {
|
||||
self.player_drop(rest);
|
||||
}
|
||||
}
|
||||
}
|
||||
fn feet(&self) -> Option<[f64; 3]> {
|
||||
self.player
|
||||
.as_ref()
|
||||
.map(|p| [p.position.x, p.position.y, p.position.z])
|
||||
}
|
||||
/// `TeleportRandomlyConsumeEffect.apply` for the local player.
|
||||
pub(super) fn teleport_randomly(&mut self, teleport: &TeleportConsume) {
|
||||
if self.player.is_none() {
|
||||
return;
|
||||
}
|
||||
let dim = self.dim;
|
||||
let Ok(_) = teleport.apply(&mut Teleporter(self), dim);
|
||||
}
|
||||
/// `LivingEntity.randomTeleport(x, y, z, true, avoid)`: down to the first
|
||||
/// block entities can teleport onto, inside the border, in a loaded chunk.
|
||||
fn random_teleport(&mut self, target: Vec3, avoid: &str) -> bool {
|
||||
let [min_x, min_z, max_x, max_z] = self.border.bounds();
|
||||
// WorldBorder.clampVec3ToBound (Mth.clamp, 1.0E-5F inside the far edge).
|
||||
let clamp = |v: f64, low: f64, high: f64| if v < low { low } else { v.min(high) };
|
||||
let x = clamp(target.x, min_x, max_x - f64::from(1.0e-5_f32));
|
||||
let z = clamp(target.z, min_z, max_z - f64::from(1.0e-5_f32));
|
||||
let mut y = target.y;
|
||||
let mut pos = BlockPos::containing(Vec3::new(x, y, z));
|
||||
if !self.world.loaded(pos.x, pos.z) {
|
||||
return false;
|
||||
}
|
||||
while pos.y > self.dim.min_y() {
|
||||
pos.y -= 1;
|
||||
let state = self.world.block(pos.x, pos.y, pos.z);
|
||||
if self.state_in_tag("minecraft:entities_can_teleport_to", state) {
|
||||
return self.check_position_and_teleport(Vec3::new(x, y, z), state, avoid);
|
||||
}
|
||||
y -= 1.0;
|
||||
}
|
||||
false
|
||||
}
|
||||
/// `LivingEntity.checkPositionAndTeleport`, then `ServerPlayer.teleportTo`
|
||||
/// (the motion and rotation kept) and entity event 46.
|
||||
fn check_position_and_teleport(
|
||||
&mut self,
|
||||
at: Vec3,
|
||||
ground: horizon_world::registry::BlockStateId,
|
||||
avoid: &str,
|
||||
) -> bool {
|
||||
if self.state_in_tag(avoid, ground) {
|
||||
return false;
|
||||
}
|
||||
let entities = self.happy_ghast_player_collisions();
|
||||
let Some(player) = self.player.as_mut() else {
|
||||
return false;
|
||||
};
|
||||
let bounds = player.dimensions.bounds(at);
|
||||
let free = horizon_client::motion::MotionWorld {
|
||||
entities: &entities,
|
||||
player,
|
||||
scene: &mut self.world,
|
||||
assets: &self.pack.assets,
|
||||
collision_binding: self.collision,
|
||||
resources: self.motion,
|
||||
}
|
||||
.no_player_collision(bounds)
|
||||
.unwrap_or(false);
|
||||
// LevelReader.containsAnyLiquid and findBlocksIn: the blocks from the
|
||||
// box's minimum corner to the one holding its maximum corner.
|
||||
let (lo, hi) = (
|
||||
BlockPos::containing(bounds.min_position()),
|
||||
BlockPos::containing(bounds.max_position()),
|
||||
);
|
||||
let blocks = (lo.x..=hi.x)
|
||||
.flat_map(|x| (lo.y..=hi.y).flat_map(move |y| (lo.z..=hi.z).map(move |z| (x, y, z))));
|
||||
let states: Vec<_> = blocks.map(|(x, y, z)| self.world.block(x, y, z)).collect();
|
||||
let liquid = states
|
||||
.iter()
|
||||
.any(|&s| self.res.facts().get(s).fluid != horizon_client::blocks::Fluid::None);
|
||||
if !free || liquid || states.iter().any(|&s| self.state_in_tag(avoid, s)) {
|
||||
return false;
|
||||
}
|
||||
if let Some(p) = self.player.as_mut() {
|
||||
p.position = at;
|
||||
}
|
||||
// The position packet moves the old position along (absolute xyz).
|
||||
self.previous_position = at;
|
||||
self.portal_particles();
|
||||
true
|
||||
}
|
||||
fn state_in_tag(&self, tag: &str, state: horizon_world::registry::BlockStateId) -> bool {
|
||||
let name = &self.res.facts().get(state).name;
|
||||
self.res
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag)
|
||||
.is_some_and(|s| s.contains(&**name))
|
||||
}
|
||||
/// `LivingEntity.handleEntityEvent(46)`: 128 portal particles from the old
|
||||
/// to the new position, from the client player's random (the particle
|
||||
/// engine's here).
|
||||
fn portal_particles(&mut self) {
|
||||
let Some(p) = self.player.as_ref() else {
|
||||
return;
|
||||
};
|
||||
let (from, to) = (self.previous_position, p.position);
|
||||
let (width, height) = (
|
||||
f64::from(p.dimensions.width),
|
||||
f64::from(p.dimensions.height),
|
||||
);
|
||||
let options = ParticleOptions::simple(ParticleType::Portal);
|
||||
for i in 0..128 {
|
||||
let d = f64::from(i) / 127.0;
|
||||
let r = self.particles.random();
|
||||
let v = [0; 3].map(|_| f64::from((r.next_float() - 0.5) * 0.2));
|
||||
let x = from.x + d * (to.x - from.x) + (r.next_double() - 0.5) * width * 2.0;
|
||||
let y = from.y + d * (to.y - from.y) + r.next_double() * height;
|
||||
let z = from.z + d * (to.z - from.z) + (r.next_double() - 0.5) * width * 2.0;
|
||||
self.particles.add(&options, [x, y, z], v);
|
||||
}
|
||||
}
|
||||
/// `LivingEntity.stopRiding`.
|
||||
pub(super) fn stop_riding(&mut self) {
|
||||
let Some(id) = self.riding else {
|
||||
return;
|
||||
};
|
||||
if let Some(i) = self.boats.iter().position(|b| b.id == id) {
|
||||
self.dismount(i);
|
||||
} else if let Some(i) = self.carts.iter().position(|c| c.id == id) {
|
||||
self.dismount_cart(i);
|
||||
} else {
|
||||
self.dismount_mount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `Consumable.emitParticlesAndSounds` against the local player.
|
||||
struct Emitter<'a, 'g>(&'a mut Game<'g>);
|
||||
impl EmissionWorld for Emitter<'_, '_> {
|
||||
type Error = Infallible;
|
||||
type Stack = ItemStack;
|
||||
type Sound = String;
|
||||
type Random = ();
|
||||
type Source = LegacyRandom;
|
||||
fn random_source(&mut self, (): ()) -> &mut LegacyRandom {
|
||||
&mut self.0.world.random
|
||||
}
|
||||
/// `LivingEntity.spawnItemParticles`.
|
||||
fn spawn_item_particles(&mut self, stack: ItemStack, count: i32) -> Result<(), Infallible> {
|
||||
self.0.eat_particles(&stack, count.max(0) as u32);
|
||||
Ok(())
|
||||
}
|
||||
fn overrides_consume_sound(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn consume_sound(&mut self, _: ItemStack) -> Result<String, Infallible> {
|
||||
unreachable!("players play the consumable's own sound")
|
||||
}
|
||||
/// `Entity.playSound`: at the player's position.
|
||||
fn play_sound(&mut self, sound: String, volume: f32, pitch: f32) -> Result<(), Infallible> {
|
||||
let at = self.0.feet();
|
||||
self.0.audio.play(&sound, at, volume, pitch);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// The local player as `TeleportRandomlyConsumeEffect`'s user.
|
||||
struct Teleporter<'a, 'g>(&'a mut Game<'g>);
|
||||
impl Teleporter<'_, '_> {
|
||||
fn at(&self) -> Vec3 {
|
||||
self.0.player.as_ref().map_or(Vec3::ZERO, |p| p.position)
|
||||
}
|
||||
}
|
||||
impl TeleportConsumeWorld for Teleporter<'_, '_> {
|
||||
type Error = Infallible;
|
||||
type Level = Dim;
|
||||
type Random = ();
|
||||
type Source = LegacyRandom;
|
||||
fn position_field(&self) -> Vec3 {
|
||||
self.at()
|
||||
}
|
||||
fn get_random(&mut self) -> Result<(), Infallible> {
|
||||
Ok(())
|
||||
}
|
||||
fn random_source(&mut self, (): ()) -> &mut LegacyRandom {
|
||||
&mut self.0.world.random
|
||||
}
|
||||
fn min_y(&mut self, level: Dim) -> Result<i32, Infallible> {
|
||||
Ok(level.min_y())
|
||||
}
|
||||
fn logical_height(&mut self, level: Dim) -> Result<i32, Infallible> {
|
||||
Ok(level.logical_height())
|
||||
}
|
||||
fn is_passenger(&mut self) -> Result<bool, Infallible> {
|
||||
Ok(self.0.riding.is_some())
|
||||
}
|
||||
fn stop_riding(&mut self) -> Result<(), Infallible> {
|
||||
self.0.stop_riding();
|
||||
Ok(())
|
||||
}
|
||||
fn position(&mut self) -> Result<Vec3, Infallible> {
|
||||
Ok(self.at())
|
||||
}
|
||||
fn random_teleport(&mut self, target: Vec3) -> Result<bool, Infallible> {
|
||||
Ok(self
|
||||
.0
|
||||
.random_teleport(target, "minecraft:consumable_does_not_teleport_to"))
|
||||
}
|
||||
fn teleport_event(&mut self, _: Dim, old: Vec3) -> Result<(), Infallible> {
|
||||
let ctx = self.0.who_context(Some(Who::Player), None);
|
||||
self.0
|
||||
.post_game_event("minecraft:teleport", [old.x, old.y, old.z], ctx);
|
||||
Ok(())
|
||||
}
|
||||
fn is_fox(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn teleport_sound(&mut self, _: Dim, at: Vec3, _: bool) -> Result<(), Infallible> {
|
||||
self.0.audio.play(
|
||||
"minecraft:item.chorus_fruit.teleport",
|
||||
Some([at.x, at.y, at.z]),
|
||||
1.0,
|
||||
1.0,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
fn block_position(&mut self) -> Result<BlockPos, Infallible> {
|
||||
Ok(BlockPos::containing(self.at()))
|
||||
}
|
||||
fn directional_particles(
|
||||
&mut self,
|
||||
_: Dim,
|
||||
origin: BlockPos,
|
||||
offset: i32,
|
||||
) -> Result<(), Infallible> {
|
||||
self.0
|
||||
.level_event_at(2017, [origin.x, origin.y, origin.z], offset);
|
||||
Ok(())
|
||||
}
|
||||
fn reset_fall_distance(&mut self) -> Result<(), Infallible> {
|
||||
if let Some(p) = self.0.player.as_mut() {
|
||||
p.fall_distance = 0.0;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn reset_impulse(&mut self) -> Result<(), Infallible> {
|
||||
if let Some(p) = self.0.player.as_mut() {
|
||||
p.impulse.reset();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -54,12 +54,23 @@ pub struct Flight {
|
||||
/// Reply with every frame time too (`fly ... PITCH raw`).
|
||||
raw: bool,
|
||||
reply: Sender<String>,
|
||||
/// The world's smoothed tick time each frame (the F3 server line): the
|
||||
/// server thread's when single player runs on one.
|
||||
tick_ms: Vec<f32>,
|
||||
}
|
||||
|
||||
impl Game<'_> {
|
||||
/// Move the camera along the running flight; reply when it ends.
|
||||
pub(super) fn advance_flight(&mut self) {
|
||||
let Some(flight) = &self.flight else { return };
|
||||
let tick_ms = self
|
||||
.integrated
|
||||
.as_ref()
|
||||
.map_or(self.debug_charts.smoothed_tick_ms, |s| s.smoothed_tick_ms());
|
||||
let Some(flight) = self.flight.as_mut() else {
|
||||
return;
|
||||
};
|
||||
flight.tick_ms.push(tick_ms);
|
||||
let flight = &*flight;
|
||||
let t = (flight.started.elapsed().as_secs_f64() / flight.seconds).min(1.0);
|
||||
let (a, b) = (flight.from, flight.to);
|
||||
let d = [b.x - a.x, b.y - a.y, b.z - a.z];
|
||||
@@ -79,6 +90,9 @@ impl Game<'_> {
|
||||
&& let Some(flight) = self.flight.take()
|
||||
{
|
||||
let mut summary = self.frame_stats.summary();
|
||||
let n = flight.tick_ms.len().max(1) as f32;
|
||||
summary["tick_ms"] = (flight.tick_ms.iter().sum::<f32>() / n).into();
|
||||
summary["tick_ms_max"] = flight.tick_ms.iter().copied().fold(0.0, f32::max).into();
|
||||
if flight.raw {
|
||||
summary["frame_ms"] = self.frame_stats.frame_millis().into();
|
||||
summary["cpu_ms"] = self.frame_stats.cpu_millis().into();
|
||||
@@ -183,6 +197,16 @@ impl Game<'_> {
|
||||
}
|
||||
Ok(Some(json!({ "ok": true, "flat": r.flat_draws() })))
|
||||
}
|
||||
"section-cull" => {
|
||||
let r = self.renderer.as_mut().ok_or("no renderer")?;
|
||||
match words.get(1).copied() {
|
||||
None => {}
|
||||
Some("on") => r.set_section_cull(true)?,
|
||||
Some("off") => r.set_section_cull(false)?,
|
||||
Some(other) => return Err(format!("unknown section cull mode {other}").into()),
|
||||
}
|
||||
Ok(Some(json!({ "ok": true, "cull": r.section_cull() })))
|
||||
}
|
||||
"sculk" => Ok(Some(self.sculk_command(&words)?)),
|
||||
"status" => Ok(Some(self.control_status())),
|
||||
"pad" => Ok(Some(self.pad_command(&words)?)),
|
||||
@@ -345,10 +369,18 @@ impl Game<'_> {
|
||||
};
|
||||
let info = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&item)
|
||||
.ok_or_else(|| format!("unknown item {item}"))?;
|
||||
let count: u32 = words.get(2).map_or(Ok(1), |c| c.parse())?;
|
||||
// Single player's inventory is its server thread's player's.
|
||||
if let Some(server) = &self.integrated {
|
||||
let command = format!("give @s {item} {count}");
|
||||
server
|
||||
.call(move |g| g.owner_console_command(&command))
|
||||
.ok_or("the integrated server stopped")?;
|
||||
return Ok(Some(json!({ "ok": true, "given": count })));
|
||||
}
|
||||
let max = info.max_stack;
|
||||
let mut given = 0;
|
||||
// Stop once the inventory is full.
|
||||
@@ -379,7 +411,14 @@ impl Game<'_> {
|
||||
ok()
|
||||
}
|
||||
"time" => {
|
||||
self.world.day_time = arg(1)?.parse()?;
|
||||
let time: i64 = arg(1)?.parse()?;
|
||||
self.world.day_time = time;
|
||||
// Single player's clock is its server thread's.
|
||||
if let Some(server) = &self.integrated {
|
||||
server
|
||||
.call(move |g| g.world.day_time = time)
|
||||
.ok_or("the integrated server stopped")?;
|
||||
}
|
||||
ok()
|
||||
}
|
||||
"summon" => {
|
||||
@@ -437,7 +476,7 @@ impl Game<'_> {
|
||||
match self.screen {
|
||||
Screen::Chat => self.chat_type(text),
|
||||
Screen::CommandBlock => self.command_block_type(text),
|
||||
Screen::Options => self.ui.options.type_text(&self.atlas, text),
|
||||
Screen::Options => self.ui.options.type_text(&self.gui.atlas, text),
|
||||
// The port, or the game rules' search and number boxes.
|
||||
Screen::WorldOptions if text == "\\b" => self.world_options_text(None),
|
||||
Screen::WorldOptions => self.world_options_text(Some(text)),
|
||||
@@ -527,6 +566,7 @@ impl Game<'_> {
|
||||
seconds: n(7)?.max(0.1),
|
||||
raw: words.get(9) == Some(&"raw"),
|
||||
reply: reply.clone(),
|
||||
tick_ms: Vec::new(),
|
||||
});
|
||||
Ok(None)
|
||||
}
|
||||
@@ -661,7 +701,7 @@ impl Game<'_> {
|
||||
});
|
||||
let target = self.pick().map(|hit| {
|
||||
let state = self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]);
|
||||
json!({ "pos": hit.pos, "block": &*self.res.facts.get(state).name })
|
||||
json!({ "pos": hit.pos, "block": &*self.res.facts().get(state).name })
|
||||
});
|
||||
let renderer = self.renderer.as_ref().map(|r| {
|
||||
let [arena_bytes, section_vertex_bytes] = r.section_vertex_bytes();
|
||||
@@ -684,6 +724,7 @@ impl Game<'_> {
|
||||
"drawn_sections": r.drawn_sections,
|
||||
"section_draws": r.section_draws,
|
||||
"section_draw_calls": r.section_draw_calls,
|
||||
"culled_sections": r.culled_sections(),
|
||||
"uploaded_bytes": r.uploaded_bytes,
|
||||
"resident_sections": r.resident_sections(),
|
||||
"arena_bytes": arena_bytes,
|
||||
|
||||
@@ -106,7 +106,7 @@ impl Game<'_> {
|
||||
fn golem_chest_sound(&mut self, p: [i32; 3], open: bool) {
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone();
|
||||
@@ -292,7 +292,7 @@ impl Game<'_> {
|
||||
pub(super) fn golem_shearable(&self, index: usize) -> bool {
|
||||
self.mobs[index].saddle_item().is_some_and(|a| {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get("minecraft:shearable_from_copper_golem")
|
||||
.is_some_and(|t| t.contains(&*a.item))
|
||||
|
||||
@@ -110,7 +110,7 @@ impl Game<'_> {
|
||||
let mut next_entity = self.next_entity;
|
||||
let mut random = self.world.random.clone();
|
||||
let spawning = self.spawning_monsters();
|
||||
let creaking = self.res.mob_types.get("minecraft:creaking").cloned();
|
||||
let creaking = self.res.mob_types().get("minecraft:creaking").cloned();
|
||||
let player_uuid = self.level.player_uuid;
|
||||
let snapshot: Vec<_> = mobs.iter().map(|m| seen(m, player_uuid)).collect();
|
||||
let mut events = Vec::new();
|
||||
@@ -220,6 +220,12 @@ impl Game<'_> {
|
||||
/// death and a natural heart drops experience.
|
||||
pub(super) fn creaking_heart_broken(&mut self, pos: [i32; 3]) {
|
||||
let key = (pos[0], pos[1], pos[2]);
|
||||
if !matches!(
|
||||
self.world.block_entities.get(&key),
|
||||
Some(BlockEntity::CreakingHeart(_))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
let Some(BlockEntity::CreakingHeart(mut heart)) = self.world.block_entities.take(&key)
|
||||
else {
|
||||
return;
|
||||
@@ -259,7 +265,7 @@ impl Game<'_> {
|
||||
return Ok(());
|
||||
};
|
||||
let state = self.world.block(key.0, key.1, key.2);
|
||||
if &*self.res.facts.get(state).name != "minecraft:creaking_heart" {
|
||||
if &*self.res.facts().get(state).name != "minecraft:creaking_heart" {
|
||||
// The block is gone: preRemoveSideEffects.
|
||||
self.world.block_entities.forget(&key);
|
||||
self.with_heart(key, &mut heart, |h, _, _, host, out| {
|
||||
@@ -311,7 +317,7 @@ impl Game<'_> {
|
||||
if self.creaking.hearts.is_empty() {
|
||||
self.creaking.hearts = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.states
|
||||
.iter()
|
||||
.map(|f| &*f.name == "minecraft:creaking_heart")
|
||||
|
||||
@@ -204,8 +204,8 @@ impl Game<'_> {
|
||||
let Some(chunk) = self.world.chunks.get(&(x >> 4, z >> 4)) else {
|
||||
return BiomeFacts::default();
|
||||
};
|
||||
let b = self.res.biomes.get(chunk.biome(x, y, z));
|
||||
let tags = &self.res.mob_data;
|
||||
let b = self.res.biomes().get(chunk.biome(x, y, z));
|
||||
let tags = self.res.mob_data();
|
||||
let has = |t: &str| tags.biome_has(t, &b.name);
|
||||
let climate = if has("minecraft:spawns_warm_variant_farm_animals") {
|
||||
Climate::Warm
|
||||
@@ -255,7 +255,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
format!("minecraft:{kind}")
|
||||
};
|
||||
let t = self.res.mob_types.get(&kind).cloned()?;
|
||||
let t = self.res.mob_types().get(&kind).cloned()?;
|
||||
self.next_entity += 1;
|
||||
let yaw = self.world.random.next_float() * 360.0;
|
||||
let mut mob = Mob::new(self.next_entity, t, Vec3::new(at[0], at[1], at[2]), yaw);
|
||||
@@ -368,7 +368,7 @@ impl Game<'_> {
|
||||
pub(super) fn motion_top(&self, x: i32, z: i32) -> i32 {
|
||||
let top = if self.dim == Dim::Nether { 127 } else { 319 };
|
||||
for y in (horizon_client::chunk::MIN_Y..=top).rev() {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if (f.full_collision || f.fluid != Fluid::None) && !f.name.ends_with("leaves") {
|
||||
return y + 1;
|
||||
}
|
||||
@@ -377,14 +377,16 @@ impl Game<'_> {
|
||||
}
|
||||
pub(super) fn mob_world_base<'s>(&'s self, others: &'s [Seen]) -> MobWorld<'s> {
|
||||
let (rain, thunder) = self.world.weather.levels(1.0);
|
||||
let player = self.player_view();
|
||||
MobWorld {
|
||||
world: &self.world,
|
||||
registry: self.pack.assets.registry,
|
||||
facts: &self.res.facts,
|
||||
facts: self.res.facts(),
|
||||
movement: &self.motion.blocks,
|
||||
collision: self.collision,
|
||||
data: &self.res.mob_data,
|
||||
player: self.player_view(),
|
||||
data: self.res.mob_data(),
|
||||
nearest_player: player.as_ref().filter(|p| !p.spectator).map(|p| p.position),
|
||||
player,
|
||||
others,
|
||||
others_grid: None,
|
||||
daylight: self.dim != Dim::Nether && self.sky_darken() < 4,
|
||||
@@ -393,14 +395,14 @@ impl Game<'_> {
|
||||
raining: rain > 0.2,
|
||||
thundering: thunder > 0.9,
|
||||
nether: self.dim == Dim::Nether,
|
||||
block_tags: &self.res.items.block_tags,
|
||||
biomes: &self.res.biomes,
|
||||
block_tags: &self.res.items().block_tags,
|
||||
biomes: self.res.biomes(),
|
||||
mob_griefing: self.ui.rules.bool("mob_griefing"),
|
||||
end: self.dim == Dim::End,
|
||||
world_seed: self.level.seed,
|
||||
sea_level: if self.dim == Dim::Nether { 32 } else { 63 },
|
||||
teams: self.mob_teams(),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
difficulty: self.local_difficulty(
|
||||
self.player
|
||||
.as_ref()
|
||||
@@ -429,25 +431,6 @@ impl Game<'_> {
|
||||
};
|
||||
spawning::LocalDifficulty::new(base, self.world.day_time, inhabited, moon)
|
||||
}
|
||||
/// `ServerChunkCache.tickSpawningChunk`: chunks whose centre is within
|
||||
/// 128 blocks of the player gain inhabited time.
|
||||
fn tick_inhabited(&mut self) {
|
||||
let Some(p) = self.player.as_ref().map(|p| p.position) else {
|
||||
return;
|
||||
};
|
||||
let (pcx, pcz) = (p.x.floor() as i32 >> 4, p.z.floor() as i32 >> 4);
|
||||
for dx in -8..=8 {
|
||||
for dz in -8..=8 {
|
||||
let key = (pcx + dx, pcz + dz);
|
||||
let (cx, cz) = (f64::from(key.0 * 16 + 8), f64::from(key.1 * 16 + 8));
|
||||
if (cx - p.x).powi(2) + (cz - p.z).powi(2) < 128.0 * 128.0
|
||||
&& self.world.chunks.contains_key(&key)
|
||||
{
|
||||
*self.world.inhabited.entry(key).or_insert(0) += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Advance every mob one tick, then apply their events.
|
||||
pub(super) fn tick_creatures(&mut self) -> Result<()> {
|
||||
self.attack_ticks = self.attack_ticks.saturating_add(1);
|
||||
@@ -464,7 +447,6 @@ impl Game<'_> {
|
||||
}
|
||||
self.spawn_generation_creatures(key.0, key.1);
|
||||
}
|
||||
self.tick_inhabited();
|
||||
self.tick_leads();
|
||||
self.spawn_natural();
|
||||
// ServerChunkCache.tickChunks: the custom spawners tick only with spawn_mobs.
|
||||
@@ -475,24 +457,11 @@ impl Game<'_> {
|
||||
self.tick_raids();
|
||||
self.tick_creature_entities()
|
||||
}
|
||||
/// `DistanceManager.inEntityTickingRange`: chunks within the simulation
|
||||
/// distance (Chebyshev, in chunks) of the player or of a guest.
|
||||
/// `DistanceManager.inEntityTickingRange` in an entity-ticking chunk
|
||||
/// (block coordinates), from every player's tickets (`update_chunk_tickets`).
|
||||
pub(super) fn entity_ticking_area(&self) -> impl Fn(i32, i32) -> bool + use<> {
|
||||
let d = self.settings.simulation_distance.max(2);
|
||||
let mut centres: Vec<(i32, i32)> = self.streaming.extra.iter().map(|&(c, _)| c).collect();
|
||||
if let Some(p) = &self.player {
|
||||
centres.push((
|
||||
(p.position.x.floor() as i32) >> 4,
|
||||
(p.position.z.floor() as i32) >> 4,
|
||||
));
|
||||
}
|
||||
let everywhere = centres.is_empty();
|
||||
move |x, z| {
|
||||
everywhere
|
||||
|| centres
|
||||
.iter()
|
||||
.any(|&(cx, cz)| ((x >> 4) - cx).abs().max(((z >> 4) - cz).abs()) <= d)
|
||||
}
|
||||
let levels = self.tickets.levels();
|
||||
move |x, z| levels.entity_ticking_at(x, z)
|
||||
}
|
||||
/// The entity phase of `tick_creatures`: every mob's tick, deaths, and the
|
||||
/// projectiles and effects that follow from them.
|
||||
@@ -518,6 +487,7 @@ impl Game<'_> {
|
||||
let ticking = self.entity_ticking_area();
|
||||
// With guests on, each mob sees its nearest player (game/lan_mobs.rs).
|
||||
let guests = self.lan_guest_views();
|
||||
let players = self.level_players();
|
||||
let mut bindings = match self.lan.as_mut() {
|
||||
Some(host) if !guests.is_empty() => std::mem::take(&mut host.mob_players),
|
||||
_ => Default::default(),
|
||||
@@ -536,6 +506,13 @@ impl Game<'_> {
|
||||
let mut w = self.mob_world_base(&snapshot);
|
||||
w.others_grid = Some(&grid);
|
||||
let m = &mut mobs[i];
|
||||
w.nearest_player = super::natural_spawning::nearest_player(
|
||||
&players,
|
||||
m.position.x,
|
||||
m.position.y,
|
||||
m.position.z,
|
||||
)
|
||||
.map(|p| p.position);
|
||||
let seen_guest = if guests.is_empty() {
|
||||
None
|
||||
} else {
|
||||
@@ -984,7 +961,7 @@ impl Game<'_> {
|
||||
if effect {
|
||||
let old = self.world.block(pos[0], pos[1], pos[2]);
|
||||
self.destroy_particles(pos, old);
|
||||
let s = self.res.facts.get(old).sounds.break_sound.clone();
|
||||
let s = self.res.facts().get(old).sounds.break_sound.clone();
|
||||
self.audio.play(
|
||||
&s,
|
||||
Some([
|
||||
@@ -1004,7 +981,7 @@ impl Game<'_> {
|
||||
let old = self.world.block(pos[0], pos[1], pos[2]);
|
||||
self.destroy_particles(pos, old);
|
||||
if drop {
|
||||
let drops = self.res.items.block_drops_in(
|
||||
let drops = self.res.items().block_drops_in(
|
||||
self.pack.assets.registry,
|
||||
old,
|
||||
None,
|
||||
@@ -1158,7 +1135,7 @@ impl Game<'_> {
|
||||
MobEvent::GiftLoot { table, at } => {
|
||||
let drops =
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(table, false, None, &mut self.world.random);
|
||||
for d in drops {
|
||||
self.spawn_item(d, at, [0.0, 0.2, 0.0], 10);
|
||||
@@ -1421,7 +1398,7 @@ impl Game<'_> {
|
||||
}
|
||||
let projectile = self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.damage_tags
|
||||
.get("minecraft:is_projectile")
|
||||
@@ -1781,7 +1758,7 @@ impl Game<'_> {
|
||||
horizon_client::arrows::ArrowScene {
|
||||
world: &self.world,
|
||||
registry: self.pack.assets.registry,
|
||||
facts: &self.res.facts,
|
||||
facts: self.res.facts(),
|
||||
collision: self.collision,
|
||||
fluids: &self.motion.fluids,
|
||||
raining: rain,
|
||||
@@ -2033,7 +2010,7 @@ impl Game<'_> {
|
||||
let fire = [pos[0] + face[0], pos[1] + face[1], pos[2] + face[2]];
|
||||
if self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.world.block(fire[0], fire[1], fire[2]))
|
||||
&& let Some(state) =
|
||||
self.pack.assets.registry.default_state("minecraft:fire")
|
||||
@@ -2359,7 +2336,7 @@ impl Game<'_> {
|
||||
Species::Sheep if item == "minecraft:shears" && !m.extra.sheared && !m.is_baby() => {
|
||||
m.extra.sheared = true;
|
||||
let color = horizon_client::mobs::render::DYE_NAMES[m.extra.color as usize & 15];
|
||||
let stacks = self.res.items.loot_table(
|
||||
let stacks = self.res.items().loot_table(
|
||||
&format!("minecraft:shearing/sheep/{color}"),
|
||||
false,
|
||||
None,
|
||||
@@ -2391,7 +2368,7 @@ impl Game<'_> {
|
||||
Species::Wolf if m.extra.tame && is_food && m.health < m.attrs.max_health => {
|
||||
let heal = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&item)
|
||||
.and_then(|i| i.food.as_ref())
|
||||
.map_or(2.0, |f| f.0 as f32);
|
||||
@@ -2495,7 +2472,7 @@ impl Game<'_> {
|
||||
Species::Cat if m.extra.tame && is_food && m.health < m.attrs.max_health => {
|
||||
let heal = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&item)
|
||||
.and_then(|i| i.food.as_ref())
|
||||
.map_or(1.0, |f| f.0 as f32);
|
||||
@@ -2662,7 +2639,7 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
if let Some(stack) = self.inventory[self.selected].as_mut()
|
||||
&& let Some(info) = self.res.items.get(&stack.item)
|
||||
&& let Some(info) = self.res.items().get(&stack.item)
|
||||
&& info.max_damage > 0
|
||||
{
|
||||
stack.damage += 1;
|
||||
@@ -2735,7 +2712,7 @@ impl Game<'_> {
|
||||
// EntityType.canSpawn: no monsters in peaceful (FAIL ends the click).
|
||||
let id = format!("minecraft:{}", kind.trim_start_matches("minecraft:"));
|
||||
if self.ui.difficulty == 0
|
||||
&& let Some(t) = self.res.mob_types.get(&id)
|
||||
&& let Some(t) = self.res.mob_types().get(&id)
|
||||
&& !horizon_client::mobs::spawn_rules::allowed_in_peaceful(t.species)
|
||||
{
|
||||
return Ok(true);
|
||||
@@ -2799,7 +2776,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Mob models and projectiles for the entity pass.
|
||||
pub(super) fn mob_geometry(&self, camera: glam::DVec3, alpha: f64, out: &mut Vec<Vertex>) {
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let lookup = |name: &str| atlas.sprites.get(name).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
let scale = f64::from(self.settings.entity_distance);
|
||||
for mob in &self.mobs {
|
||||
@@ -2857,7 +2834,7 @@ impl Game<'_> {
|
||||
camera,
|
||||
&lookup,
|
||||
packed,
|
||||
&self.res.mob_data,
|
||||
self.res.mob_data(),
|
||||
&armor,
|
||||
out,
|
||||
);
|
||||
@@ -3016,7 +2993,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// Mob.getBaseExperienceReward
|
||||
/// The damage type id of a Horizon damage kind.
|
||||
fn damage_type(kind: horizon_client::mobs::DamageKind, player: bool) -> &'static str {
|
||||
pub(super) fn damage_type(kind: horizon_client::mobs::DamageKind, player: bool) -> &'static str {
|
||||
use horizon_client::mobs::DamageKind as K;
|
||||
match kind {
|
||||
K::PlayerAttack => "minecraft:player_attack",
|
||||
@@ -3101,13 +3078,17 @@ impl Game<'_> {
|
||||
return;
|
||||
}
|
||||
let mut y = pos[1];
|
||||
while &*self.res.facts.get(self.world.block(pos[0], y, pos[2])).name
|
||||
while &*self
|
||||
.res
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], y, pos[2]))
|
||||
.name
|
||||
== "minecraft:nether_portal"
|
||||
{
|
||||
y -= 1;
|
||||
}
|
||||
// isValidSpawn: a sturdy top face (portal frames emit no light).
|
||||
let below = self.res.facts.get(self.world.block(pos[0], y, pos[2]));
|
||||
let below = self.res.facts().get(self.world.block(pos[0], y, pos[2]));
|
||||
if below.sturdy_full & (1 << 1) == 0 {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,9 @@ impl DebugHost for Host<'_, '_> {
|
||||
|
||||
impl Game<'_> {
|
||||
fn open_screen(&self) -> OpenScreen {
|
||||
if self.title.is_some() {
|
||||
return OpenScreen::Other;
|
||||
}
|
||||
match self.screen {
|
||||
Screen::GameModeSwitcher => OpenScreen::GameModeSwitcher,
|
||||
Screen::Playing if self.book.is_none() && self.sign_edit.is_none() => OpenScreen::None,
|
||||
@@ -437,7 +440,7 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
let (left, right) = d.columns(&self.debug_chart_lines());
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
let mut draws = debug_overlay::draw(&atlas.font, [&left, &right], scale, width);
|
||||
let charts = self.debug_charts.draw(
|
||||
&atlas.font,
|
||||
|
||||
@@ -63,7 +63,7 @@ impl Game<'_> {
|
||||
/// pot without), or None when no pot is there.
|
||||
fn pot_tag(&mut self, pos: [i32; 3]) -> Option<Tag> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if &*self.res.facts.get(state).name != "minecraft:decorated_pot" {
|
||||
if &*self.res.facts().get(state).name != "minecraft:decorated_pot" {
|
||||
return None;
|
||||
}
|
||||
let mut tag = spill::saved_entity(&self.world, pos).unwrap_or_else(|| {
|
||||
|
||||
@@ -11,9 +11,7 @@ use horizon_client::{
|
||||
Result,
|
||||
lan::{LoginGate, NetConfig, NetLog, OnlineMode, hub::HubConfig},
|
||||
server::{
|
||||
eula,
|
||||
java_properties::now_millis,
|
||||
profiles,
|
||||
eula, profiles,
|
||||
properties::{GAME_MODES, ServerProperties, SystemEntropy},
|
||||
user_cache::UserCache,
|
||||
user_lists::{
|
||||
@@ -84,18 +82,16 @@ fn log_from(thread: &str, level: &str, message: &str) {
|
||||
"ERROR" => ::log::Level::Error,
|
||||
_ => ::log::Level::Info,
|
||||
};
|
||||
horizon_client::logging::write_only(file_level, message);
|
||||
horizon_client::logging::write_as(thread, file_level, message);
|
||||
CAPTURE.with_borrow_mut(|lines| {
|
||||
if let Some(lines) = lines {
|
||||
lines.push(message.to_owned());
|
||||
}
|
||||
});
|
||||
let secs = now_millis().div_euclid(1000).rem_euclid(86_400);
|
||||
// Log4j's %d{HH:mm:ss}: the local time, as in logs/latest.log.
|
||||
println!(
|
||||
"[{:02}:{:02}:{:02}] [{thread}/{level}]: {message}",
|
||||
secs / 3600,
|
||||
secs / 60 % 60,
|
||||
secs % 60
|
||||
"[{}] [{thread}/{level}]: {message}",
|
||||
chrono::Local::now().format("%H:%M:%S")
|
||||
);
|
||||
}
|
||||
|
||||
@@ -340,7 +336,7 @@ impl Game<'_> {
|
||||
);
|
||||
}
|
||||
let settings = if flat {
|
||||
let biomes = &self.res.biomes;
|
||||
let biomes = self.res.biomes();
|
||||
let (settings, errors) = horizon_client::flatgen::settings_from_json(
|
||||
&props.generator_settings,
|
||||
|b| self.pack.assets.registry.default_state(b).is_some(),
|
||||
@@ -431,6 +427,7 @@ const BROADCAST: &[&str] = &[
|
||||
impl Game<'_> {
|
||||
/// DedicatedServer.initServer and MinecraftServer.runServer.
|
||||
pub(super) fn run_dedicated(&mut self) -> Result<()> {
|
||||
self.join_world_rest()?;
|
||||
let Setup {
|
||||
props,
|
||||
universe,
|
||||
@@ -683,7 +680,7 @@ impl Game<'_> {
|
||||
self.ticks = self.ticks.max(1);
|
||||
}
|
||||
// MinecraftServer.tickServer: while paused only the connections run.
|
||||
self.tick_server(paused)?;
|
||||
self.tick_server_timed(paused)?;
|
||||
if idle_timeout > 0 {
|
||||
self.kick_idle(idle_timeout);
|
||||
}
|
||||
@@ -829,6 +826,7 @@ impl Game<'_> {
|
||||
self.console_command(state, line);
|
||||
self.console_broadcast = None;
|
||||
if let Some(mut host) = self.lan.take() {
|
||||
self.run_level_teleports(&mut host);
|
||||
self.send_admin_feedback(&mut host, None);
|
||||
self.lan = Some(host);
|
||||
}
|
||||
|
||||
@@ -114,9 +114,9 @@ impl Game<'_> {
|
||||
}
|
||||
|
||||
fn fixture_reset(&mut self, seed: i64) {
|
||||
self.world = World::new(self.res.facts.air, seed);
|
||||
self.world = World::new(self.res.facts().air, seed);
|
||||
// The oracle level is plains everywhere (bone meal's flowers, freezing).
|
||||
let plains = u32::from(self.res.biomes.id("minecraft:plains"));
|
||||
let plains = u32::from(self.res.biomes().id("minecraft:plains"));
|
||||
for cx in -2..=2 {
|
||||
for cz in -2..=2 {
|
||||
let mut chunk = Chunk::empty(cx, cz);
|
||||
@@ -198,7 +198,7 @@ impl Game<'_> {
|
||||
let state = BlockStateId(cell[3].as_u64().unwrap_or(0) as u32);
|
||||
self.world.set(p.0, p.1, p.2, state)?;
|
||||
before.insert(p, state.0);
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts.get(state).name) {
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts().get(state).name) {
|
||||
self.world.block_entities.insert(p, entity);
|
||||
}
|
||||
}
|
||||
@@ -284,7 +284,7 @@ impl Game<'_> {
|
||||
let state = self.world.block(origin.x, origin.y, origin.z);
|
||||
let mut used = Vec::new();
|
||||
if let Some(op) = case.get("remove") {
|
||||
self.fixture_remove(origin, op)?;
|
||||
used = self.fixture_remove(origin, op)?;
|
||||
} else if let Some(op) = case.get("use") {
|
||||
used = self.fixture_use(origin, op)?;
|
||||
} else if let Some(op) = case.get("use_item") {
|
||||
@@ -339,7 +339,7 @@ impl Game<'_> {
|
||||
changed.dedup();
|
||||
for p in changed {
|
||||
let now = self.world.block(p.0, p.1, p.2).0;
|
||||
if before.get(&p).copied().unwrap_or(self.res.facts.air.0) != now {
|
||||
if before.get(&p).copied().unwrap_or(self.res.facts().air.0) != now {
|
||||
out.push(format!("set {},{},{} {now}", p.0, p.1, p.2));
|
||||
}
|
||||
}
|
||||
@@ -706,7 +706,7 @@ impl Game<'_> {
|
||||
/// lectern's book, or the items of a block entity Horizon keeps as saved.
|
||||
fn fixture_fill(&mut self, p: (i32, i32, i32), slot: usize, stack: Option<ItemStack>) {
|
||||
let jukebox =
|
||||
&*self.res.facts.get(self.world.block(p.0, p.1, p.2)).name == "minecraft:jukebox";
|
||||
&*self.res.facts().get(self.world.block(p.0, p.1, p.2)).name == "minecraft:jukebox";
|
||||
match self.world.block_entities.get_mut(&p) {
|
||||
Some(BlockEntity::Jukebox(j)) => j.record = stack,
|
||||
Some(BlockEntity::Lectern(l)) => l.book = stack,
|
||||
@@ -735,7 +735,7 @@ impl Game<'_> {
|
||||
use horizon_world::nbt::Tag;
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p.0, p.1, p.2))
|
||||
.name
|
||||
.clone();
|
||||
@@ -788,8 +788,9 @@ impl Game<'_> {
|
||||
other => *other = Tag::List(vec![item]),
|
||||
}
|
||||
}
|
||||
/// `Level.setBlock`, `destroyBlock` or `removeBlock` on the case's block.
|
||||
fn fixture_remove(&mut self, origin: BlockPos, op: &Value) -> Result<()> {
|
||||
/// `Level.setBlock`, `destroyBlock` or `removeBlock` on the case's block, or
|
||||
/// a player mining it (`fixture_mine`).
|
||||
fn fixture_remove(&mut self, origin: BlockPos, op: &Value) -> Result<Vec<String>> {
|
||||
match op["op"].as_str().unwrap_or("") {
|
||||
"set" => {
|
||||
let state = BlockStateId(op["state"].as_u64().unwrap_or(0) as u32);
|
||||
@@ -803,9 +804,61 @@ impl Game<'_> {
|
||||
"remove" => {
|
||||
self.with_level(|b, level, ticks| b.remove_block(level, ticks, origin, false));
|
||||
}
|
||||
"mine" => return self.fixture_mine(origin, op),
|
||||
other => return Err(format!("unknown removal {other}").into()),
|
||||
}
|
||||
self.process_level_events()
|
||||
self.process_level_events()?;
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
/// A survival player three blocks south of `pos` mines it holding the
|
||||
/// case's item (`break_block`, which every player's mining goes through):
|
||||
/// the statistics and the held stack, as `VanillaDispenserOracle.mine`
|
||||
/// prints them.
|
||||
fn fixture_mine(&mut self, pos: BlockPos, op: &Value) -> Result<Vec<String>> {
|
||||
let stack = parse_stack(op["item"].as_str().unwrap_or("-"))?;
|
||||
self.mode = GameMode::Survival;
|
||||
self.creative = false;
|
||||
self.player = Some(PlayerMotion::new(
|
||||
self.motion,
|
||||
horizon_core::geometry::Vec3::new(
|
||||
f64::from(pos.x) + 0.5,
|
||||
f64::from(pos.y) + 1.0,
|
||||
f64::from(pos.z) + 3.5,
|
||||
),
|
||||
)?);
|
||||
self.yaw = 0.0;
|
||||
self.pitch = 90.0;
|
||||
self.keys.clear();
|
||||
self.inventory[self.selected] = stack.clone();
|
||||
self.offhand = None;
|
||||
let state = self.world.block(pos.x, pos.y, pos.z);
|
||||
let block = self.res.facts().get(state).name.clone();
|
||||
let item = stack.as_ref().map(|s| s.item.clone());
|
||||
let before = |game: &Self| {
|
||||
let used = item.as_ref().map_or(0, |i| game.stats.get("used", i));
|
||||
(used, game.stats.get("mined", &block))
|
||||
};
|
||||
let (used, mined) = before(self);
|
||||
self.break_block([pos.x, pos.y, pos.z])?;
|
||||
let (used_after, mined_after) = before(self);
|
||||
let mut out = Vec::new();
|
||||
if let Some(item) = &item
|
||||
&& used_after != used
|
||||
{
|
||||
out.push(format!("stat {item} minecraft:used {}", used_after - used));
|
||||
}
|
||||
if mined_after != mined {
|
||||
out.push(format!(
|
||||
"stat {block} minecraft:mined {}",
|
||||
mined_after - mined
|
||||
));
|
||||
}
|
||||
out.push(format!(
|
||||
"mine held {}",
|
||||
canon_stack(self.inventory[self.selected].as_ref())
|
||||
));
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// `EntityType.create` and `snapTo` for one target: no spawn finalization.
|
||||
@@ -829,7 +882,7 @@ impl Game<'_> {
|
||||
}
|
||||
let t = self
|
||||
.res
|
||||
.mob_types
|
||||
.mob_types()
|
||||
.get(kind)
|
||||
.cloned()
|
||||
.ok_or_else(|| format!("no mob type {kind}"))?;
|
||||
|
||||
@@ -328,18 +328,18 @@ impl Game<'_> {
|
||||
self.world.block(p.0, p.1, p.2)
|
||||
}
|
||||
fn dispenser_block_name(&self, p: Pos) -> std::sync::Arc<str> {
|
||||
self.res.facts.get(self.block_at(p)).name.clone()
|
||||
self.res.facts().get(self.block_at(p)).name.clone()
|
||||
}
|
||||
fn in_block_tag(&self, tag: &str, block: &str) -> bool {
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get(tag)
|
||||
.is_some_and(|s| s.contains(block))
|
||||
}
|
||||
fn water_at(&self, p: Pos) -> bool {
|
||||
matches!(
|
||||
self.res.behaviours.fluid_kind(self.block_at(p)),
|
||||
self.res.behaviours().fluid_kind(self.block_at(p)),
|
||||
FluidKind::Water | FluidKind::FlowingWater
|
||||
)
|
||||
}
|
||||
@@ -520,7 +520,7 @@ impl Game<'_> {
|
||||
if let Some(entity) = self.world.block_entities.get_mut(&pos) {
|
||||
let max = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&rest.item)
|
||||
.map_or(64, |i| i.max_stack)
|
||||
.max(1);
|
||||
@@ -555,7 +555,11 @@ impl Game<'_> {
|
||||
}
|
||||
/// `ItemStack.hurtAndBreak(amount)` without an entity.
|
||||
fn hurt_and_break(&mut self, mut stack: ItemStack, amount: u32) -> Option<ItemStack> {
|
||||
let max = self.res.items.get(&stack.item).map_or(0, |i| i.max_damage);
|
||||
let max = self
|
||||
.res
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.map_or(0, |i| i.max_damage);
|
||||
if max == 0 {
|
||||
return Some(stack);
|
||||
}
|
||||
@@ -637,7 +641,7 @@ impl Game<'_> {
|
||||
) -> Result<Dispensed> {
|
||||
let equippable = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&stack.item)
|
||||
.is_some_and(|i| i.equip_slot.is_some());
|
||||
if equippable {
|
||||
@@ -649,7 +653,7 @@ impl Game<'_> {
|
||||
}
|
||||
let swallowable = self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.item_tags
|
||||
.get("minecraft:sulfur_cube_swallowable")
|
||||
.is_some_and(|t| t.contains(&*stack.item));
|
||||
@@ -748,7 +752,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
format!("minecraft:{kind}")
|
||||
};
|
||||
let t = self.res.mob_types.get(&name)?.clone();
|
||||
let t = self.res.mob_types().get(&name)?.clone();
|
||||
let y_off = if try_move_down {
|
||||
self.drop_offset(t.width, t.height, p)
|
||||
} else {
|
||||
@@ -768,7 +772,7 @@ impl Game<'_> {
|
||||
/// `EquipmentDispenseItemBehavior.dispenseEquipment`: the first living
|
||||
/// entity in front that `canEquipWithDispenser` gets one of the item.
|
||||
fn dispense_equipment(&mut self, pos: Pos, facing: Direction, stack: &mut ItemStack) -> bool {
|
||||
let Some(info) = self.res.items.get(&stack.item) else {
|
||||
let Some(info) = self.res.items().get(&stack.item) else {
|
||||
return false;
|
||||
};
|
||||
let (Some(slot), true) = (
|
||||
@@ -1078,7 +1082,7 @@ impl Game<'_> {
|
||||
let below = (front.0, front.1 - 1, front.2);
|
||||
let y_offset = if self.water_at(front) {
|
||||
1.0
|
||||
} else if self.res.facts.is_air(self.block_at(front)) && self.water_at(below) {
|
||||
} else if self.res.facts().is_air(self.block_at(front)) && self.water_at(below) {
|
||||
0.0
|
||||
} else {
|
||||
return (self.dispense_default(pos, facing, stack), CLICK);
|
||||
@@ -1116,7 +1120,7 @@ impl Game<'_> {
|
||||
let y_offset = if let Some(rail) = self.rail(front.0, front.1, front.2) {
|
||||
if rail.shape.is_slope() { 0.6 } else { 0.1 }
|
||||
} else {
|
||||
if !self.res.facts.is_air(self.block_at(front)) {
|
||||
if !self.res.facts().is_air(self.block_at(front)) {
|
||||
return (self.dispense_default(pos, facing, stack), CLICK);
|
||||
}
|
||||
let below = (front.0, front.1 - 1, front.2);
|
||||
@@ -1389,7 +1393,7 @@ impl Game<'_> {
|
||||
stack: ItemStack,
|
||||
) -> Result<Dispensed> {
|
||||
let target = offset(pos, facing);
|
||||
let free = self.res.facts.is_air(self.block_at(target))
|
||||
let free = self.res.facts().is_air(self.block_at(target))
|
||||
&& target.1 >= horizon_client::chunk::MIN_Y + 2
|
||||
&& self.ui.difficulty != 0
|
||||
&& self.can_build_wither(target);
|
||||
@@ -1443,7 +1447,7 @@ impl Game<'_> {
|
||||
"minecraft:soul_sand" | "minecraft:soul_soil"
|
||||
)
|
||||
};
|
||||
let air = |p: Pos| self.res.facts.is_air(self.block_at(p));
|
||||
let air = |p: Pos| self.res.facts().is_air(self.block_at(p));
|
||||
for (ax, az) in [(1, 0), (0, 1)] {
|
||||
for col in 0..3 {
|
||||
let left = (head.0 - ax * col, head.1, head.2 - az * col);
|
||||
@@ -1466,7 +1470,7 @@ impl Game<'_> {
|
||||
stack: ItemStack,
|
||||
) -> Result<Dispensed> {
|
||||
let target = offset(pos, facing);
|
||||
if self.res.facts.is_air(self.block_at(target))
|
||||
if self.res.facts().is_air(self.block_at(target))
|
||||
&& self.can_spawn_golem([target.0, target.1, target.2])
|
||||
{
|
||||
if let Some(pumpkin) = self
|
||||
@@ -1511,7 +1515,7 @@ impl Game<'_> {
|
||||
let front = offset(pos, facing);
|
||||
let below_empty = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.block_at((front.0, front.1 - 1, front.2)));
|
||||
let clicked_face = if below_empty { facing } else { Direction::Up };
|
||||
let ctx = PlaceContext {
|
||||
@@ -1539,7 +1543,7 @@ impl Game<'_> {
|
||||
return Ok((Some(stack), FAIL));
|
||||
};
|
||||
let target = (placed.x, placed.y, placed.z);
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts.get(state).name) {
|
||||
if let Some(entity) = BlockEntity::for_block(&self.res.facts().get(state).name) {
|
||||
self.world.block_entities.insert(target, entity);
|
||||
self.apply_placed_item([target.0, target.1, target.2], &stack, false);
|
||||
}
|
||||
@@ -1689,14 +1693,14 @@ impl Game<'_> {
|
||||
table: &str,
|
||||
held: Option<&ItemStack>,
|
||||
) -> Vec<ItemStack> {
|
||||
match self.res.items.loot_sequence(parent) {
|
||||
match self.res.items().loot_sequence(parent) {
|
||||
Some(sequence) => {
|
||||
let random = self.rand_sequences.get(&sequence, self.level.seed);
|
||||
self.res.items.loot_table_from(table, false, held, random)
|
||||
self.res.items().loot_table_from(table, false, held, random)
|
||||
}
|
||||
None => self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.loot_table(table, false, held, &mut self.world.random),
|
||||
}
|
||||
}
|
||||
@@ -1717,7 +1721,7 @@ impl Game<'_> {
|
||||
/// random draws) keeps the name, flags, persistence and age; the old one
|
||||
/// is discarded.
|
||||
pub(super) fn convert_mob(&mut self, index: usize, kind: &str) -> Option<u32> {
|
||||
let t = self.res.mob_types.get(kind).cloned()?;
|
||||
let t = self.res.mob_types().get(kind).cloned()?;
|
||||
let old = &self.mobs[index];
|
||||
self.next_entity += 1;
|
||||
let mut mob = Mob::new(self.next_entity, t, old.position, old.yaw);
|
||||
|
||||
@@ -447,9 +447,9 @@ impl Game<'_> {
|
||||
}
|
||||
fn end_portal_active(&self) -> bool {
|
||||
(0..256).any(|y| {
|
||||
&*self.res.facts.get(self.world.block(0, y, 0)).name == "minecraft:bedrock"
|
||||
&*self.res.facts().get(self.world.block(0, y, 0)).name == "minecraft:bedrock"
|
||||
&& (-3..=3).any(|d| {
|
||||
&*self.res.facts.get(self.world.block(d, y, 0)).name == "minecraft:end_portal"
|
||||
&*self.res.facts().get(self.world.block(d, y, 0)).name == "minecraft:end_portal"
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -591,7 +591,7 @@ impl Game<'_> {
|
||||
let p = self.crystals[i].position;
|
||||
let b = [p.x.floor() as i32, p.y.floor() as i32, p.z.floor() as i32];
|
||||
if let Some(fire) = fire
|
||||
&& self.res.facts.is_air(self.world.block(b[0], b[1], b[2]))
|
||||
&& self.res.facts().is_air(self.world.block(b[0], b[1], b[2]))
|
||||
&& self.world.loaded(b[0], b[2])
|
||||
{
|
||||
let _ = self.level_set(b, fire);
|
||||
@@ -764,7 +764,7 @@ impl Game<'_> {
|
||||
let held = self.held().cloned();
|
||||
let modifiers = held
|
||||
.as_ref()
|
||||
.and_then(|h| self.res.items.get(&h.item))
|
||||
.and_then(|h| self.res.items().get(&h.item))
|
||||
.map(|i| (i.attack_damage, i.attack_speed))
|
||||
.unwrap_or((0.0, 0.0));
|
||||
let speed = (4.0 + modifiers.1).max(0.1);
|
||||
@@ -813,7 +813,7 @@ impl Game<'_> {
|
||||
(0..256)
|
||||
.rev()
|
||||
.find(|&y| {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
(f.full_collision
|
||||
|| f.legacy_solid
|
||||
|| f.fluid != horizon_client::blocks::Fluid::None)
|
||||
@@ -1257,7 +1257,7 @@ impl Game<'_> {
|
||||
let (x, z) = (head.x + look.x * 2.5, head.z + look.y * 2.5);
|
||||
let mut y = head.y + 0.5;
|
||||
while y > 0.0
|
||||
&& self.res.facts.is_air(self.world.block(
|
||||
&& self.res.facts().is_air(self.world.block(
|
||||
x.floor() as i32,
|
||||
y.floor() as i32,
|
||||
z.floor() as i32,
|
||||
@@ -1594,7 +1594,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let boxes = [d.part_box(0), d.part_box(1), d.part_box(2)];
|
||||
let tags = &self.res.items.block_tags;
|
||||
let tags = &self.res.items().block_tags;
|
||||
let transparent = tags
|
||||
.get("minecraft:dragon_transparent")
|
||||
.cloned()
|
||||
@@ -1610,8 +1610,8 @@ impl Game<'_> {
|
||||
for y in lo.y.floor() as i32..=hi.y.floor() as i32 {
|
||||
for z in lo.z.floor() as i32..=hi.z.floor() as i32 {
|
||||
let state = self.world.block(x, y, z);
|
||||
let name = &self.res.facts.get(state).name;
|
||||
if self.res.facts.is_air(state) || transparent.contains(&**name) {
|
||||
let name = &self.res.facts().get(state).name;
|
||||
if self.res.facts().is_air(state) || transparent.contains(&**name) {
|
||||
continue;
|
||||
}
|
||||
if griefing && !immune.contains(&**name) {
|
||||
@@ -1713,7 +1713,7 @@ impl Game<'_> {
|
||||
let y = (0..256)
|
||||
.rev()
|
||||
.find(|&y| {
|
||||
let f = self.res.facts.get(self.world.block(0, y, 0));
|
||||
let f = self.res.facts().get(self.world.block(0, y, 0));
|
||||
f.full_collision || f.legacy_solid
|
||||
})
|
||||
.map_or(64, |y| y + 1);
|
||||
@@ -1767,7 +1767,7 @@ impl Game<'_> {
|
||||
next.y.floor() as i32,
|
||||
next.z.floor() as i32,
|
||||
];
|
||||
let f = self.res.facts.get(self.world.block(p[0], p[1], p[2]));
|
||||
let f = self.res.facts().get(self.world.block(p[0], p[1], p[2]));
|
||||
f.full_collision || f.legacy_solid
|
||||
};
|
||||
let hit_player = player.is_some_and(|pb| {
|
||||
@@ -1869,9 +1869,9 @@ impl Game<'_> {
|
||||
batch.width as i32,
|
||||
batch.height as i32,
|
||||
&bars,
|
||||
&self.atlas.font,
|
||||
&self.gui.atlas.font,
|
||||
);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.gui.atlas, &draws);
|
||||
}
|
||||
/// The dragon fight's boss bar shows (`EnderDragonFight.dragonEvent`,
|
||||
/// with `setCreateWorldFog`).
|
||||
@@ -1909,7 +1909,13 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let a = alpha as f32;
|
||||
let sprite = |n: &str| self.atlas.sprites.get(n).map(|r| [r.u0, r.v0, r.u1, r.v1]);
|
||||
let sprite = |n: &str| {
|
||||
self.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get(n)
|
||||
.map(|r| [r.u0, r.v0, r.u1, r.v1])
|
||||
};
|
||||
let (Some(skin), Some(eyes)) = (
|
||||
sprite("entity/enderdragon/dragon"),
|
||||
sprite("entity/enderdragon/dragon_eyes"),
|
||||
@@ -2075,7 +2081,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// `submitRays`: the death rays from a fixed seed, fading in white to magenta.
|
||||
fn dragon_rays(&self, base: glam::Mat4, t: f32, out: &mut Vec<Vertex>) {
|
||||
let white = self.atlas.font.white();
|
||||
let white = self.gui.atlas.font.white();
|
||||
let uv = [white.u0, white.v0];
|
||||
let over = if t > 0.8 {
|
||||
((t - 0.8) / 0.2).min(1.0)
|
||||
@@ -2131,6 +2137,7 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Some(s) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/end_crystal/end_crystal_beam")
|
||||
@@ -2192,6 +2199,7 @@ impl Game<'_> {
|
||||
out: &mut Vec<Vertex>,
|
||||
) {
|
||||
let Some(s) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/enderdragon/dragon_fireball")
|
||||
@@ -2381,7 +2389,7 @@ impl Game<'_> {
|
||||
}
|
||||
let name = self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(hit.pos[0], hit.pos[1], hit.pos[2]))
|
||||
.name
|
||||
.clone();
|
||||
@@ -2391,7 +2399,7 @@ impl Game<'_> {
|
||||
let above = [hit.pos[0], hit.pos[1] + 1, hit.pos[2]];
|
||||
if !self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.world.block(above[0], above[1], above[2]))
|
||||
{
|
||||
return false;
|
||||
@@ -2512,7 +2520,7 @@ impl Game<'_> {
|
||||
}
|
||||
fn block_name_at(&self, p: [i32; 3]) -> std::sync::Arc<str> {
|
||||
self.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone()
|
||||
@@ -2614,7 +2622,7 @@ impl Game<'_> {
|
||||
for y in h - 10..=h + 10 {
|
||||
for z in cz - 10..=cz + 10 {
|
||||
for x in cx - 10..=cx + 10 {
|
||||
if !self.res.facts.is_air(self.world.block(x, y, z)) {
|
||||
if !self.res.facts().is_air(self.world.block(x, y, z)) {
|
||||
let _ = self.level_set([x, y, z], air);
|
||||
}
|
||||
}
|
||||
@@ -2636,7 +2644,7 @@ impl Game<'_> {
|
||||
if &*self.block_name_at([x, y, z]) != "minecraft:obsidian" {
|
||||
let _ = self.set_state_named([x, y, z], "minecraft:obsidian", &[]);
|
||||
}
|
||||
} else if y > 65 && !self.res.facts.is_air(self.world.block(x, y, z)) {
|
||||
} else if y > 65 && !self.res.facts().is_air(self.world.block(x, y, z)) {
|
||||
let _ = self.level_set([x, y, z], air);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ impl Game<'_> {
|
||||
let held = self.inventory[self.selected].as_ref();
|
||||
speed += self
|
||||
.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.attribute_add(held, "minecraft:mining_efficiency") as f32;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ impl Game<'_> {
|
||||
pub(super) fn submerged_mining_speed(&self) -> f32 {
|
||||
let mut total = 0.0;
|
||||
for stack in self.armor.iter().flatten() {
|
||||
for (attr, _, amount, op) in self.res.stations.enchantments.attributes(stack) {
|
||||
for (attr, _, amount, op) in self.res.stations().enchantments.attributes(stack) {
|
||||
if attr == "minecraft:submerged_mining_speed" && op == "add_multiplied_total" {
|
||||
total += amount;
|
||||
}
|
||||
@@ -36,13 +36,13 @@ impl Game<'_> {
|
||||
}
|
||||
/// `EnchantmentHelper.processDurabilityChange` (unbreaking) for `amount` points.
|
||||
pub(super) fn durability_loss(&mut self, stack: &ItemStack, amount: u32) -> u32 {
|
||||
let e = &self.res.stations.enchantments;
|
||||
let e = &self.res.stations().enchantments;
|
||||
if !e.has_component(stack, "minecraft:item_damage") {
|
||||
return amount;
|
||||
}
|
||||
let ctx = EffectContext {
|
||||
tool: Some(&stack.item),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
e.modify_value(
|
||||
@@ -65,10 +65,10 @@ impl Game<'_> {
|
||||
direct_attacker: Some("minecraft:player"),
|
||||
is_direct: true,
|
||||
damage_type: Some("minecraft:player_attack"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
self.res.stations.enchantments.modify_value(
|
||||
self.res.stations().enchantments.modify_value(
|
||||
Some(&held),
|
||||
"minecraft:damage",
|
||||
&ctx,
|
||||
@@ -96,10 +96,10 @@ impl Game<'_> {
|
||||
attacker: Some("minecraft:player"),
|
||||
direct_attacker: Some("minecraft:player"),
|
||||
is_direct: true,
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let knockback = self.res.stations.enchantments.modify_value(
|
||||
let knockback = self.res.stations().enchantments.modify_value(
|
||||
Some(&held),
|
||||
"minecraft:knockback",
|
||||
&ctx,
|
||||
@@ -130,7 +130,7 @@ impl Game<'_> {
|
||||
// minecraft:post_attack ignite effects of the attacker's weapon (fire aspect).
|
||||
let mut ignite = 0.0f32;
|
||||
for (id, level) in held.enchantments() {
|
||||
let Some(def) = self.res.stations.enchantments.get(id) else {
|
||||
let Some(def) = self.res.stations().enchantments.get(id) else {
|
||||
continue;
|
||||
};
|
||||
for effect in def.effects["minecraft:post_attack"]
|
||||
@@ -145,7 +145,7 @@ impl Game<'_> {
|
||||
let mut random = self.world.random.clone();
|
||||
let ok = effect.get("requirements").is_none_or(|r| {
|
||||
self.res
|
||||
.stations
|
||||
.stations()
|
||||
.enchantments
|
||||
.condition(r, *level, &ctx, &mut random)
|
||||
});
|
||||
@@ -182,13 +182,13 @@ impl Game<'_> {
|
||||
attacker: Some("minecraft:player"),
|
||||
direct_attacker: Some("minecraft:player"),
|
||||
is_direct: true,
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
direct_motion: Some(motion),
|
||||
..Default::default()
|
||||
};
|
||||
let mut bursts = Vec::new();
|
||||
for (id, level) in held.enchantments() {
|
||||
let Some(def) = self.res.stations.enchantments.get(id) else {
|
||||
let Some(def) = self.res.stations().enchantments.get(id) else {
|
||||
continue;
|
||||
};
|
||||
for effect in def.effects["minecraft:post_attack"]
|
||||
@@ -205,7 +205,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
}
|
||||
let ok = effect.get("requirements").is_none_or(|r| {
|
||||
self.res.stations.enchantments.condition(
|
||||
self.res.stations().enchantments.condition(
|
||||
r,
|
||||
*level,
|
||||
&ctx,
|
||||
@@ -254,16 +254,16 @@ impl Game<'_> {
|
||||
if level == 0 {
|
||||
continue;
|
||||
}
|
||||
let Some(def) = self.res.stations.enchantments.get("minecraft:thorns") else {
|
||||
let Some(def) = self.res.stations().enchantments.get("minecraft:thorns") else {
|
||||
continue;
|
||||
};
|
||||
let effect = def.effects["minecraft:post_attack"][0].clone();
|
||||
let ctx = EffectContext {
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let mut random = self.world.random.clone();
|
||||
let ok = self.res.stations.enchantments.condition(
|
||||
let ok = self.res.stations().enchantments.condition(
|
||||
&effect["requirements"],
|
||||
level,
|
||||
&ctx,
|
||||
@@ -286,7 +286,7 @@ impl Game<'_> {
|
||||
s.damage += 2;
|
||||
if self
|
||||
.res
|
||||
.items
|
||||
.items()
|
||||
.get(&s.item)
|
||||
.is_some_and(|i| s.damage >= i.max_damage)
|
||||
{
|
||||
@@ -330,10 +330,10 @@ impl Game<'_> {
|
||||
};
|
||||
let Some(stack) = stack else { return amount };
|
||||
let ctx = EffectContext {
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let to_repair_xp = self.res.stations.enchantments.modify_value(
|
||||
let to_repair_xp = self.res.stations().enchantments.modify_value(
|
||||
Some(&stack),
|
||||
"minecraft:repair_with_xp",
|
||||
&ctx,
|
||||
@@ -364,11 +364,11 @@ impl Game<'_> {
|
||||
let Some(bow) = self.inventory[self.selected].clone() else {
|
||||
return (0.0, false);
|
||||
};
|
||||
let e = &self.res.stations.enchantments;
|
||||
let e = &self.res.stations().enchantments;
|
||||
let ctx = EffectContext {
|
||||
direct_attacker: Some("minecraft:arrow"),
|
||||
attacker: Some("minecraft:player"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let power = e.modify_value(
|
||||
@@ -380,7 +380,7 @@ impl Game<'_> {
|
||||
);
|
||||
let ammo_ctx = EffectContext {
|
||||
tool: Some("minecraft:arrow"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let infinity = e.has_component(&bow, "minecraft:ammo_use")
|
||||
@@ -399,12 +399,12 @@ impl Game<'_> {
|
||||
let bow = self.inventory[self.selected].clone()?;
|
||||
let ctx = EffectContext {
|
||||
this: Some("minecraft:arrow"),
|
||||
items: Some(&self.res.items),
|
||||
items: Some(self.res.items()),
|
||||
..Default::default()
|
||||
};
|
||||
let mut ignite: Option<f32> = None;
|
||||
for (id, level) in bow.enchantments() {
|
||||
let Some(def) = self.res.stations.enchantments.get(id) else {
|
||||
let Some(def) = self.res.stations().enchantments.get(id) else {
|
||||
continue;
|
||||
};
|
||||
for effect in def.effects["minecraft:projectile_spawned"]
|
||||
@@ -416,7 +416,7 @@ impl Game<'_> {
|
||||
continue;
|
||||
}
|
||||
let ok = effect.get("requirements").is_none_or(|r| {
|
||||
self.res.stations.enchantments.condition(
|
||||
self.res.stations().enchantments.condition(
|
||||
r,
|
||||
*level,
|
||||
&ctx,
|
||||
@@ -436,7 +436,7 @@ impl Game<'_> {
|
||||
pub(super) fn apply_enchantment_attributes(&mut self) {
|
||||
let mut wanted: Vec<(String, String, f64, String)> = Vec::new();
|
||||
for stack in self.armor.iter().flatten() {
|
||||
wanted.extend(self.res.stations.enchantments.attributes(stack));
|
||||
wanted.extend(self.res.stations().enchantments.attributes(stack));
|
||||
}
|
||||
let Some(p) = self.player.as_mut() else {
|
||||
return;
|
||||
|
||||
@@ -132,9 +132,9 @@ impl Game<'_> {
|
||||
/// The environment attributes of the current dimension.
|
||||
pub(super) fn dim_environment(&self) -> &Environment {
|
||||
match self.dim {
|
||||
Dim::Overworld => &self.res.environment,
|
||||
Dim::Nether => &self.res.nether_environment,
|
||||
Dim::End => &self.res.end_environment,
|
||||
Dim::Overworld => self.res.environment(),
|
||||
Dim::Nether => self.res.nether_environment(),
|
||||
Dim::End => self.res.end_environment(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ impl Game<'_> {
|
||||
/// tinted 0x282828. The atlas does not wrap, so each face is 16×16 quads.
|
||||
pub(super) fn end_sky_geometry(&self) -> Vec<Vertex> {
|
||||
let mut out = Vec::with_capacity(6 * 256 * 4);
|
||||
let Some(r) = self.atlas.sprites.get("environment/end_sky").copied() else {
|
||||
let Some(r) = self.gui.atlas.sprites.get("environment/end_sky").copied() else {
|
||||
return out;
|
||||
};
|
||||
use std::f32::consts::FRAC_PI_2;
|
||||
@@ -184,6 +184,7 @@ impl Game<'_> {
|
||||
let intensity = self.end.flash.intensity(self.clock.fraction() as f32);
|
||||
if intensity > 1e-5
|
||||
&& let Some(r) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("environment/celestial/end_flash")
|
||||
@@ -224,7 +225,7 @@ impl Game<'_> {
|
||||
|
||||
pub(super) fn block_name(&self, p: [i32; 3]) -> std::sync::Arc<str> {
|
||||
self.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(p[0], p[1], p[2]))
|
||||
.name
|
||||
.clone()
|
||||
@@ -561,7 +562,7 @@ impl Game<'_> {
|
||||
let mut y = (0..256)
|
||||
.rev()
|
||||
.find(|&y| {
|
||||
let f = self.res.facts.get(self.world.block(0, y, 0));
|
||||
let f = self.res.facts().get(self.world.block(0, y, 0));
|
||||
(f.full_collision || f.fluid != horizon_client::blocks::Fluid::None)
|
||||
&& !f.name.ends_with("_leaves")
|
||||
})
|
||||
@@ -783,7 +784,7 @@ impl Game<'_> {
|
||||
let mut y = 255;
|
||||
while y > floor {
|
||||
let p = [around[0] + xd, y, around[2] + zd];
|
||||
let f = self.res.facts.get(self.world.block(p[0], p[1], p[2]));
|
||||
let f = self.res.facts().get(self.world.block(p[0], p[1], p[2]));
|
||||
if f.full_collision && (allow_bedrock || &*f.name != "minecraft:bedrock") {
|
||||
tallest = Some(p);
|
||||
break;
|
||||
@@ -839,12 +840,12 @@ impl Game<'_> {
|
||||
if &*self.block_name([x, y, z]) != "minecraft:end_stone"
|
||||
|| self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(x, y + 1, z))
|
||||
.full_collision
|
||||
|| self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(x, y + 2, z))
|
||||
.full_collision
|
||||
{
|
||||
@@ -920,7 +921,8 @@ impl Game<'_> {
|
||||
fn end_crystal_geometry(&self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let (Some(model), Some(r)) = (
|
||||
self.crystal_model.as_ref(),
|
||||
self.atlas
|
||||
self.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/end_crystal/end_crystal")
|
||||
.copied(),
|
||||
@@ -1073,7 +1075,7 @@ impl Game<'_> {
|
||||
|
||||
/// ThrownItemRenderer: the ender eye item facing the camera.
|
||||
fn eye_geometry(&self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let Some(r) = self.atlas.sprites.get("item/ender_eye").copied() else {
|
||||
let Some(r) = self.gui.atlas.sprites.get("item/ender_eye").copied() else {
|
||||
return;
|
||||
};
|
||||
let alpha = self.clock.fraction();
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Game<'_> {
|
||||
&& self.settings.resource_packs.iter().all(|id| id == "vanilla")
|
||||
&& self.player.is_some()
|
||||
&& !self.spectator()
|
||||
&& !opaque(self.res.facts.get(self.world.block(at[0], at[1], at[2]))))
|
||||
&& !opaque(self.res.facts().get(self.world.block(at[0], at[1], at[2]))))
|
||||
.then(|| Culler::new(camera.to_array(), 8_192));
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ impl Game<'_> {
|
||||
if let Some(culler) = &self.entity_culler {
|
||||
culler.cull_vertices(vertices, start, |pos| {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if !opaque(self.res.facts.get(state)) {
|
||||
if !opaque(self.res.facts().get(state)) {
|
||||
return false;
|
||||
}
|
||||
let Some(y) = pos[1].checked_sub(MIN_Y) else {
|
||||
|
||||
@@ -167,7 +167,11 @@ impl Game<'_> {
|
||||
Snapshot {
|
||||
screen: self.screen_label(),
|
||||
dimension: self.dim.id().to_string(),
|
||||
chat: self.ui.chat.received,
|
||||
// A remote client counts the server's lines itself.
|
||||
chat: self
|
||||
.remote
|
||||
.as_ref()
|
||||
.map_or(self.ui.chat.received, |r| r.chat_received),
|
||||
counts: if world.is_some() {
|
||||
self.inventory_counts()
|
||||
} else {
|
||||
@@ -189,8 +193,19 @@ impl Game<'_> {
|
||||
if let Some(before) = &self.events.last
|
||||
&& *before != now
|
||||
{
|
||||
let new_chat = (now.chat - before.chat).min(100) as usize;
|
||||
let lines = self.ui.chat.recent_lines(new_chat);
|
||||
// Joining or leaving a server starts another count.
|
||||
let new_chat = now.chat.saturating_sub(before.chat).min(100) as usize;
|
||||
// Newest first; the remote client keeps its lines oldest first.
|
||||
let lines = match &self.remote {
|
||||
Some(r) => r
|
||||
.chat
|
||||
.iter()
|
||||
.rev()
|
||||
.take(new_chat)
|
||||
.map(|(t, _)| t.clone())
|
||||
.collect(),
|
||||
None => self.ui.chat.recent_lines(new_chat),
|
||||
};
|
||||
for event in diff(before, &now, &lines) {
|
||||
self.events.push(self.ticks, event);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ impl Game<'_> {
|
||||
break;
|
||||
}
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let f = self.res.facts.get(state);
|
||||
let f = self.res.facts().get(state);
|
||||
let fluid = if f.fluid != Fluid::None {
|
||||
100.0f32
|
||||
} else {
|
||||
@@ -206,7 +206,7 @@ impl Game<'_> {
|
||||
Some((at, resistance)) if at == pos => {
|
||||
power -= (resistance + 0.3) * 0.3;
|
||||
}
|
||||
_ if !self.res.facts.is_air(state) || f.fluid != Fluid::None => {
|
||||
_ if !self.res.facts().is_air(state) || f.fluid != Fluid::None => {
|
||||
power -= (f.explosion_resistance.max(fluid) + 0.3) * 0.3;
|
||||
}
|
||||
_ => {}
|
||||
@@ -450,11 +450,11 @@ impl Game<'_> {
|
||||
if self.world.random.next_int_bound(3).unwrap_or(1) == 0
|
||||
&& self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.is_air(self.world.block(pos[0], pos[1], pos[2]))
|
||||
&& self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(pos[0], pos[1] - 1, pos[2]))
|
||||
.solid_render
|
||||
{
|
||||
@@ -475,7 +475,7 @@ impl Game<'_> {
|
||||
} else {
|
||||
targets.len()
|
||||
};
|
||||
let (world, facts) = (&self.world, &self.res.facts);
|
||||
let (world, facts) = (&self.world, self.res.facts());
|
||||
self.particles.explosion(center, radius, block_count, &|b| {
|
||||
facts.is_air(world.block(b[0], b[1], b[2]))
|
||||
});
|
||||
@@ -490,10 +490,10 @@ impl Game<'_> {
|
||||
stacks: &mut Vec<([i32; 3], ItemStack)>,
|
||||
) -> Result<()> {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if self.res.facts.is_air(state) {
|
||||
if self.res.facts().is_air(state) {
|
||||
return Ok(());
|
||||
}
|
||||
let name = self.res.facts.get(state).name.clone();
|
||||
let name = self.res.facts().get(state).name.clone();
|
||||
let is_tnt = &*name == "minecraft:tnt";
|
||||
// Block.onExplosionHit: the drops copy from the block entity, which
|
||||
// then spills its contents as the block turns to air.
|
||||
@@ -510,7 +510,7 @@ impl Game<'_> {
|
||||
// tables' survives_explosion and explosion_decay draw from their
|
||||
// random sequence.
|
||||
let decay = (interaction == BlockInteraction::DestroyWithDecay).then_some(radius);
|
||||
let drops = self.res.items.block_drops_exploded(
|
||||
let drops = self.res.items().block_drops_exploded(
|
||||
self.pack.assets.registry,
|
||||
state,
|
||||
None,
|
||||
|
||||
@@ -188,7 +188,7 @@ impl Game<'_> {
|
||||
let radius = ((reach / 16.0).ceil() as i32 + 1).min(self.settings.render_distance.max(2));
|
||||
self.extras.minimap.update(
|
||||
&self.world,
|
||||
&self.res.facts,
|
||||
self.res.facts(),
|
||||
(bx >> 4, bz >> 4),
|
||||
radius,
|
||||
layer,
|
||||
@@ -197,10 +197,10 @@ impl Game<'_> {
|
||||
if !self.extras.minimap.compose(view) {
|
||||
return;
|
||||
}
|
||||
let Some(rect) = self.atlas.sprites.get(MINIMAP_SPRITE).copied() else {
|
||||
let Some(rect) = self.gui.atlas.sprites.get(MINIMAP_SPRITE).copied() else {
|
||||
return;
|
||||
};
|
||||
let (w, h) = (self.atlas.width as f32, self.atlas.height as f32);
|
||||
let (w, h) = (self.gui.atlas.width as f32, self.gui.atlas.height as f32);
|
||||
self.map_patches.push(horizon_client::font::Patch {
|
||||
x: (rect.u0 * w).round() as u32,
|
||||
y: (rect.v0 * h).round() as u32,
|
||||
@@ -246,7 +246,7 @@ impl Game<'_> {
|
||||
let (map_corner, map_size) = (e.minimap_corner, f32::from(e.minimap_size));
|
||||
let visible = |corner| !(self.debug && corner == Corner::TopLeft);
|
||||
let mut corners = Corners::new(batch.width, batch.height, self.effect_rows_height());
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
if let Some(view) = self.minimap_view()
|
||||
&& visible(map_corner)
|
||||
&& !self.extras.minimap.image.is_empty()
|
||||
@@ -290,7 +290,7 @@ impl Game<'_> {
|
||||
use_: self.extras.mouse[1],
|
||||
cps,
|
||||
};
|
||||
extras_hud::draw_keystrokes(batch, &self.atlas, &mut corners, keys_corner, &k);
|
||||
extras_hud::draw_keystrokes(batch, &self.gui.atlas, &mut corners, keys_corner, &k);
|
||||
}
|
||||
if mod_panels {
|
||||
self.draw_mod_panels(batch, &mut corners);
|
||||
|
||||
@@ -6,7 +6,7 @@ use horizon_world::level::LevelEvent;
|
||||
|
||||
impl Game<'_> {
|
||||
pub(super) fn finish_falling_block(&mut self, mut block: FallingBlock, pos: [i32; 3]) {
|
||||
let anvil = self.res.facts.get(block.state).name.ends_with("anvil");
|
||||
let anvil = self.res.facts().get(block.state).name.ends_with("anvil");
|
||||
if let Some(impact) = block.damage.impact(block.fall_distance) {
|
||||
if impact.amount > 0.0 {
|
||||
falling_block::hurt_mobs(&mut self.mobs, block.position, impact.amount);
|
||||
@@ -80,7 +80,7 @@ impl Game<'_> {
|
||||
&& block.drop_item
|
||||
&& self.ui.rules.bool("entity_drops")
|
||||
{
|
||||
let item = self.res.facts.get(block.state).item.clone();
|
||||
let item = self.res.facts().get(block.state).item.clone();
|
||||
if &*item != "minecraft:air" {
|
||||
self.pop_resource(
|
||||
pos,
|
||||
|
||||
@@ -108,6 +108,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/illager/evoker_fangs")
|
||||
|
||||
@@ -226,14 +226,18 @@ impl Game<'_> {
|
||||
fn biome_name_at(&self, p: Vec3) -> Option<String> {
|
||||
let (x, y, z) = (p.x.floor() as i32, p.y.floor() as i32, p.z.floor() as i32);
|
||||
let c = self.world.chunks.get(&(x >> 4, z >> 4))?;
|
||||
Some(self.res.biomes.list[c.biome(x, y, z) as usize].name.clone())
|
||||
Some(
|
||||
self.res.biomes().list[c.biome(x, y, z) as usize]
|
||||
.name
|
||||
.clone(),
|
||||
)
|
||||
}
|
||||
fn water_height(&self, x: i32, y: i32, z: i32) -> Option<(f32, bool)> {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if f.fluid != Fluid::Water {
|
||||
return None;
|
||||
}
|
||||
let above = self.res.facts.get(self.world.block(x, y + 1, z));
|
||||
let above = self.res.facts().get(self.world.block(x, y + 1, z));
|
||||
let h = if above.fluid == Fluid::Water {
|
||||
1.0
|
||||
} else {
|
||||
@@ -243,7 +247,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// getOpenWaterTypeForBlock: 0 above water, 1 inside water, 2 invalid.
|
||||
fn open_water_type(&self, x: i32, y: i32, z: i32) -> u8 {
|
||||
let f = self.res.facts.get(self.world.block(x, y, z));
|
||||
let f = self.res.facts().get(self.world.block(x, y, z));
|
||||
if self.world.is_air(self.world.block(x, y, z)) || &*f.name == "minecraft:lily_pad" {
|
||||
return 0;
|
||||
}
|
||||
@@ -390,7 +394,7 @@ impl Game<'_> {
|
||||
(fish[1] - 1.0).floor() as i32,
|
||||
fish[2].floor() as i32,
|
||||
);
|
||||
&*self.res.facts.get(state).name == "minecraft:water"
|
||||
&*self.res.facts().get(state).name == "minecraft:water"
|
||||
}
|
||||
/// `ServerLevel.sendParticles` of a simple particle.
|
||||
fn send_particles(
|
||||
@@ -565,6 +569,7 @@ impl Game<'_> {
|
||||
return;
|
||||
};
|
||||
let Some(r) = self
|
||||
.gui
|
||||
.atlas
|
||||
.sprites
|
||||
.get("entity/fishing/fishing_hook")
|
||||
|
||||
@@ -75,7 +75,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// The fluid at the camera, as `Camera.getFluidInCamera` reports it.
|
||||
fn camera_fluid(&self, camera: [f64; 3]) -> CameraFluid {
|
||||
match fog_type(&self.world, &self.res.facts, camera, self.forward()) {
|
||||
match fog_type(&self.world, self.res.facts(), camera, self.forward()) {
|
||||
FogType::Water => CameraFluid::Water,
|
||||
FogType::Lava => CameraFluid::Lava,
|
||||
FogType::PowderSnow => CameraFluid::PowderSnow,
|
||||
@@ -177,6 +177,6 @@ impl Game<'_> {
|
||||
}
|
||||
let draws =
|
||||
hud_overlays::spyglass(batch.width as i32, batch.height as i32, self.scope_scale);
|
||||
hud_layout::paint(batch, &self.atlas, &draws);
|
||||
hud_layout::paint(batch, &self.gui.atlas, &draws);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ impl Game<'_> {
|
||||
return false;
|
||||
}
|
||||
let s = f.step();
|
||||
let behind = self.res.facts.get(self.world.block(
|
||||
let behind = self.res.facts().get(self.world.block(
|
||||
f.pos[0] - s[0],
|
||||
f.pos[1] - s[1],
|
||||
f.pos[2] - s[2],
|
||||
@@ -282,8 +282,15 @@ impl Game<'_> {
|
||||
}
|
||||
/// BlockAttachedEntity.tick for frames.
|
||||
pub(super) fn tick_item_frames(&mut self) {
|
||||
// ServerLevel.tick: only entities in entity-ticking chunks tick.
|
||||
let ticking = self.entity_ticking_area();
|
||||
let mut i = 0;
|
||||
while i < self.item_frames.len() {
|
||||
let at = center(&self.item_frames[i]);
|
||||
if !ticking(at[0].floor() as i32, at[2].floor() as i32) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
self.item_frames[i].check_interval += 1;
|
||||
if self.item_frames[i].check_interval >= 100 {
|
||||
self.item_frames[i].check_interval = 0;
|
||||
@@ -301,7 +308,7 @@ impl Game<'_> {
|
||||
}
|
||||
/// ItemFrameRenderer: the frame model, then the item half size on its face.
|
||||
pub(super) fn frame_geometry(&mut self, camera: glam::DVec3, out: &mut Vec<Vertex>) {
|
||||
let sprites = &self.atlas.sprites;
|
||||
let sprites = &self.gui.atlas.sprites;
|
||||
let mut maps: Vec<(i32, glam::Mat4, u32)> = Vec::new();
|
||||
let mut items: Vec<(ItemStack, u32, glam::Mat4, u8)> = Vec::new();
|
||||
// ItemFrame.shouldRenderAtSqrDistance: 1024 blocks at 100%.
|
||||
|
||||
@@ -39,7 +39,7 @@ impl Game<'_> {
|
||||
};
|
||||
switcher.hover(w, h, (self.cursor.0 as i32, self.cursor.1 as i32));
|
||||
let selected = switcher.selected;
|
||||
let atlas = &self.atlas;
|
||||
let atlas = &self.gui.atlas;
|
||||
batch.sprite_region(
|
||||
atlas,
|
||||
"gui/container/gamemode_switcher",
|
||||
@@ -62,14 +62,14 @@ impl Game<'_> {
|
||||
for (index, mode) in MODES.into_iter().enumerate() {
|
||||
let (x, y) = slot_origin(w, h, index);
|
||||
batch.sprite(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
"gui/sprites/gamemode_switcher/slot",
|
||||
x as f32,
|
||||
y as f32,
|
||||
);
|
||||
if mode == selected {
|
||||
batch.sprite(
|
||||
&self.atlas,
|
||||
&self.gui.atlas,
|
||||
"gui/sprites/gamemode_switcher/selection",
|
||||
x as f32,
|
||||
y as f32,
|
||||
|
||||
@@ -8,7 +8,7 @@ use horizon_client::Result;
|
||||
impl Game<'_> {
|
||||
fn golem_block(&self, p: [i32; 3]) -> &str {
|
||||
let state = self.world.block(p[0], p[1], p[2]);
|
||||
&self.res.facts.get(state).name
|
||||
&self.res.facts().get(state).name
|
||||
}
|
||||
fn is_golem_head(&self, p: [i32; 3]) -> bool {
|
||||
matches!(
|
||||
@@ -33,7 +33,7 @@ impl Game<'_> {
|
||||
for (ax, az) in [(1, 0), (0, 1)] {
|
||||
let side = |s: i32, row: i32| [head[0] + ax * s, head[1] - row, head[2] + az * s];
|
||||
let arms = (-1..=1).all(|s| self.golem_block(side(s, 1)) == "minecraft:iron_block");
|
||||
let air = |p: [i32; 3]| self.res.facts.is_air(self.world.block(p[0], p[1], p[2]));
|
||||
let air = |p: [i32; 3]| self.res.facts().is_air(self.world.block(p[0], p[1], p[2]));
|
||||
if arms
|
||||
&& self.golem_block(side(0, 2)) == "minecraft:iron_block"
|
||||
&& [-1, 1].iter().all(|&s| air(side(s, 0)) && air(side(s, 2)))
|
||||
@@ -58,7 +58,7 @@ impl Game<'_> {
|
||||
let below = [head[0], head[1] - 1, head[2]];
|
||||
let name = self.golem_block(below);
|
||||
self.res
|
||||
.items
|
||||
.items()
|
||||
.block_tags
|
||||
.get("minecraft:copper")
|
||||
.is_some_and(|t| t.contains(name))
|
||||
@@ -88,7 +88,7 @@ impl Game<'_> {
|
||||
/// `EntityType.create(level, TRIGGERED)` and `snapTo`: a built golem or
|
||||
/// wither has no spawn finalization and draws nothing from the level.
|
||||
pub(super) fn create_triggered(&mut self, kind: &str, at: [f64; 3], yaw: f32) -> Option<u32> {
|
||||
let t = self.res.mob_types.get(kind).cloned()?;
|
||||
let t = self.res.mob_types().get(kind).cloned()?;
|
||||
self.next_entity += 1;
|
||||
let mut mob = horizon_client::mobs::Mob::new(
|
||||
self.next_entity,
|
||||
@@ -181,9 +181,9 @@ impl Game<'_> {
|
||||
});
|
||||
if let Some(chest) = chest {
|
||||
self.with_level(|b, level, ticks| b.set_block(level, ticks, pos, chest, 2));
|
||||
if let Some(entity) =
|
||||
horizon_client::containers::BlockEntity::for_block(&self.res.facts.get(chest).name)
|
||||
{
|
||||
if let Some(entity) = horizon_client::containers::BlockEntity::for_block(
|
||||
&self.res.facts().get(chest).name,
|
||||
) {
|
||||
self.world
|
||||
.block_entities
|
||||
.insert((below[0], below[1], below[2]), entity);
|
||||
|
||||
@@ -10,7 +10,7 @@ impl Game<'_> {
|
||||
/// Load the configured/placed feature registry used by saplings, fungi
|
||||
/// and bone meal (once per process; shares the generator's bundle).
|
||||
pub(super) fn install_live_features(&self) {
|
||||
if self.res.behaviours.live_features().is_some() {
|
||||
if self.res.behaviours().live_features().is_some() {
|
||||
return;
|
||||
}
|
||||
let dir = self.options.resources.join("worldgen");
|
||||
@@ -20,7 +20,7 @@ impl Game<'_> {
|
||||
.and_then(|data| LiveFeatures::new(&data).map_err(|e| e.to_string()));
|
||||
match features {
|
||||
Ok(Some(features)) => {
|
||||
self.res.behaviours.set_live_features(Arc::new(features));
|
||||
self.res.behaviours().set_live_features(Arc::new(features));
|
||||
log::info!("Horizon: live features ready in {:?}", started.elapsed());
|
||||
}
|
||||
Ok(None) => {
|
||||
|
||||
@@ -39,7 +39,7 @@ impl Game<'_> {
|
||||
});
|
||||
self.clicks.destroying = destroying;
|
||||
self.attack_clicks = 0;
|
||||
self.stop_remote_mining();
|
||||
self.request_remote_mining_stop();
|
||||
self.mining = None;
|
||||
}
|
||||
/// `LivingEntity.swing` with `getModifiedSwingDuration`.
|
||||
@@ -90,7 +90,7 @@ impl Game<'_> {
|
||||
let (pos, first) = (d.pos, (d.ticks as u32 - 1).is_multiple_of(4));
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
if first {
|
||||
let sounds = self.res.facts.get(state).sounds.clone();
|
||||
let sounds = self.res.facts().get(state).sounds.clone();
|
||||
self.audio.play(
|
||||
&sounds.hit,
|
||||
Some(pos.map(|v| f64::from(v) + 0.5)),
|
||||
@@ -117,17 +117,17 @@ impl Game<'_> {
|
||||
/// `BlockBehaviour.getDestroyProgress` with `Player.getDestroySpeed`.
|
||||
pub(super) fn destroy_progress(&self, pos: [i32; 3]) -> f32 {
|
||||
let state = self.world.block(pos[0], pos[1], pos[2]);
|
||||
let facts = self.res.facts.get(state);
|
||||
let facts = self.res.facts().get(state);
|
||||
if facts.hardness == -1.0 {
|
||||
return 0.0;
|
||||
}
|
||||
let held = self.held();
|
||||
let mut speed = self.res.items.mining_speed(held, &facts.name);
|
||||
let mut speed = self.res.items().mining_speed(held, &facts.name);
|
||||
speed = self.modify_destroy_speed(speed);
|
||||
if let Some(eye) = self.eye_position()
|
||||
&& self
|
||||
.res
|
||||
.facts
|
||||
.facts()
|
||||
.get(self.world.block(
|
||||
eye[0].floor() as i32,
|
||||
eye[1].floor() as i32,
|
||||
@@ -141,7 +141,7 @@ impl Game<'_> {
|
||||
if self.player.as_ref().is_some_and(|p| !p.ground.on_ground) {
|
||||
speed /= 5.0;
|
||||
}
|
||||
let harvest = !facts.requires_tool || self.res.items.correct_for_drops(held, &facts.name);
|
||||
let harvest = !facts.requires_tool || self.res.items().correct_for_drops(held, &facts.name);
|
||||
speed / facts.hardness / if harvest { 30.0 } else { 100.0 }
|
||||
}
|
||||
/// Whether an attack would hit an entity rather than the block behind
|
||||
@@ -287,7 +287,7 @@ impl Game<'_> {
|
||||
horizon_client::attack_strength::BASE_ATTACK_SPEED
|
||||
+ self
|
||||
.held()
|
||||
.and_then(|h| self.res.items.get(&h.item))
|
||||
.and_then(|h| self.res.items().get(&h.item))
|
||||
.map_or(0.0, |i| f64::from(i.attack_speed))
|
||||
}
|
||||
/// `evaluateWhichHandsToRender`: which of the main and off hand show.
|
||||
@@ -351,7 +351,7 @@ impl HandWorld for GameHands<'_, '_> {
|
||||
}
|
||||
fn is_air(&mut self, pos: [i32; 3]) -> bool {
|
||||
let state = self.game.world.block(pos[0], pos[1], pos[2]);
|
||||
self.game.res.facts.get(state).name.ends_with("air")
|
||||
self.game.res.facts().get(state).name.ends_with("air")
|
||||
}
|
||||
fn creative(&self) -> bool {
|
||||
self.game.creative
|
||||
|
||||
@@ -83,7 +83,7 @@ impl Game<'_> {
|
||||
horizon_client::flatgen::FlatTerrain::from_settings(
|
||||
&s,
|
||||
self.pack.assets.registry,
|
||||
&self.res.biomes,
|
||||
self.res.biomes(),
|
||||
)
|
||||
})
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user