[PR #4097] [MERGED] Native mods: what a machine's tick reaches (neighbouring mod block entities, its block's state) #5416

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4097
Author: @Sylviromi
Created: 10/30/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: native-mod-neighbours


📝 Commits (7)

  • dc925bf Native mods: reach a neighbouring mod block entity from a tick
  • 723a2a4 Native mods: set a block's property from a tick (a machine's lit)
  • 1eeda33 Merge branch 'native-mod-menus' into native-mod-neighbours
  • 3c2a49c Native mods: neighbour changes notify after the change; properties update neighbours
  • b4181cf Merge branch 'native-mod-menus' into native-mod-neighbours
  • a3aa60d Native mods: neighbour helpers are API 7
  • deec904 Merge main; neighbour and block-state helpers are API 18

📊 Changes

2 files changed (+76 additions, -6 deletions)

View changed files

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

📄 Description

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

Stacked on #4072 (on #4055, on #3996): review only the commits after #4072 (dc925bf62 and the next, +53 −1).

What and why

Fixes #4088. Part of #3911 (Mods): the smallest piece of gap "C, energy/fluid/item transfer between blocks" in #1854.

  • native_with_mod_block_entity(pos, change) -> Option<R>, a helper kept as stable as the hook points (API 7): runs change on the mod block entity at a position, to read or change it from a tick, as a generator charging the machine beside it or a pipe handing an item on. None for any other block entity and for the one ticking now (it is out of the world). After the change, as its setChanged would, its chunk is saved next time and, when its items changed, comparators read it again. What energy is stays the mod's, in its own compound.
  • A tick that moved its own items tells comparators too (container_changed), as a furnace's setChanged does.
  • native_set_block_property(pos, key, value), a helper (API 7): sets a property of a block, as a furnace's tick sets its lit (Level.setBlock with UPDATE_ALL, so neighbours and observers hear of it), so a machine shows when it works; the block entity stays.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only (the native mod API); follows BlockEntity.setChanged (Level.blockEntityChanged, updateNeighbourForOutputSignal). Without a mod nothing changes.

Self-check

