Commit Graph

30 Commits

Author SHA1 Message Date
Ludovic Marie a891037c9f parity: harnesses build horizon-client in the fast profile only
Under parity.py the release and fast profiles have identical settings
(PROFILE: no LTO, 16 codegen units, incremental), yet 38 harnesses built
horizon-client in release and 16 others in fast: every run where the client
changed compiled it twice. They all use fast now. Release stays for
horizon-world's probes, which no fast harness builds.

Measured on playhorizon (4 CPUs), all 13 probe builds after 78 merges:
1578 s, of which the release client (bin + client_probe) took 485 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 23:24:54 +01:00
Ludovic Marie 5d04a5bee8 Merge remote-tracking branch 'origin/main' into fix/harness-await-flakes 2026-10-26 12:04:32 +01:00
Ludovic Marie 34d8d94022 parity: server harnesses wait on the server's clock and replies, not on sleeps
server_knockback, locator_bar, server_dimension_players and their one-player users now end a step by the server's
game clock (a sync round trip, N ticks, a last sync) the way server_player_targets does, so a server that stalls
under load still gets all its ticks inside the step. server_knockback's frozen section waits for the stepped tick,
the stopped clock and the landed hit; dedicated_server waits for the player's leaving before /list.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 11:06:02 +01:00
rdbtCVS bd09f8b03e Migrate player integration coverage to server-thread hosting
Co-Authored-By: OpenAI Codex GPT-6.1 <noreply@openai.com>
2026-10-25 19:36:11 +00:00
Ludovic Marie 6acf7fb6ab server_player_targets harness: end each step by the server's clock
Each step waited a fixed 2.5 s. When the machine is loaded the vanilla server stalls for longer than that (CI on
#1571 and #1585: after Bob's trip to the Nether, vanilla's `tp Bob 4.5 -60 0.5` from the console ran a step late),
so its packets were filed under the next step and the transcripts differed although both servers sent the same.

A step now ends once the server has done its work:
- the console's own `time query gametime` comes back, so the step's console commands have run (the console runs
  its queue in order);
- LocatorBarClient's new `sync NAME` runs `time query gametime` as that player and waits for the reply (not
  recorded), so that player's commands have run and every packet sent before the reply is recorded;
- the server's game time has advanced STEP_TICKS (40) more ticks, then each player sends its position reminder
  and syncs once more.

game_time() moves out of settle() in test_dedicated_server_parity.py so both use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 05:46:22 +01:00
Ludovic Marie d271176f23 Tools and harnesses start the game in scratch folders, not a player's
The game logs into HORIZON_HOME and falls back to the player's own game folder when it is unset. Harnesses
that set only HORIZON_NO_AUDIO (and test_native_client, which set nothing) wrote logs, and on a world run
advancements, into ~/Library/Application Support/horizon.

lab.game_env gives every game a fresh HORIZON_HOME, HORIZON_LAUNCHER_HOME, XDG_DATA_HOME and XDG_CONFIG_HOME,
no audio and no launcher self-update; a folder the caller passes is kept. Every launcher of the game uses it,
parity.py gives each harness its own HORIZON_HOME, and tests/test_game_home.py fails for a script in tools/
that starts the game without it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 18:34:32 +02:00
Ludovic Marie 574e3ca567 dedicated_server parity: the client re-sends its position as vanilla's does
The harness failed about 1 run in 3 on CI with "play-trade villager false" on
Horizon's side: the protocol client never saw the villager it trades with.

