[GH-ISSUE #7355] Proposal:Add stable native hook points for a 1:1 Carpet + Carpet Extra .hnmod port #3216

Open
opened 2026-11-03 04:06:45 +07:00 by bsakaguchi · 4 comments
Owner

Originally created by @bartekchomik26-dotcom on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7355

Update: Based on the agent audit against 0cf1b3d20 (API 359), the general lifecycle, interaction, command (native_commands), and dispenser (native_dispense_item) hooks are already stable. This issue has been updated to track only the missing point-specific vanilla call sites and Scarpet gaps required to finish a 1:1 Carpet + Carpet Extra port.

To build Carpet as an .hnmod without maintaining a massive source patch, we need the following precise contracts:

1. Scarpet Event Gaps

  • Cancellable Player Message Broadcast: We need a hook to intercept and cancel/modify chat messages before they broadcast.
  • Explosion Events: __on_explosion requires a hook at the start of the explosion logic (exposing source, position, affected blocks) and a post-explosion hook.
  • Per-Entity Event Dispatch: A generic per-entity tick/event hook to power Scarpet's EntityEventsGroup.

2. Carpet-Specific Rule Hooks (Precise Call Sites)

These rules are point-specific interventions in vanilla logic, not generic events:

  • Rule: movableBlockEntities
    • Call Site: Piston movement logic. We need an injection point right before the piston checks if a block is immovable, allowing the mod to return true (movable) for specific block entities.
  • Rule: optimizedTNT
    • Call Site: The equivalent of ServerExplosion.calculateExplodedPositions. We need a hook that allows overwriting the position calculation before the damage/block destruction pass.
  • Rule: renewableSponges
    • Call Site: The thunderHit method inside the Guardian entity class, fired immediately after the lightning strike damage is applied.
  • Rule: hopperCounters
    • Call Site: The exact point in HopperBlockEntity where an item successfully moves from the hopper into a container (or vice versa), exposing the transfer amount.
  • Rule: fastRedstoneDust
    • Call Site: RedstoneWireBlock power update logic, to allow overriding the propagation step.

Why this is a "Precise Contract" request:
These are specific, point-in-time interventions required to alter vanilla mechanics. Once these call sites are exposed, Carpet can be built entirely as an .hnmod without patching the engine source.

Originally created by @bartekchomik26-dotcom on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7355 **Update:** Based on the agent audit against `0cf1b3d20` (API 359), the general lifecycle, interaction, command (`native_commands`), and dispenser (`native_dispense_item`) hooks are already stable. This issue has been updated to track *only* the missing point-specific vanilla call sites and Scarpet gaps required to finish a 1:1 Carpet + Carpet Extra port. To build Carpet as an `.hnmod` without maintaining a massive source patch, we need the following precise contracts: ### 1. Scarpet Event Gaps * **Cancellable Player Message Broadcast:** We need a hook to intercept and cancel/modify chat messages before they broadcast. * **Explosion Events:** `__on_explosion` requires a hook at the start of the explosion logic (exposing source, position, affected blocks) and a post-explosion hook. * **Per-Entity Event Dispatch:** A generic per-entity tick/event hook to power Scarpet's `EntityEventsGroup`. ### 2. Carpet-Specific Rule Hooks (Precise Call Sites) These rules are point-specific interventions in vanilla logic, not generic events: * **Rule: `movableBlockEntities`** * *Call Site:* Piston movement logic. We need an injection point right before the piston checks if a block is immovable, allowing the mod to return `true` (movable) for specific block entities. * **Rule: `optimizedTNT`** * *Call Site:* The equivalent of `ServerExplosion.calculateExplodedPositions`. We need a hook that allows overwriting the position calculation before the damage/block destruction pass. * **Rule: `renewableSponges`** * *Call Site:* The `thunderHit` method inside the `Guardian` entity class, fired immediately after the lightning strike damage is applied. * **Rule: `hopperCounters`** * *Call Site:* The exact point in `HopperBlockEntity` where an item successfully moves from the hopper into a container (or vice versa), exposing the transfer amount. * **Rule: `fastRedstoneDust`** * *Call Site:* `RedstoneWireBlock` power update logic, to allow overriding the propagation step. --- **Why this is a "Precise Contract" request:** These are specific, point-in-time interventions required to alter vanilla mechanics. Once these call sites are exposed, Carpet can be built entirely as an `.hnmod` without patching the engine source.
Author
Owner

@testatanucleare13-create commented on GitHub (Nov 2, 2026):

/claim

<!-- gh-comment-id:6581400215 --> @testatanucleare13-create commented on GitHub (Nov 2, 2026): /claim
Author
Owner

@testatanucleare13-create commented on GitHub (Nov 2, 2026):

🤖 Agent: I checked the acceptance criteria against main (0cf1b3d20). The first landing tranche described here appears to be already present as stable, versioned hooks, so adding them again would duplicate API:

  • Lifecycle: native_server_about_to_start / native_server_stopping, native_world_lifecycle open/close phases, and native_server_tick start/end are in place.
  • Generation/entity lifecycle: native_chunk_load(..., new) distinguishes newly generated chunks from saved chunks; native_entity_join_level is cancellable.
  • Player interactions: native_left_click_block, native_use_item_on / native_use_item, and native_interact_entity exist; player tick and both player/dispenser shear hooks are present too.
  • Commands: server registration is native_register_commands; client-side names are registered through native_commands, and game/chat.rs merges them into the chat dispatcher for parsing and completion. The statement that the chat box cannot see native commands looks stale.
  • Carpet Extra dispenser dispatch: native_dispense_item already lets a native mod intercept any item before vanilla behavior selection and own the remainder/event response.

These hook points are in native_hooks.rs and contribute to NATIVE_HOOKS_API (currently 359). Other listed points, such as cancellable player-message broadcast, explosion effects, per-entity event dispatch, and Carpet-specific rule hooks, may still be gaps, but they are outside the stated first tranche and need their own precise contracts/call sites. I made no code changes; I am unclaiming until the issue identifies a remaining unmet behavior rather than hooks already on main.

<!-- gh-comment-id:6581435059 --> @testatanucleare13-create commented on GitHub (Nov 2, 2026): 🤖 Agent: I checked the acceptance criteria against `main` (`0cf1b3d20`). The first landing tranche described here appears to be already present as stable, versioned hooks, so adding them again would duplicate API: - Lifecycle: `native_server_about_to_start` / `native_server_stopping`, `native_world_lifecycle` open/close phases, and `native_server_tick` start/end are in place. - Generation/entity lifecycle: `native_chunk_load(..., new)` distinguishes newly generated chunks from saved chunks; `native_entity_join_level` is cancellable. - Player interactions: `native_left_click_block`, `native_use_item_on` / `native_use_item`, and `native_interact_entity` exist; player tick and both player/dispenser shear hooks are present too. - Commands: server registration is `native_register_commands`; client-side names are registered through `native_commands`, and `game/chat.rs` merges them into the chat dispatcher for parsing and completion. The statement that the chat box cannot see native commands looks stale. - Carpet Extra dispenser dispatch: `native_dispense_item` already lets a native mod intercept any item before vanilla behavior selection and own the remainder/event response. These hook points are in `native_hooks.rs` and contribute to `NATIVE_HOOKS_API` (currently 359). Other listed points, such as cancellable player-message broadcast, explosion effects, per-entity event dispatch, and Carpet-specific rule hooks, may still be gaps, but they are outside the stated first tranche and need their own precise contracts/call sites. I made no code changes; I am unclaiming until the issue identifies a remaining unmet behavior rather than hooks already on main.
Author
Owner

@testatanucleare13-create commented on GitHub (Nov 2, 2026):

/unclaim

<!-- gh-comment-id:6581438983 --> @testatanucleare13-create commented on GitHub (Nov 2, 2026): /unclaim
Author
Owner

@bartekchomik26-dotcom commented on GitHub (Nov 2, 2026):

@testatanucleare13-create — Thanks for the detailed audit against 0cf1b3d20 and API 359. You're completely right—native_commands, native_register_commands, and native_dispense_item already cover the command merging and dispenser interception I mentioned. I've updated the main issue body to strike those out.

I've narrowed the issue down strictly to the gaps you noted: cancellable player-message broadcast, explosion effects, per-entity event dispatch, and the precise rule hooks. I've laid out the exact vanilla call sites for the rule hooks. Let me know if this updated delta looks actionable enough to pick up.

<!-- gh-comment-id:6581906397 --> @bartekchomik26-dotcom commented on GitHub (Nov 2, 2026): @testatanucleare13-create — Thanks for the detailed audit against `0cf1b3d20` and API 359. You're completely right—`native_commands`, `native_register_commands`, and `native_dispense_item` already cover the command merging and dispenser interception I mentioned. I've updated the main issue body to strike those out. I've narrowed the issue down strictly to the gaps you noted: cancellable player-message broadcast, explosion effects, per-entity event dispatch, and the precise rule hooks. I've laid out the exact vanilla call sites for the rule hooks. Let me know if this updated delta looks actionable enough to pick up.
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#3216
No description provided.