hook_points_stay_hookable and catalog_matches_hook_points pass (the helper isn't a hook point, so not in the catalog). pr_ready --quick against origin/main at 829c4021a: fmt, clippy, Cargo.lock, public tree and Python tests pass; client tests 688 passed, 1 failed (the axolotl test of #3840, only with prepared resources; passes in CI). Its scope counts the whole stack (519 lines); this PR's own part is +28 −1.

Proof

A GregTech-style test mod (local): a coal generator burns fuel into EU (32 EU/t, 16,000 EU buffer) and gives it through this helper to an LV macerator beside it, which spends 2 EU/t for 200 ticks per ore. Offscreen through horizon-ctl, hoppers feeding coal and iron ore:

After Generator Macerator Hopper under the macerator
~6 s burning (1,486 of 1,600 ticks left), 0 EU (all given away) 3,772 EU, progress 114/200 empty
~15 s 0 EU 10,162 EU, one ore done 2 iron dust
~27 s 2,024 EU (the macerator is full) 15,998 EU, three ores done 6 iron dust

With native_set_block_property, the generator's and the macerator's lit follow whether they burn and work, and their blockstates show their active faces then.

A vanilla furnace then smelted the mod's iron dust into iron ingots (its own smelting recipe).

🤖 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/4097 **Author:** [@Sylviromi](https://github.com/Sylviromi) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `native-mod-neighbours` --- ### 📝 Commits (7) - [`dc925bf`](https://github.com/horizon-rust/horizon/commit/dc925bf620cc2033a511999a1737e09805805335) Native mods: reach a neighbouring mod block entity from a tick - [`723a2a4`](https://github.com/horizon-rust/horizon/commit/723a2a44cbe6f6e88ced4550d2c16d8b072b07cc) Native mods: set a block's property from a tick (a machine's lit) - [`1eeda33`](https://github.com/horizon-rust/horizon/commit/1eeda33ae5f7ede586218a5db1fc7bca2ad95cb1) Merge branch 'native-mod-menus' into native-mod-neighbours - [`3c2a49c`](https://github.com/horizon-rust/horizon/commit/3c2a49c4efa44f0d0030f7038e635bded055e22b) Native mods: neighbour changes notify after the change; properties update neighbours - [`b4181cf`](https://github.com/horizon-rust/horizon/commit/b4181cf43acc4b587212f8dee339bbb23e83f4a2) Merge branch 'native-mod-menus' into native-mod-neighbours - [`a3aa60d`](https://github.com/horizon-rust/horizon/commit/a3aa60d7bc57e7389ccb090a857c8e49249fd852) Native mods: neighbour helpers are API 7 - [`deec904`](https://github.com/horizon-rust/horizon/commit/deec9041acc6310ab0a30ea773324f27cbcfb211) Merge main; neighbour and block-state helpers are API 18 ### 📊 Changes **2 files changed** (+76 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/native_hooks.rs` (+72 -6) 📝 `docs/native-mods.md` (+4 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, Claude Opus 5.5), not by Sylviromi personally. **Stacked on #4072 (on #4055, on #3996): review only the commits after #4072** (`dc925bf62` and the next, +53 −1). ## What and why Fixes #4088. Part of #3911 (Mods): the smallest piece of gap "C, energy/fluid/item transfer between blocks" in #1854. - `native_with_mod_block_entity(pos, change) -> Option<R>`, a helper kept as stable as the hook points (API 7): runs `change` on the mod block entity at a position, to read or change it from a tick, as a generator charging the machine beside it or a pipe handing an item on. None for any other block entity and for the one ticking now (it is out of the world). After the change, as its `setChanged` would, its chunk is saved next time and, when its items changed, comparators read it again. What energy is stays the mod's, in its own compound. - A tick that moved its own items tells comparators too (`container_changed`), as a furnace's `setChanged` does. - `native_set_block_property(pos, key, value)`, a helper (API 7): sets a property of a block, as a furnace's tick sets its `lit` (`Level.setBlock` with `UPDATE_ALL`, so neighbours and observers hear of it), so a machine shows when it works; the block entity stays. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (the native mod API); follows `BlockEntity.setChanged` (`Level.blockEntityChanged`, `updateNeighbourForOutputSignal`). Without a mod nothing changes. ## Self-check `hook_points_stay_hookable` and `catalog_matches_hook_points` pass (the helper isn't a hook point, so not in the catalog). **pr_ready** `--quick` against origin/main at 829c4021a: fmt, clippy, Cargo.lock, public tree and Python tests pass; client tests 688 passed, 1 failed (the axolotl test of #3840, only with prepared resources; passes in CI). Its scope counts the whole stack (519 lines); this PR's own part is +28 −1. ## Proof A GregTech-style test mod (local): a coal generator burns fuel into EU (32 EU/t, 16,000 EU buffer) and gives it through this helper to an LV macerator beside it, which spends 2 EU/t for 200 ticks per ore. Offscreen through `horizon-ctl`, hoppers feeding coal and iron ore: | After | Generator | Macerator | Hopper under the macerator | | --- | --- | --- | --- | | ~6 s | burning (1,486 of 1,600 ticks left), 0 EU (all given away) | 3,772 EU, progress 114/200 | empty | | ~15 s | 0 EU | 10,162 EU, one ore done | 2 iron dust | | ~27 s | 2,024 EU (the macerator is full) | 15,998 EU, three ores done | 6 iron dust | With `native_set_block_property`, the generator's and the macerator's `lit` follow whether they burn and work, and their blockstates show their active faces then. A vanilla furnace then smelted the mod's iron dust into iron ingots (its own smelting recipe). 🤖 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 05:12:27 +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#5416
No description provided.