[PR #6089] [MERGED] feat(mods): native hooks to decide experience orb merging #6646

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6089
Author: @Xmilon
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: native/xp-orb-merge


📝 Commits (1)

  • 962d50b feat(mods): native hooks to decide experience orb merging

📊 Changes

6 files changed (+285 additions, -34 deletions)

View changed files

📝 crates/horizon-client/src/entities.rs (+0 -25)
📝 crates/horizon-client/src/game.rs (+76 -9)
📝 crates/horizon-client/src/game/native_hooks.rs (+35 -0)
📝 crates/horizon-client/src/game/native_server.rs (+28 -0)
➕ tests/test_experience_orb_merge.py (+126 -0)
➕ tools/native-hook-fragments/experience_orb_merge.json (+20 -0)

📄 Description

🤖 Opened by Xmilon's AI agent (Claude Code, claude-sonnet-5-5), not by Xmilon personally.

What and why

Fixes #6083. Part of #4953.

A mod can now decide how experience orbs merge, and write an orb it keeps:

  • native_experience_orb_can_merge(dimension, into, from, into_value, from_value, can_merge): asked for each pair whose boxes meet, at spawn (ExperienceOrb.tryMergeToExisting; from is 0, the new orb is no entity yet) and on the 20-tick scan (scanForMerges). can_merge starts as vanilla's canMerge answer; a mod may flip it either way.
  • native_experience_orb_merge(dimension, into, from, from_value, canceled): after a yes, cancellable. Both orbs stay; a spawning orb tries the next orb in reach, then spawns on its own.
  • native_set_experience_orb(dimension, id, value, count, age): writes an orb's fields (each optional; 0 for value/count refused).

The tick merge moved from entities::merge_orbs into Game::merge_orbs so it can call the hooks; behaviour without a mod is unchanged. API fragment only (tools/native-hook-fragments/experience_orb_merge.json), no API numbers.

Kind

  • tooling: tools, CI, tests, harnesses

Vanilla reference

ExperienceOrb.tryMergeToExisting, merge, scanForMerges, canMerge. NeoForge has no event for orb merging.

Other projects' code

none

Self-check

  • tests/test_experience_orb_merge.py: compiles the real award_orb, orb_merges and merge_orbs from game.rs with a fake mod; vanilla answer, flip each way, cancel, scan tick and remote client covered. Passes.
  • cargo check and cargo clippy -p horizon-client --lib --bins -- -D warnings: clean. rustfmt and tools/check_public_tree.py: pass.
  • Not run: tools/pr_ready.py harnesses (no vanilla data locally); full test suite left to CI.

🤖 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/6089 **Author:** [@Xmilon](https://github.com/Xmilon) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `native/xp-orb-merge` --- ### 📝 Commits (1) - [`962d50b`](https://github.com/horizon-rust/horizon/commit/962d50bffaa142e19a6be099af5ea365994f3f5e) feat(mods): native hooks to decide experience orb merging ### 📊 Changes **6 files changed** (+285 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entities.rs` (+0 -25) 📝 `crates/horizon-client/src/game.rs` (+76 -9) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+35 -0) 📝 `crates/horizon-client/src/game/native_server.rs` (+28 -0) ➕ `tests/test_experience_orb_merge.py` (+126 -0) ➕ `tools/native-hook-fragments/experience_orb_merge.json` (+20 -0) </details> ### 📄 Description > 🤖 Opened by Xmilon's AI agent (Claude Code, claude-sonnet-5-5), not by Xmilon personally. ## What and why Fixes #6083. Part of #4953. A mod can now decide how experience orbs merge, and write an orb it keeps: - `native_experience_orb_can_merge(dimension, into, from, into_value, from_value, can_merge)`: asked for each pair whose boxes meet, at spawn (`ExperienceOrb.tryMergeToExisting`; `from` is 0, the new orb is no entity yet) and on the 20-tick scan (`scanForMerges`). `can_merge` starts as vanilla's `canMerge` answer; a mod may flip it either way. - `native_experience_orb_merge(dimension, into, from, from_value, canceled)`: after a yes, cancellable. Both orbs stay; a spawning orb tries the next orb in reach, then spawns on its own. - `native_set_experience_orb(dimension, id, value, count, age)`: writes an orb's fields (each optional; 0 for `value`/`count` refused). The tick merge moved from `entities::merge_orbs` into `Game::merge_orbs` so it can call the hooks; behaviour without a mod is unchanged. API fragment only (`tools/native-hook-fragments/experience_orb_merge.json`), no API numbers. ## Kind - [x] tooling: tools, CI, tests, harnesses ## Vanilla reference `ExperienceOrb.tryMergeToExisting`, `merge`, `scanForMerges`, `canMerge`. NeoForge has no event for orb merging. ## Other projects' code none ## Self-check - `tests/test_experience_orb_merge.py`: compiles the real `award_orb`, `orb_merges` and `merge_orbs` from game.rs with a fake mod; vanilla answer, flip each way, cancel, scan tick and remote client covered. Passes. - `cargo check` and `cargo clippy -p horizon-client --lib --bins -- -D warnings`: clean. rustfmt and `tools/check_public_tree.py`: pass. - Not run: `tools/pr_ready.py` harnesses (no vanilla data locally); full test suite left to CI. 🤖 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:24:16 +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#6646
No description provided.