[PR #4817] [MERGED] Native mods: set a server block (API next) #5869

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4817
Author: @arismoko
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: native-set-block-4808


📝 Commits (2)

  • f98890b Native mods: add server block-setting helper
  • bceac87 Native mods: renumber set-block hook to API 24, create block entities, drain level events, fix flags docs

📊 Changes

2 files changed (+45 additions, -1 deletions)

View changed files

📝 crates/horizon-client/src/game/native_hooks.rs (+39 -1)
📝 docs/native-mods.md (+6 -0)

📄 Description

🤖 Opened by Aria's agent swarm, Dyna, not by Aria.

Fixes #4808

Adds Game::native_set_block for the current authoritative dimension. It accepts a registered BlockStateId and vanilla update flags, and returns whether a block changed. It rejects clients, other dimensions and invalid state IDs. It uses the same with_level and Behaviours::set_block path as native_set_block_property, including that path's existing neighbour updates, block-entity handling and client block log. It does not add a new hook or a NeoForge event; the vanilla counterpart is Level.setBlock(BlockPos, BlockState, int).

This is a Game helper like native_set_block_property. Hooks holding only GameLevel cannot call it yet. The helper cannot select a different dimension: it accepts only the dimension currently loaded into Game. The API version is next; its number will follow the next available version at merge.

Exact head: f98890b386. A throwaway native mixin replaced a chest with diamond on the integrated server, and a LAN guest read the diamond block. A dedicated server ran the same helper check. Both checks verified rejection of a wrong dimension and invalid state, a successful change, and a false result for a repeated change. These checks did not separately verify neighbour updates or block-entity removal; those use the existing set-block path.

Clippy fails on the existing main-branch manual_range_contains lint in crates/horizon-world/src/worldgen/aquifer/noise_based.rs:466; it was reproduced on unchanged main.

pr_ready (tools/pr_ready.py --base HEAD^ on LT-24-005, against HEAD^ at 278940963, 1 min 52 s)

Check Result
Scope ✅ 2 files, +23 −0
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (26 s)
rustfmt ✅ (6 s)
clippy ❌ failed (12 s)
tests: horizon-client ✅ 1231 passed (1 min 6 s)
doc tests ✅ 0 passed (1 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 ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🔄 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/4817 **Author:** [@arismoko](https://github.com/arismoko) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `native-set-block-4808` --- ### 📝 Commits (2) - [`f98890b`](https://github.com/horizon-rust/horizon/commit/f98890b3867b2034777ec21848fdd9f14828d94e) Native mods: add server block-setting helper - [`bceac87`](https://github.com/horizon-rust/horizon/commit/bceac876298a127478564a27db0c1a5a508d8840) Native mods: renumber set-block hook to API 24, create block entities, drain level events, fix flags docs ### 📊 Changes **2 files changed** (+45 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+39 -1) 📝 `docs/native-mods.md` (+6 -0) </details> ### 📄 Description > 🤖 Opened by Aria's agent swarm, Dyna, not by Aria. Fixes #4808 Adds `Game::native_set_block` for the current authoritative dimension. It accepts a registered `BlockStateId` and vanilla update flags, and returns whether a block changed. It rejects clients, other dimensions and invalid state IDs. It uses the same `with_level` and `Behaviours::set_block` path as `native_set_block_property`, including that path's existing neighbour updates, block-entity handling and client block log. It does not add a new hook or a NeoForge event; the vanilla counterpart is `Level.setBlock(BlockPos, BlockState, int)`. This is a `Game` helper like `native_set_block_property`. Hooks holding only `GameLevel` cannot call it yet. The helper cannot select a different dimension: it accepts only the dimension currently loaded into `Game`. The API version is next; its number will follow the next available version at merge. Exact head: f98890b3867b2034777ec21848fdd9f14828d94e. A throwaway native mixin replaced a chest with diamond on the integrated server, and a LAN guest read the diamond block. A dedicated server ran the same helper check. Both checks verified rejection of a wrong dimension and invalid state, a successful change, and a false result for a repeated change. These checks did not separately verify neighbour updates or block-entity removal; those use the existing set-block path. Clippy fails on the existing main-branch `manual_range_contains` lint in `crates/horizon-world/src/worldgen/aquifer/noise_based.rs:466`; it was reproduced on unchanged main. **pr_ready** (`tools/pr_ready.py --base HEAD^` on LT-24-005, against HEAD^ at 278940963, 1 min 52 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +23 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (26 s) | | rustfmt | ✅ (6 s) | | clippy | ❌ failed (12 s) | | tests: horizon-client | ✅ 1231 passed (1 min 6 s) | | doc tests | ✅ 0 passed (1 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 | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:15:33 +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#5869
No description provided.