Commit Graph

3685 Commits

Author SHA1 Message Date
Ludovic Marie f7d042c6d0 Skip section face groups that face away from the eye
The mesher groups each section's solid quads by the axis side they face
(Sodium's ModelQuadFacing) and records each group's nearest plane. When
the eye is behind every plane of a group, back-face culling would discard
all of it after vertex shading, so the renderer leaves the group out of
the section's draws. Seen from the village path, 29-36% fewer solid quads
reach the GPU at render distances 8-32; the picture is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:56:43 +02:00
Ludovic Marie 55945ee975 Collision scans: skip blocks with no shape, build the entity shape lazily
BlockCollisionScan asked every cursor cell for its collision shape,
moved it into place and intersected it with Shapes.create(box), even
for air. Mob movement and every other Entity.collide spent most of
their time there. Now:

- CollisionBlock carries empty_shape, set by the registry for states
  with no contextual rule and an empty cached shape (air, plants): the
  scan skips them without asking. Providers that build CollisionBlock
  themselves (the query-order fixture) leave it false, so their query
  logs are unchanged.
- A shape whose bounds miss the box is skipped before moving it:
  joinIsNotEmpty(AND) of the two is false anyway.
- Shapes.create(box) is built the first time a shape is not the unit
  cube (finite bounds always make one), not for every scan.
- SceneCollisions hands the scan the resident chunk itself, so a cell
  costs one section read instead of a chunk-map lookup.

Results are unchanged: running both paths side by side over 900,000
mob moves in a 600-mob village gave bit-identical movement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:40:22 +02:00
Ludovic Marie bc4d0cc806 Villagers: know each block state's POI type from a table built once
PoiTypes.forState ran per palette entry of every section a villager
searched (and per block of the sections that hold one), with a string
match on the block name each time and a per-search hash map in front.
At world load, when every villager looks for a job site, bed and
meeting point at once, that was 16 % of the tick. The POI type of
every state is now worked out once, the first time a villager looks,
and read from a table after that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:40:22 +02:00
Ludovic Marie 8a48f3b383 mob_ai probe: keep the snapshot grid as the game does
The probe builds MobWorld itself; it now keeps the same SeenGrid over
its snapshot for the mob ticks, so the mob_ai harness checks pushes
through the grid against vanilla.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:40:22 +02:00
Ludovic Marie 54acb709e4 Mobs: shape only the cells that can support them
Entity.checkSupportingBlock runs findSupportingBlock after every move of
a mob on the ground. Horizon looked up and built the collision shape of
every cell of the cursor (27 to 48 per call, twice when it falls back
to where the mob came from). Like BlockCollisions' cursor, a block whose
shape stays inside its own cell (neither hasLargeCollisionShape nor a
moving piston) can only meet the area when its cell does, so only those
cells, and large shapes such as fences, are shaped now. The pick is a
total order, so visiting column by column finds the same block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:40:22 +02:00
Ludovic Marie 4f1735170e Mobs: find the mobs to push through a grid, not a scan of every mob
LivingEntity.pushEntities compared each mob's box with every other mob
of the tick's snapshot: quadratic, about 1 ms per tick with 600 mobs.
The snapshot is now also kept in a grid of 4-block columns by each box's
minimum corner, updated as each mob finishes its tick, and the push
reads only the columns its box can reach. Candidates come back in
snapshot order, so the pushes, their order and their sums are the same:
over 800,000 pushes in a 600-mob village both ways gave the same
targets in the same order. A query wider than the grid (or not finite)
falls back to the full scan.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:40:22 +02:00
Ludovic Marie dbe28edc9b Merge origin/main: use #501's staging belt, keep only the animation cache change
Drop this branch's own staging buffer (gfx/uploads.rs); the sprite uploads
go through the StagingBelt from #501. What stays is the animation mip-chain
cache holding every vanilla frame, with tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 16:40:11 +02:00
Ludovic Marie baaa5e7374 Per-frame uploads through the staging belt; skip unchanged lightmaps
Renderer::render's buffer writes (globals, section origins and draws,
entity, cloud, celestial, border, debug-line and screen-effect vertices)
and the HUD's vertices now go through the frame's staging belt instead of
one Queue::write_buffer staging buffer each. The lightmap is uploaded only
when its pixels change instead of every frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:39:01 +02:00
Ludovic Marie 1e1c3b79e5 Stop animated textures from slowing every tick's frame
Every frame that crossed a tick re-uploaded the animated block sprites, and
that took about 1.8 ms on an M4 Pro (more than the world tick itself):