A server pairs a player with an entity only while the entity's chunk has been
sent to it, and checks again when either moves (ChunkMap.move / updatePlayers).
VanillaProtocolClient sent its position once, at the spawn teleport, and never
again. Horizon's first chunk batch goes out two ticks after the player is placed
(after the first tick's packets, as vanilla orders them); when a busy machine
held the tick thread back long enough for the client's move to be handled one
tick after placement, the villager's chunk wasn't sent yet, and with no later
move the villager was never paired.

The 26.3 client re-sends its position every 20 ticks standing still
(LocalPlayer.sendPosition, after a ServerboundClientTickEnd each tick). The
parity client now does the same from the time it is loaded until its death, so
an entity whose chunk comes late is paired at the next reminder, on either
server.

On failure the harness now adds the servers' and clients' warnings and errors to
its message and the client log's tail when the client fails, and parity.py's
summary prints the end of the first failing harnesses' logs, so CI shows why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 01:33:16 +02:00
Ludovic Marie 3960c09159 tools: one copy of the helpers harnesses share, in lab.py
free_port (7 copies), offline_uuid (4), varint and parse_varint (3 and 2),
dbits (6), fbits (4) and settled (2) move into lab.py; every caller uses
lab's. The other server harnesses keep importing free_port from
test_dedicated_server_parity, which now takes lab's. Imports the moved
code left unused go too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:20:06 +02:00
Ludovic Marie ce87bfb8c7 Tools read the pinned Minecraft version from research-lock.json
lab.VERSION, lab.GAME (.local/minecraft/<version>) and lab.RESOURCES
(.local/horizon-client/<version>) come from the lock, and lab.version_info()
reads the pinned client jar's version.json. Every harness, generator and
tool that named 26.3 (resource folders, jar and source paths, result
records, the vanilla client's --version and asset index, the bare login
client's protocol, the benchmark's options.txt data version, the packet id
table's header) uses them, so a candidate worktree pinned to another version
runs them unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 12:22:20 +02:00
Ludovic Marie 5c88c46c51 Merge pull request #1001 from ludovic111/fix/guest-projectile-owner
🤖 Agent: merged after verify passed. Remote players' projectiles record their owner: ender pearls teleport and hurt the thrower, mobs target the shooter; docs/server.md row updated; part of #484.
2026-10-19 11:52:38 +02:00
Ludovic Marie 97993634c0 Merge pull request #999 from ludovic111/fix/guest-use-item-on
🤖 Agent: merged after verify passed. A remote player's item used on a block is used once (a snowball thrown at the ground flew 2× main hand / 3× off hand); part of #484.
2026-10-19 11:50:11 +02:00
Ludovic Marie 092bf87012 Server: a guest's projectiles are theirs (ender pearls take them)
A projectile a guest shot was recorded as the local player's (Who::Player), which on a
server means the host, or nobody on a dedicated server. So a guest's ender pearl
teleported the host on a LAN world and did nothing on a dedicated server, what it hit
answered to the host, and clients were told the projectile had no owner.

Projectiles now remember the guest who shot them (Projectile.guest, set when the
guest's turn ends). Clients get the guest as the owner (Projectile.getAddEntityPacket),
and the hit runs as that guest: their pearl teleports and hurts them, and the mob hit
answers to them. ThrownEnderpearl's endermite also needs monsters to spawn, and comes
where the player was.

The dedicated-server harness checks that the snowballs' owner is the player and throws
an ender pearl at the player's feet: vanilla teleports it and takes 5 health, main did
neither.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 11:11:44 +02:00
Ludovic Marie ca1e3a17c8 Server: a right click with an item on a block uses it once
A vanilla client sends a right click as one packet per hand and part
(Minecraft.startUseItem): UseItemOn for the block's part and ItemStack.useOn, then
UseItem for Item.use when that passed, the main hand first. The server ran the whole
click, both hands, for UseItemOn, then the item again for UseItem: a snowball thrown
at the ground flew twice, three times from the off hand.

Each packet now does its own part with its own hand
(ServerGamePacketListenerImpl.handleUseItemOn / handleUseItem): UseItemOn stops at
useOn (no throwing, drinking, eating, raising, equipping, buckets or an ender eye off a
frame), and neither touches entities (Interact does). Horizon's own client, which
counted on the server trying the off hand, now sends the off hand's packets when the
main hand's use passes, as vanilla's does. UseItem's rotation is the player's now
(absSnapRotationTo) without sending the client a teleport back.

The dedicated-server harness right-clicks the ground with a snowball in the main hand,
then in the off hand, and counts the snowballs against vanilla's (2 and 3 on main,
1 and 1 now).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 11:11:19 +02:00
Ludovic Marie 4953305c7b Server: run a dead player's chat commands, as vanilla does (#973)
A dead guest's packets were all dropped but the respawn request, so a command typed on
the death screen never ran. ServerGamePacketListenerImpl.handleChatCommand and
handleSignedChatCommand don't look at the player's health: the commands now run.

The dedicated-server harness sends `/trigger nope` from the death screen and compares
the reply with vanilla's before respawning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 10:34:02 +02:00
Ludovic Marie a0bcc13f1c Tick blocks around every player, from vanilla's chunk tickets (#890)
Without a local player (dedicated server, --server-thread) no block ticked:
tick_blocks returned early, so crops, fluids, redstone, pistons and pressure
plates stood still, and a LAN host ticked only around itself.

ticket_levels ports DistanceManager's levels: PLAYER_LOADING at 31 within the
view distance and PLAYER_SIMULATION at 31 - simulation distance for every
player in the level (the local player, LAN guests, a server's players), and
FORCED at 31. Random ticks run in simulation entity-ticking chunks that are
ticking chunks, scheduled ticks, block events and block entities in block
ticking ones, entities in entity ticking ones; the sculk blocks follow the
same rule. Saved ticks unpack when a chunk starts ticking
(startTickingChunk), not when it loads.

The hub keeps the tick-rate state current while nobody is in the game, so a
player joining a frozen server is told once (updateJoiningPlayer).

dedicated_server parity froze nothing while the client was sent its chunks:
saved fluid ticks there (a lava fall that never settles) ran before or after
the chunk was sent depending on each server's loading speed, and it failed on
main too. It now freezes the game until the client has its chunks.

lan_e2e gets a growth check: water flows and wheat grows next to a guest
1000 blocks from the host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 22:20:39 +02:00
Ludovic Marie 8912d5d269 dedicated_server harness: compare the op's command feedback on the console, and a score on @s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 15:41:19 +02:00
Ludovic Marie b859b22111 Keep usercache.json and find console players through it, as vanilla
Port CachedUserNameToIdResolver to the dedicated server, in place of the
in-memory name cache: usercache.json in the universe folder is loaded at
startup (bad entries skipped, a bad date warned about), players are added
when they join and kept for a month, and the file keeps the 1000 most
recently used, newest first, as Gson writes it.

The console's op, deop, ban, pardon and whitelist find players by name
through it, in any case. A name it doesn't hold is asked of the profile
service (profiles::find_by_name) on offline servers too, as vanilla does;
one the service doesn't know is the offline player of the lower-case name
on an offline server, and "That player does not exist" on an online one.

tools/test_user_cache_parity.py runs vanilla's server and Horizon's with a
mock profile service and compares the replies, the names looked up and the
files; the dedicated-server harness now compares usercache.json too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 11:33:02 +02:00
Ludovic Marie e7f7236c34 Open furnaces, blast furnaces and smokers on a server
Right-clicking a furnace as a guest did nothing: the host only handed
chests, barrels, hoppers, dispensers and shulker boxes over. It now opens
the furnace's own menu (minecraft:furnace, blast_furnace or smoker),
runs the guest's clicks through the host's AbstractFurnaceMenu (fuel slot,
take-only result, shift-clicks by recipe and fuel, a new input restarts
cooking) and keeps the client's progress arrows in step with
ContainerSetData. The dedicated server harness now opens a furnace and
smelts an ore in it on both servers.

Fixes #540

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 04:17:54 +02:00
Ludovic Marie 66d187ed06 Respawn on a server in vanilla's order, so vanilla clients leave the loading screen
A vanilla 26.3 client that died on a Horizon server stayed on its loading
screen after pressing Respawn (#566): ClientPacketListener.handleRespawn
starts a LevelLoadTracker that waits for the level info's "level chunks
load start" game event and the chunk under the player, and Horizon's
respawn sent neither the level info nor the chunk cache centre.

The hub's respawn now follows PlayerList.respawn: the entities paired with
the dead player are removed (one packet each), its chunks are dropped
without ForgetLevelChunk (as PlayerChunkSender does for a dead player) and
sent again, the abilities, then Respawn (with the last death location),
the teleport to the spawn facing its direction, the default spawn,
difficulty, experience, post effects, the level info, the permission
level, the chunk cache centre and the inventory. A dying guest also gets
the death animation event and no health update while dead, as vanilla's
ServerPlayer.die does.

Guests' commands also ran at the host's permission level: an operator on
a dedicated server could not run operator commands (and LAN guests ran
the host's level). They now run at the guest's own level, as the command
tree they are sent says.

The dedicated server harness covers it: after trading, the vanilla-codec
client is made an operator by the console, runs /kill, respawns, and the
packets from the death screen to the respawned inventory are compared
with vanilla's, then the level must load where it respawned. The client
also stops sending a movement packet beside each teleport acceptance
during the respawn: the 26.3 client sends the acceptance alone, and
vanilla's server kicks a second position in the same tick.

Fixes #566

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 03:11:16 +02:00
Ludovic Marie 92209ddeee Trading on the dedicated server, compared with vanilla's
test_dedicated_server_parity summons a librarian beside the spawn and the
vanilla protocol client right-clicks it: the OpenScreen packet (title as
Entity.getDisplayName, UUIDs left out) and the MerchantOffers packet must
match vanilla's server. Villagers keep Xp, LastRestock and RestocksToday
before their offers are made (vanilla's null offers).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 23:01:02 +02:00
Ludovic Marie 7c8afc8a34 Merge branch 'parity-base' into parity/server-leftovers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 05:44:19 +02:00
Ludovic Marie 0a2601c33a Send recipes, advancements and command replies to players as vanilla does
- ClientboundUpdateRecipesPacket at join: the recipe property sets and the
  stonecutter's recipes, from the data pack (lan/recipes.rs).
- On a player's first tick the minecraft:tick criteria are met: the recipes
  their advancements grant go out in ClientboundRecipeBookAddPacket, then
  ClientboundUpdateAdvancementsPacket with what the player may see
  (lan/advancements.rs).
- Command replies reach remote players as the components vanilla sends:
  Text keeps the Component it was built from (literal, translatable,
  siblings, style), sendFailure wraps the message as vanilla does, and the
  NBT wraps the elements of mixed lists.

The dedicated-server harness drops its known gaps: it compares these
packets (sorted where vanilla's hash maps order them per run) and the
replies to three failing commands, keeps only the first set_time among the
joining packets and turns random ticks off in the generated world.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 05:43:51 +02:00
Ludovic Marie 7322bba2b5 dedicated_server: read the game time as the console prints it
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 03:51:40 +02:00
Ludovic Marie 71e677ed6a dedicated_server: settle the generated world in game ticks, without random ticks
The world was saved 20 wall-clock seconds after force-loading the area, so
on a busy machine chunks were still generating or their fluids flowing,
and random ticks changed blocks while the client was being sent its
chunks: which chunks differed varied from run to run. Wait until every
force-loaded chunk is loaded and 600 game ticks have passed, with
random_tick_speed 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 03:40:50 +02:00
Ludovic Marie de3a285cb3 Headless Horizon client joining a vanilla dedicated server, checked by the harness
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 01:07:19 +02:00
Ludovic Marie 6f84b9ae94 Harness names differing chunks; spawner update tags without keepPacked
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 01:02:14 +02:00
Ludovic Marie 5f5b6119d2 Spawner update tags in chunk packets; harness lists recipes and advancements as known gaps
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 00:57:10 +02:00
Ludovic Marie 4d62899a10 Harness: force-load the spawn area so both servers serve full chunks
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 00:52:35 +02:00
Ludovic Marie 7ede56b596 Dedicated server: vanilla console lines, player chat, /list, legacy ping, chunk tracking, heightmaps and light layers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 00:32:29 +02:00
Ludovic Marie 8d16a937c5 Dedicated server: load the spawn area; vanilla-codec client harness
VanillaProtocolClient joins a server with vanilla's own codecs;
test_dedicated_server_parity.py compares a vanilla and a Horizon dedicated
server serving the same world.

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