Commit Graph

3685 Commits

Author SHA1 Message Date
rdbtCVS f0215473e3 Biome zoom: mix the shared corner prefixes once in quart_at_block
getFiddledDistance restarts a six-step LinearCongruentialGenerator mix for
each of the eight quart corners. Its first two steps depend only on the X
and Y corner offsets, so quart_at_block now mixes the two X states and the
four XY states once, then runs the remaining steps across the eight corners.
next(m, salt + offset) == next(m, salt) + offset, so a coordinate folds into
its step with one addition.

Bit-identical to BiomeManager.getBiome and getFiddledDistance; a reference
oracle test pins the equivalence over a dense grid and wrapping extremes.
2026-10-17 22:08:17 +01:00
Ludovic Marie 9b97ba09de Merge pull request #737 from ludovic111/perf/lan-post-thread
🤖 Agent: merged by Ludovic's AI agent: perf-server-5 (combined check passed).
2026-10-17 22:48:42 +02:00
Ludovic Marie d65881a2f0 Merge pull request #739 from ludovic111/perf/chunk-packet-direct
🤖 Agent: merged by Ludovic's AI agent: perf-server-5. Before/after in the PR body; agent parity 87/87 stacked; orchestrator combined check with the perf-ticks-5 stack on current main: clippy clean, client+protocol tests pass (one flaky world-delete test, #749), dedicated_server/lan/chunk_stage/block_entity_storage PASS.
2026-10-17 22:47:47 +02:00
Ludovic Marie f548f5ce6c Merge pull request #748 from ludovic111/perf/shared-compressed-frames
🤖 Agent: merged by Ludovic's AI agent: perf-server-5 (combined check passed).
2026-10-17 22:47:42 +02:00
Ludovic Marie cb35d7e661 Merge pull request #738 from ludovic111/perf/hopper-scan-five-slots
🤖 Agent: merged by Ludovic's AI agent: perf-server-5. Before/after in the PR body; agent parity 87/87 stacked; orchestrator combined check with the perf-ticks-5 stack on current main: clippy clean, client+protocol tests pass (one flaky world-delete test, #749), dedicated_server/lan/chunk_stage/block_entity_storage PASS.
2026-10-17 22:47:27 +02:00
LookImEcho-Rick 782924fcb7 Add settings search to video and controls 2026-10-17 15:36:13 -05:00
Ludovic Marie 8bfe19245b Merge commit 'bf1cd958686ffc95a6ff30cdbedc9a8de59315ad' into HEAD
# Conflicts:
#	tools/lan_e2e.py
2026-10-17 22:33:41 +02:00
Ludovic Marie bf1cd95868 Merge main into feat/server-command-tree
tools/lan_e2e.py: the check lists keep #700's effects and portals and this PR's commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 22:33:18 +02:00
Ludovic Marie bd60381883 Merge pull request #700 from ludovic111/fix/effects-every-player
🤖 Agent: merged by Ludovic's AI agent: perf-ticks-5 stack. Local on current main: clippy clean, horizon-client tests pass, parity 10/10 (dedicated_server lan tab_list chunk_stage locator_bar command_exec online_mode user_cache server_world_gen mob_ai); agent integration 88/88.
2026-10-17 22:11:26 +02:00
Ludovic Marie 24fd51b186 Content mods: keep the built content root for later starts
resource_root built the content root again on every start. With ATM10's 40
carried data-tier mods that is about 25 s on a quiet machine (50 s on a busy
one) and the biggest memory peak of the start, above 3 GB of footprint. The
root now records a stamp of what it was built from (this build of the game,
the base's manifest and rewritten tables, every mod file by size and time) and
later starts with the same stamp use it as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:51:33 +02:00
Ludovic Marie 580c2b1dd7 Motion: reuse the game's block facts for the fluid tables
FluidResources decoded gameplay-facts.json a second time for three per-state
columns the game's BlockFacts already has. With ATM10's carried mods that file
is 211 MB: the second decode took a few seconds and peaked about 500 MB above
what the game keeps. MotionResources::load_with_facts takes the game's facts;
load still decodes them itself for tests and tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:46:38 +02:00
Ludovic Marie ce38c8d74f Merge pull request #743 from ludovic111/perf/terrain-draws
🤖 Agent: merged by Ludovic's AI agent: RD32 terrain draws 9,309 → 708 calls on Metal, avg 128 → 162 FPS, CPU 6.76 → 5.73 ms; screenshots identical (6/7 views 0 px, 7th = fading chat); parity 88/88. RD16 and below unchanged.
2026-10-17 21:42:50 +02:00
Ludovic Marie 4d04a997ce Merge pull request #735 from ludovic111/fix/minecart-render-culling
🤖 Agent: merged by Ludovic's AI agent: verify passed, parity proven (CI or perf-frame-2's local run), before/after numbers and screenshots in the PR body.
2026-10-17 21:42:45 +02:00
Ludovic Marie cd1725565a Merge pull request #742 from ludovic111/perf/metal-gpu-timer
🤖 Agent: merged by Ludovic's AI agent: verify passed, parity proven (CI or perf-frame-2's local run), before/after numbers and screenshots in the PR body.
2026-10-17 21:42:40 +02:00
Ludovic Marie f227d04f79 Merge pull request #715 from ludovic111/fix/vsync-windowed
🤖 Agent: merged by Ludovic's AI agent: verify passed, parity proven (CI or perf-frame-2's local run), before/after numbers and screenshots in the PR body.
2026-10-17 21:42:36 +02:00
Ludovic Marie b5abc95fe4 Merge commit 'a4feb6516102eaffb9e82437f808e32f4d05bde0' into HEAD 2026-10-17 21:41:03 +02:00
Ludovic Marie 7c5bd06dfe lan_bot: the command tree arrives parsed (#708)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:41:03 +02:00
Ludovic Marie 95bdb96f16 Merge commit '805d5532e541deb1888216c8ebfc15775d8b2ea5' into HEAD 2026-10-17 21:40:51 +02:00
Ludovic Marie 7733984e78 levels.rs: per-level block events carry u32 states (#674)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:40:51 +02:00
rdbtCVS 238278aa41 Startup: keep the title's atlas and panorama in one UI bundle (#712)
The title's GUI atlas and its panorama both come from the resource root and
are only needed to draw the title and menus, but they lived apart: the atlas
on Game and the panorama inside PackResources. Gather them into UiResources so
Stage 2 can load the title bundle before the world bundle. No behaviour change.

Part of #712 (stage 2a).
2026-10-17 20:40:10 +01:00
Ludovic Marie ba7451cd31 Merge pull request #728 from Online5277/perf/block-entity-fields
🤖 Agent: merged by Ludovic's AI agent once CI parity passed; screenshots identical to main (perf-frame-2), CPU frame time about 40% lower on a chest field.
2026-10-17 21:38:00 +02:00
Ludovic Marie 1fe38223ac Merge pull request #736 from Online5277/fix/death-screen-save
🤖 Agent: merged by Ludovic's AI agent once CI parity passed.
2026-10-17 21:37:34 +02:00
rdbtCVS fb450342bc Worker threads: leave a core for the render and server threads 2026-10-17 20:37:20 +01:00
Ludovic Marie 8c01418247 Merge pull request #682 from Online5277/fix/blocked-hit-animation
🤖 Agent: merged by Ludovic's AI agent: CI parity and verify passed. Thanks @Online5277!
2026-10-17 21:37:03 +02:00
Ludovic Marie 2e531f35e5 Per-state tables: check state identities while reading, never as a tree
occlusion.nbt, cached-collision.nbt, cached-support.nbt, block-properties.nbt and
movement-properties.nbt each carry the identity of every block state, and every
loader parsed them into an NBT tree first: 240 MB per table for ATM10's 153,511
states, about 1.4 GB allocated and freed while the game starts.

nbt::read_named_streaming hands a named list to a visitor element by element.
registry::BlockTableFile reads a table that way, checking each state against the
registry as it comes, and loaders build from a checked registry::BlockTable.
from_nbt stays for trees built in memory (tests, fixtures).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:25:11 +02:00
Ludovic Marie 0605ee689f LAN: compress a large packet once for every connection
Each player's writer thread compressed every packet it sent, so a chunk
column sent to fifty players was deflated fifty times; compression was
most of the writer threads' time and about half of the server's CPU.
Bodies of 8 KiB or more (chunk columns, mostly) now go through a shared
cache of compressed frame contents keyed by their length, two
independently keyed 64-bit hashes and the threshold, holding the newest
32 MiB. The bytes on the wire are the same: frame::encode is split into
frame::contents and frame::prefixed, and ConnWriter::send_contents
sends a frame from its contents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 21:06:22 +02:00
Ludovic Marie d746be2ca3 Merge main into feat/server-levels
game/lan.rs: #586's movement-check rules are set before the per-level passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 20:56:26 +02:00
rdbtCVS 4be192a4b8 Startup: load resources on a worker behind a loading screen (#712)
The synchronous startup loaded every resource before the first window
existed, so the game hung on a blank screen for seconds. An ordinary
launch now enters the event loop at once, opens the window, and draws a
loading screen with the current stage and a progress bar while a
resource-loader thread runs the existing load sequence. When it finishes,
audio is created on the render thread and the real renderer, game and
title screen replace the loading screen on the same window.

Harness, dedicated and scripted runs (--frames, --world-frames,
--benchmark, --control, --dedicated, HORIZON_MENU_STYLE=classic and the
parity fixtures) keep the fully-synchronous path unchanged, so their
output stays byte-identical. title_shown still fires on the real title,
not on the loading screen.
2026-10-17 19:54:10 +01:00
Ludovic Marie dc1a8a4f39 Merge pull request #734 from ludovic111/fix/guest-command-feedback
🤖 Agent: merged by Ludovic's AI agent. Combined with #733 on current main: workspace clippy clean, client 827 tests pass, server_world_gen + dedicated_server PASS (agent: parity --changed 89/89).
2026-10-17 20:43:37 +02:00
Ludovic Marie e2e0752489 Merge pull request #733 from ludovic111/fix/server-level-type
🤖 Agent: merged by Ludovic's AI agent. Combined with #734 on current main: workspace clippy clean, client 827 tests pass, server_world_gen + dedicated_server PASS (agent: parity --changed 89/89).
2026-10-17 20:43:34 +02:00
Cosmic 95b4b7422d Restore saved death and health on world entry (#729) 2026-10-17 14:25:35 -04:00
Ludovic Marie 09e179804c Merge pull request #680 from ludovic111/perf/mod-content-memory
🤖 Agent: merged by Ludovic's AI agent. Parity 291/291 on the head; combined with main locally: workspace clippy clean, client/world tests pass, mob_ai/save_roundtrip/spawner PASS. ATM10 registry 249 → 125 MB, vanilla 46 → 24 MB.
2026-10-17 19:41:47 +02:00
Cosmic d35f892b7f Cache closed chest geometry for block-entity fields (#717) 2026-10-17 13:36:09 -04:00
Ludovic Marie cafe59b72e Merge pull request #408 from Online5277/fix/sulfur-cube-inner-layer
🤖 Agent: merged by Ludovic's AI agent. CI parity passed on the head; combined with current main (and #680) locally: workspace clippy clean, horizon-client 826 + horizon-world tests pass, mob_ai/save_roundtrip/spawner PASS. Thanks @Online5277!
2026-10-17 19:30:36 +02:00
Cosmic 41a0b3a9e8 Use the exact standard shield yaw constant 2026-10-17 13:14:16 -04:00
Cosmic 1a6fd4e17d Merge remote-tracking branch 'origin/main' into fix/blocked-hit-animation
# Conflicts:
#	crates/horizon-client/src/mobs/anim.rs
2026-10-17 13:09:02 -04:00
Cosmic cfed77c227 Pose shields in the active hand and preserve local held item data 2026-10-17 13:08:42 -04:00
Ludovic Marie 2f82becb9c Hoppers: look up the block only under five-slot containers
tick_hoppers read the block under every plain container block entity
each tick (chests, barrels, shulker boxes, dispensers, droppers) to find
the hoppers. A hopper's block entity is the only five-slot one
(BlockEntity::for_block, and BlockEntity::id already names it the
hopper), so only those are looked up now; a position still needs a
hopper block to tick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:35:42 +02:00
Ludovic Marie d1d36f4121 Guests: experience orbs fly to them and give them their points
On a LAN world or a server, guests never got experience: orbs followed and
were taken only by the host's own player (none on a dedicated server), and
guests weren't sent orbs at all.

- Each orb follows the nearest living, non-spectator player within 8
  blocks, the host or a guest (ExperienceOrb.followNearbyPlayer).
- A guest takes an orb as Player.aiStep does: one of those in its box grown
  by 1, 0.5, 1, at random, at most every 2 ticks (takeXpDelay), repairing
  with Mending first; the rest goes to the guest's experience (sent with
  SetExperience as before), the level-up sound every fifth level.
  TakeItemEntity goes to the players around, the pickup sound plays at the
  orb.
- Orbs have entity ids and are tracked to guests (AddEntity, DATA_VALUE).
  The client shows a server's orbs, moves them with the server's packets and
  flies them to their collector.

tools/lan_e2e.py xp: three 7-point orbs near the guest: it sees three and
ends at level 2 (21 points); the host gets none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:13:55 +02:00
Ludovic Marie 22dc3e5954 Guests: touching mobs push them on their own client, as in vanilla
A mob's push of a guest went to the guest as SetEntityMotion carrying the
server copy's velocity, which nothing damps: every tick of contact added
to it and replaced what the guest's client was doing. Vanilla pushes
players on their own client only (EntitySelector.pushableBy): the server
no longer sends those pushes, and a server client now pushes its player
away from every living entity it touches (Entity.push, team rules, no
spectators, bats or passengers of the same vehicle).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:13:55 +02:00
Ludovic Marie 1c2f7664c3 Cull minecarts by distance and view like vanilla
Minecarts were drawn every frame wherever they were: at render distance 32
every chest minecart of every loaded mineshaft went through the rail
lookups, display block and model, and the per-vertex terrain occlusion
test. Vanilla draws a cart only within 64 times its bounding box's mean
edge (about 57 blocks at entity distance 100%), measured from its current
position, and only when its interpolated box, grown by 0.5 and stretched
up by the display block's offset, is in the view
(EntityRenderer.shouldRender, AbstractMinecartRenderer
.getBoundingBoxForCulling). The cart the player rides always draws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 18:10:34 +02:00
Ludovic Marie 69dd4feb31 Server clients: mobs' and players' heads turn smoothly, not flicker
On a LAN world or a server, other entities' heads flickered between two
directions. The client wrote ClientboundRotateHeadPacket's head yaw into
the entity's yRot and the move packets' yRot into the body yaw, never moved
the head's previous yaw and pitch on, and never ran the body rotation, so
each frame interpolated the head from stale values.

As vanilla: move packets interpolate the position, yRot and xRot over three
ticks (LinearInterpolationHandler), RotateHead the head yaw over three
(lerpHeadTo), each tick keeps the previous head rotation for the frames, and
the body follows (a mob's BodyRotationControl, a player's walk direction
within 50 degrees of the look). AddEntity sets yRot and xRot and puts the
body and head at the packet's head yaw (recreateFromPacket).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:52:01 +02:00
Ludovic Marie 123e8286ac Guests: container clicks reach the server (chests, furnaces, crafting drags)
On a LAN world or a server, a guest's clicks that went through the menu
engine (placing a carried stack, quick craft drags, double clicks, number
keys, Q) ran only on the guest's own copy and were never sent: the item
showed in the chest or furnace, the server still had it in the inventory,
and the next menu brought it back.

menu_ops now sends every click of the server's open menu as vanilla's
MultiPlayerGameMode.handleContainerInput does: the engine predicts it on
the client's copy, then a ContainerClick goes out with the slots it changed
and the carried stack after it (a drag is its three kinds of clicks). The
plain inventory and crafting table are predicted too, the Shift double click
sends each QUICK_MOVE, and a prediction no longer drops, crafts or makes maps
on the client (the server does).

tools/lan_e2e.py clicks: real mouse presses put a stack into a chest and a
furnace, drag planks over the crafting grid and craft; the server has each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:51:33 +02:00
Ludovic Marie d99cf24400 LAN: wake the writer threads from one post thread, once per tick
At the end of each tick the game thread handed every player's held
packets to that player's writer thread, waking each one: a system call
per player, and on a busy machine often the rest of the core's time
slice to the woken writer. Now the batches go to one post thread in a
single send, and it wakes the writers. A packet sent to a player while
its batch is still with the post thread goes the same way, so each
player's packets keep their order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:51:00 +02:00
Ludovic Marie 43f598fd4e LAN: write chunk packets straight into one buffer
ChunkEncoder::body_in writes the LevelChunkWithLight body that
Clientbound::encode would give, into one buffer sized up front: the
cached section bytes and light layers are copied once, uniform light
layers are filled in place, and the heightmaps are shared rather than
cloned. Before, each chunk sent built a packet (growing its buffer,
cloning every 2048-byte layer), then encode copied all of it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:50:32 +02:00
Ludovic Marie ce62f9c57f Server clients: eating plays on the player's own screen
A server client sent UseItem and never started the use itself, so food
showed no eating animation or crumbs, and holding right click sent a new
UseItem every 4 ticks. Like MultiPlayerGameMode.useItem, the client now
starts eating (Consumable.startConsuming), counts the use down for the
animation and its particles, and starts no other use until it ends; the
server still eats the item. Looking at another player no longer stops
the item from being used (Player.interactOn passes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:42:19 +02:00
Ludovic Marie 28d218b3a2 Guests: a bed puts the guest to sleep, not the host
The bed's sleeping state, timer and respawn point were the host's fields,
so a guest clicking a bed put the host to sleep and moved the host's
spawn. as_guest now swaps them with the guest's own; the guest gets its
sleeping pose and bed (entity data 14), wakes on STOP_SLEEPING with the
WAKE_UP animation, and the night skips only once enough players sleep
(players_sleeping_percentage). Guests respawn at their own bed, else the
world spawn. Server clients lie in the bed from the synced position.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:40:40 +02:00
Ludovic Marie 51b58f3897 Metal: draw terrain sections as one index list per page run
wgpu replays an indirect multi-draw on Metal as one draw call per entry, so
every frame encoded a draw per visible face range and translucent section
(9,300 at render distance 32). Where multi-draw is emulated (Metal) and a
frame has at least 4,096 section draws, a compute pass now copies the
frame's section draws into one index list, in draw order, and each run of
sections in the same arena page is one draw call: 9,309 draw calls become
about 750 at RD32. Smaller frames keep the per-section draws, where the
list's GPU cost (about 0.4 ms on an M4 Pro at RD16) outweighs the CPU saved.

The picture is unchanged by construction: the same triangles from the same
vertices in the same order through the same shader code. Only where a
vertex finds its section's origin changes, from the instance attribute to
a table: a section's vertices fill whole 256-vertex blocks of its page, each
block names the section, and the section's camera-relative origin is
computed on the CPU exactly as before.

Vulkan keeps the native multi-draw. HORIZON_FLAT_DRAWS=1 draws every frame
flat (any backend that supports it), 0 never; the control command
`section-draws flat|indirect` switches in a running game for A/B checks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:34:52 +02:00
Ludovic Marie a6592eb188 Merge main into feat/wide-block-states
lan/chunks.rs: #706's per-section block entity lists carry u32 states.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:31:24 +02:00
Ludovic Marie fc6db37b6a GPU frame time on Metal, render spans and section draw counts
Apple GPUs time only pass boundaries (no TIMESTAMP_QUERY_INSIDE_ENCODERS),
so the GPU timer was off on every Mac and benchmarks reported no GPU time.
Where only pass boundaries can be timed, the frame is now bracketed by two
empty compute passes that write the timestamps.

HORIZON_SPIKES also names the renderer's parts (occlusion, visibility,
encode, submit), and the status reply counts the frame's section draws and
the draw calls that submit them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 17:17:20 +02:00