- The mip-chain cache held 8 MiB, which fits 256 of the 594 vanilla
  animation frames (64-pixel layers, chains stored with spare capacity), so
  the other 338 frames had their resize and mip chain rebuilt on the render
  thread whenever their animation reached them. The budget is now 32 MiB and
  chains are allocated at their exact size: all 594 frames fit in 13 MB.
- Each changed sprite mip level went through its own Queue::write_texture,
  which allocates and frees a GPU staging buffer per call (a few hundred a
  tick). They are now packed into one reused buffer, written once, and
  copied with one submission per tick.

The texels are unchanged: a GPU test compares the batched copies with
write_texture over several flushes, and the existing cache tests compare
cached and generated chains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:09:21 +02:00
Ludovic Marie 9e73a8417f Upload animated sprites through a reused staging belt
Queue::write_texture creates a new staging buffer for every call, a kernel
call each on Metal. Animated sprites write every changed frame's mip
levels once per tick, so tick frames spent about 1.3 ms in buffer creation.
The copies now go through one wgpu StagingBelt recorded into the frame's
encoder; a GPU readback test checks they write the same texels as
write_texture on every mip level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:42:57 +02:00
LookImEcho-Rick 45397e4b30 Merge main and reconcile cloud caching with see-through text 2026-10-16 06:25:15 -05:00
Ludovic Marie b8f1011cb1 Merge pull request #474 from ludovic111/fix/lan-name-tags-through-walls
Name tags show through walls
2026-10-16 13:03:23 +02:00
Ludovic Marie 9c87672a0c Merge pull request #473 from ludovic111/fix/lan-trial-guests
LAN: trial spawners and vaults see the guests
2026-10-16 13:03:15 +02:00
Ludovic Marie b523567d1e Merge pull request #472 from ludovic111/fix/lan-guest-chat
LAN guest: command feedback names the guest and shows its numbers
2026-10-16 13:03:08 +02:00
Ludovic Marie 330c3ef07e Merge pull request #471 from ludovic111/fix/lan-guest-containers
LAN guest: their own ender chest, and double chests as 9x6
2026-10-16 13:03:01 +02:00
Ludovic Marie b1a3adff81 Merge pull request #470 from ludovic111/fix/lan-pvp
LAN: PvP between the host and guests
2026-10-16 13:02:54 +02:00
Ludovic Marie 018c5e43e3 Merge pull request #467 from ludovic111/fix/lan-guest-environment
LAN guest: hurt by lava, fire, drowning, suffocation and the void; hungry from moving
2026-10-16 13:02:47 +02:00
Ludovic Marie 7cfc19305a Merge pull request #466 from ludovic111/fix/lan-mobs-target-guests
LAN: mobs target and attack guests
2026-10-16 13:02:41 +02:00
Ludovic Marie 6ff898ec29 Merge pull request #481 from ludovic111/fix/block-entity-data-tooltips
Item tooltips for container contents, spawner data and op-only data
2026-10-16 12:45:14 +02:00
LookImEcho-Rick 56fec974ee Reuse cloud geometry and GPU buffers between frames 2026-10-16 05:45:09 -05:00
Ludovic Marie f5c91eded1 Merge pull request #479 from ludovic111/fix/pick-block-data
Ctrl + Pick Block copies the block entity's data in creative
2026-10-16 12:45:09 +02:00
Ludovic Marie 8da9c8c4c6 Merge pull request #483 from ludovic111/fix/world-options-game-rules
World Options: Edit Game Rules (InWorldGameRulesScreen)
2026-10-16 12:42:04 +02:00
Ludovic Marie 04bdf82ac9 Merge pull request #482 from ludovic111/fix/world-options-buttons
World Options: difficulty lock with its confirmation, and Restrictions
2026-10-16 12:42:00 +02:00
Ludovic Marie 9bbe5c4fd3 Merge pull request #476 from ludovic111/fix/debug-crosshair-no-bob
F3 debug crosshair: no view bob, drawn after the hand like vanilla
2026-10-16 12:41:53 +02:00
Ludovic Marie a950a046ae World Options: Edit Game Rules (InWorldGameRulesScreen)
The rules by category under a search box, a switch or number box each,
with vanilla's tooltip, number validation (Brigadier readInt and the
rule's range, red text, Done held) and ConfirmScreen before discarding.
Done sets the changed rules and tells the player, as handleSetGameRule
does. The button follows the commands the player has, as updateButton.

