[PR #5214] [MERGED] Unique random UUIDs: mobs generated in a pack no longer share one #6143

Closed
opened 2026-11-03 06:14:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5214
Author: @ludovic111
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/unique-random-uuids


📝 Commits (1)

  • fa0de01 Unique random UUIDs: mobs generated in a pack no longer share one

📊 Changes

1 file changed (+32 additions, -10 deletions)

View changed files

📝 crates/horizon-client/src/save.rs (+32 -10)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Fixes #5207: mobs generated in packs shared one UUID, so vanilla clients saw all but one of them frozen.

The bug

save::random_uuid() seeded each UUID from the clock alone (SystemTime nanos xor the pid). Two calls in the same clock tick (a microsecond on macOS) returned the same UUID, and chunk generation makes a whole pack of mobs (chickens, armadillos, fish) in well under that. Vanilla's client keeps one entity per UUID: EntityLookup.add logs Duplicate entity UUID and doesn't index the rest. Those stay in their section, so they render and push the player, but level.getEntity(id) doesn't find them, so handleMoveEntity drops every move the server sends for them. On a vanilla client they never move.

Seen in a 20-minute session of the vanilla 26.3 client on a generated world (seed 20261031): 1074 Duplicate entity UUID warnings. An armadillo the server walked from (43, 77, 38) to (39.8, 76, 31.8) stayed at (43.0, 77.0, 38.0) on the client. The tracker had sent it every move, but getEntity(id) was null on the client. The frozen armadillo also pushed the player where the server had no mob, which the anticheat's movement prediction (log-only) read as moves the keys can't make: that's how this was found.

The fix

random_uuid() is seeded once (clock and pid, as before), then each call takes the next step of one shared atomic counter through SplitMix64's mixer, a bijection: two calls never get the same input, so they never get the same output. It's still a version 4 UUID. All 23 callers (mobs, items, orbs, trial spawners, creaking, /data) get the fix with no change.

Tests

  • New save::tests::random_uuids_made_at_once_differ: 10,000 back-to-back calls give 10,000 distinct UUIDs. On the old function it fails: 2,468 distinct out of 10,000.
  • The vanilla 26.3 client at the same spot of the same world, with this fix: 0 Duplicate entity UUID warnings (55 before), and the armadillo moves on the client (interpolating 45.46 → 45.47), as the server moves it.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at caf83890c, 9 min 23 s)

Check Result
Scope ✅ 1 files, +32 −10
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 16 s)
rustfmt ✅ (6 s)
clippy ✅ (1 min 10 s)
tests: horizon-client ✅ 1343 passed (6 min 24 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 56 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot, entity_model and 44 more

Clean-room: vanilla 26.3's client (ClientPacketListener.handleMoveEntity, EntityLookup.add), no other project's code. SplitMix64 is public-domain (Steele, Lea and Flood, 2014).

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5214 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/unique-random-uuids` --- ### 📝 Commits (1) - [`fa0de01`](https://github.com/horizon-rust/horizon/commit/fa0de01c992010f985e4ed8448b75e66287cd253) Unique random UUIDs: mobs generated in a pack no longer share one ### 📊 Changes **1 file changed** (+32 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/save.rs` (+32 -10) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #5207: mobs generated in packs shared one UUID, so vanilla clients saw all but one of them frozen. ## The bug `save::random_uuid()` seeded each UUID from the clock alone (`SystemTime` nanos xor the pid). Two calls in the same clock tick (a microsecond on macOS) returned the same UUID, and chunk generation makes a whole pack of mobs (chickens, armadillos, fish) in well under that. Vanilla's client keeps one entity per UUID: `EntityLookup.add` logs `Duplicate entity UUID` and doesn't index the rest. Those stay in their section, so they render and push the player, but `level.getEntity(id)` doesn't find them, so `handleMoveEntity` drops every move the server sends for them. On a vanilla client they never move. Seen in a 20-minute session of the vanilla 26.3 client on a generated world (seed 20261031): 1074 `Duplicate entity UUID` warnings. An armadillo the server walked from (43, 77, 38) to (39.8, 76, 31.8) stayed at (43.0, 77.0, 38.0) on the client. The tracker had sent it every move, but `getEntity(id)` was null on the client. The frozen armadillo also pushed the player where the server had no mob, which the anticheat's movement prediction (log-only) read as moves the keys can't make: that's how this was found. ## The fix `random_uuid()` is seeded once (clock and pid, as before), then each call takes the next step of one shared atomic counter through SplitMix64's mixer, a bijection: two calls never get the same input, so they never get the same output. It's still a version 4 UUID. All 23 callers (mobs, items, orbs, trial spawners, creaking, `/data`) get the fix with no change. ## Tests - New `save::tests::random_uuids_made_at_once_differ`: 10,000 back-to-back calls give 10,000 distinct UUIDs. On the old function it fails: **2,468 distinct out of 10,000**. - The vanilla 26.3 client at the same spot of the same world, with this fix: 0 `Duplicate entity UUID` warnings (55 before), and the armadillo moves on the client (interpolating 45.46 → 45.47), as the server moves it. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at caf83890c, 9 min 23 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +32 −10 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 16 s) | | rustfmt | ✅ (6 s) | | clippy | ✅ (1 min 10 s) | | tests: horizon-client | ✅ 1343 passed (6 min 24 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 56 affected, to run in CI (--quick): arrow, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot, entity_model and 44 more | Clean-room: vanilla 26.3's client (`ClientPacketListener.handleMoveEntity`, `EntityLookup.add`), no other project's code. SplitMix64 is public-domain (Steele, Lea and Flood, 2014). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:14:54 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6143
No description provided.