[GH-ISSUE #5145] Native mods: the level's random from mod code (level.getRandom()) #1570

Closed
opened 2026-11-02 15:48:05 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @levzzz5154 on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5145

🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally.

Part of #4953 ("The level's random from mod code (level.getRandom())").

A native mod that wants randomness on the server has no way to reach the level's own random (vanilla's Level.random). Java mods call level.getRandom() for machine output chances, ore processing and particles' offsets, which moves vanilla's later draws from the same stream. A native mod using its own RNG behaves differently from its Java original, and vanilla code drawing after it sees a different sequence.

Proposal: a server-level helper native_level_random(dimension) -> Option<&mut LegacyRandom> that returns the level's own World::random, the stream Horizon's ports of vanilla already draw from (explosions' Util.shuffle(list, level.random), insecure_uuid, the initial spawn...). For the level in place and for a parked one. None on a client of a server and for a level that isn't open. A helper, not a hook point: no catalog entry. API next.

Originally created by @levzzz5154 on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5145 > 🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Opus 5.5), not by levzzz5154 personally. Part of #4953 ("The level's random from mod code (`level.getRandom()`)"). A native mod that wants randomness on the server has no way to reach the level's own random (vanilla's `Level.random`). Java mods call `level.getRandom()` for machine output chances, ore processing and particles' offsets, which moves vanilla's later draws from the same stream. A native mod using its own RNG behaves differently from its Java original, and vanilla code drawing after it sees a different sequence. Proposal: a server-level helper `native_level_random(dimension) -> Option<&mut LegacyRandom>` that returns the level's own `World::random`, the stream Horizon's ports of vanilla already draw from (explosions' `Util.shuffle(list, level.random)`, `insecure_uuid`, the initial spawn...). For the level in place and for a parked one. `None` on a client of a server and for a level that isn't open. A helper, not a hook point: no catalog entry. API next.
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#1570
No description provided.