The control socket's `type` now reaches World Options' boxes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:50:00 +02:00
Ludovic Marie e27e556ab2 World Options: the difficulty lock (with its question) and Restrictions
The Lock button toggles the wanted lock; Apply with a new lock asks first
(PopupScreen "Lock World Difficulty"), Yes locks the level's difficulty
(difficulty_settings.locked, now read and written), No returns to the
options. Restrictions opens RestrictionsScreen: the chat restriction the
Chat option makes, with its way to Chat Settings, and the four chat
permissions. A locked or hardcore level keeps both the difficulty and the
lock inactive, and LAN guests are told about the lock.

Part of #464

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:15:43 +02:00
Ludovic Marie ac4ed86925 Item tooltips for container contents, spawner data and op-only data
ItemContainerContents.addToTooltip: an item with a container (a shulker box,
or a chest Ctrl + Pick Block copied) lists its first five stacks as
"count x name" and how many more there are. Spawner.appendHoverText: a
spawner or trial spawner item names the entity its block_entity_data spawns,
else how to set one. ItemStack.OP_NBT_WARNING: for a player with game master
permission, an item carrying data of an op-only block entity type (command
blocks, lecterns, signs, spawners) warns that it might run commands.

The item argument now refuses block_entity_data without an id or with an
unknown block entity type, with vanilla's TypedEntityData messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 11:09:03 +02:00
Ludovic Marie bd42496af0 Ctrl + Pick Block copies the block entity's data in creative
ServerGamePacketListenerImpl.addBlockDataToItem: with Ctrl held in creative,
Pick Block gives the block's item the block entity's data. What each type
turns into item components (removeComponentsFromTag and
collectImplicitComponents: container, custom_name, lock, container_loot,
sign text, waxed, bees, banner patterns, pot decorations, skull profile)
leaves its NBT; the rest becomes minecraft:block_entity_data, tagged with
the type's id. Placing the item does the reverse
(BlockItem.updateCustomBlockEntityTag, op-only types only for a game
master, then applyComponentsFromItemStack), for every block entity type,
which also fills placed chests, barrels, hoppers and the like from their
container component, as vanilla does, where only shulker boxes were.

The client sends includeData on Ctrl in multiplayer, a picked banner keeps
its patterns without Ctrl (AbstractBannerBlock.getCloneItemStack), a picked
beehive carries its honey level, a placed command block with data keeps its
own auto and output tracking, and a placed waxed sign opens no editor.

tools/test_pick_block_data_parity.py compares both directions with vanilla's
own block entities: 148/148 cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:59:56 +02:00
Ludovic Marie 3e6052ac92 control: keys reach a server's chat input
The control socket's key command went straight to key_pressed, so Escape
paused the game instead of closing the chat a server connection opens
(remote_chat_key handles the real keyboard).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:58:09 +02:00
Ludovic Marie bc0cd9cc84 LAN guest: a use packet uses the item alone
ServerGamePacketListenerImpl.handleUseItem takes the client's rotation and
uses the held item, nothing else. The host ran the whole right click, with
the block the guest had looked at before: a guest that turned from an
ender chest to a double chest could get the ender chest opened again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:58:09 +02:00
Ludovic Marie a8579b4df8 lan status shows whether each guest crouches; walls sets up its own scene
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:58:09 +02:00
Ludovic Marie 487d76c0ae gfx: the batch test covers see-through text
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:58:09 +02:00
Ludovic Marie 74fafdd787 LAN: trial spawners and vaults see the guests
PlayerDetector reads level.getPlayers(): the guests count for a trial
spawner's detection and a vault's connected players, and a key a guest
inserts rewards the guest's UUID.

Part of #462

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:58:09 +02:00
Ludovic Marie 11130e6ef7 LAN guest: command feedback names the guest and shows its numbers
Feedback about the player (target_name) names the guest a command runs
for. A client reading a server's chat now unwraps NbtOps' {"": value}
wrapper of any bare value, not only strings, so translation arguments that
are numbers show ("Replaced 1 slot(s)", the coordinates). horizon-ctl
messages reads a server's chat too.

Part of #435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:58:09 +02:00
Ludovic Marie 3f7fba836e Name tags show through walls
SubmitNodeCollection.submitNameTag: a name that is not discrete is drawn
in full over the world and, faded on its background, again with
RenderPipelines.TEXT_SEE_THROUGH (no depth test) after the rest of the
world; a discrete one (a crouching player) only once, faded, on its
background. The background is ARGB.color(0.25, black): alpha 0x3F.

Part of #435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:58:09 +02:00
Ludovic Marie fc59063ada Keep held keys held through wait on the control socket
`wait` ended with release_agent_keys like every other task, so
`key w down` + `wait 40` + `wait 20` walked for the first wait only.
A wait holds nothing: it leaves keys and buttons alone. They stay held
until `key ... up`, `release` or `stop`. Documented in horizon-ctl's
key/wait help (and so the MCP tools) and docs/agent-control.md.

Fixes #469

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 10:56:48 +02:00
Ludovic Marie 23a54d4a22 F3 debug crosshair: drawn at the hand's projection, without the view bob
GameRenderer.render3dHud draws DebugCrosshairRenderer after the hand and
the screen effects, with the hudFov projection, no bob and FogMode.NONE.
Horizon drew it among the world's on-top gizmos, so the axes bobbed with
View Bobbing.

Fixes #475

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:38:20 +02:00
Ludovic Marie 36d7f02802 LAN: PvP between the host and guests
Player.attack on a player: the host hits the guest on its crosshair, a guest
hits the host or another guest. The hit is worked out as the attacker
(Game::melee_damage, shared with attacking mobs) and lands on the victim as a
player_attack (blocking, armour, knockback to the guest's client), when the
pvp game rule allows it (ServerPlayer.canHarmPlayer).

Part of #435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:19:00 +02:00
Ludovic Marie e289980c1e LAN guest: their own ender chest, and double chests as 9x6
The hub's container menus now say where their slots live (lan::menu::Slots):
one block entity, both halves of a double chest (CompoundContainer, the right
half first) or the guest's own ender inventory (PlayerEnderChestContainer,
saved as EnderItems). The host's ender inventory stays the host's while a
guest acts. A Horizon client shows a server's chest-like menu with the rows
and title the server sent, and keeps its slots off a block that holds no such
container.

Part of #435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 10:19:00 +02:00
Ludovic Marie 90644915c5 Merge pull request #455 from ludovic111/fix/command-blocks
Command blocks: placing, the edit screen, and running commands
2026-10-16 10:12:07 +02:00
Ludovic Marie 7b53b06aca Merge pull request #448 from ludovic111/fix/drop-swing
Dropping from a menu swings the hand
2026-10-16 10:12:02 +02:00
Ludovic Marie 53fcf14850 Merge pull request #447 from ludovic111/fix/drop-key-repeat
Holding the drop key keeps dropping, in game and in menus
2026-10-16 10:11:58 +02:00
Ludovic Marie 84999e0762 Merge pull request #446 from ludovic111/fix/wayland-uncapped-windowed
Wayland: VSync off draws uncapped in a window
2026-10-16 10:11:54 +02:00
Ludovic Marie 3c81a89d1e Merge pull request #463 from ludovic111/fix/mod-commands-in-chat
Mod commands: coloured and Tab-completed in the chat like vanilla's (#456)
2026-10-16 09:50:12 +02:00
Ludovic Marie 600bae5703 LAN guest: hurt by lava, fire, drowning, suffocation and the void; hungry from moving
The host now runs the rest of the server's body tick for each guest:
LivingEntity.baseTick's drowning and lava, fire blocks, suffocation
(isInWall) and the void (checkBelowWorld, 4 a tick, creative too), and per
move handleMovePlayer's jump (ServerPlayer.jumpFromGround's exhaustion) and
checkMovementStatistics (sprinting, swimming). The first move of a tick now
starts from the ground state before it, so take-offs are seen. Hurt sounds
are heard at the guest; lan status lists each guest's health and food.

Part of #435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:13:43 +02:00
Ludovic Marie dac18e8350 LAN: mobs target and attack guests
Each mob sees the nearest player (host or guest), as Level.getNearestPlayer
gives it, and keeps a guest it targets or that hurt it in the last 100 ticks.
Its hits, pushes, fire and launches on that player run with the guest swapped
in; mobs' projectiles hit guests too, and knockback reaches the guest's client
(SetEntityMotion on its own entity).

Part of #435

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 08:44:07 +02:00
LookImEcho-Rick 924698e506 Support standing and walking on happy ghasts 2026-10-16 01:10:46 -05:00
LookImEcho-Rick 705fab9bed Fix happy ghast rider collisions and turning 2026-10-16 01:10:19 -05:00
Ludovic Marie 7e8dd577ac Merge pull request #454 from ludovic111/fix/title-toast-slide
World backup toast slides in and out with its sounds (#384)
2026-10-16 07:37:05 +02:00
Ludovic Marie a75c3a315f Merge pull request #453 from ludovic111/fix/slider-smooth-drag
Classic sliders follow the pointer and snap on release (#385)
2026-10-16 07:37:01 +02:00