[PR #2199] [MERGED] Experience orbs: wider pickup area, merging, and lava bounce #4096

Closed
opened 2026-11-03 04:14:39 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2199
Author: @kacpherek
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/xp-orbs


📝 Commits (3)

  • ee19d2c Experience orbs: wider pickup area, merging, and lava bounce
  • 92e5902 Give merged orbs their value once per count for LAN guests and dedicated players
  • 8239417 block_removal: print a merged orb once per count on both sides

📊 Changes

10 files changed (+173 additions, -42 deletions)

View changed files

📝 crates/horizon-client/src/entities.rs (+57 -9)
📝 crates/horizon-client/src/entity_nbt.rs (+12 -8)
📝 crates/horizon-client/src/game.rs (+58 -10)
📝 crates/horizon-client/src/game/commands.rs (+2 -0)
📝 crates/horizon-client/src/game/dispense_fixture.rs (+10 -6)
📝 crates/horizon-client/src/game/lan_actions.rs (+7 -1)
📝 crates/horizon-client/src/game/pickups.rs (+2 -0)
📝 crates/horizon-client/src/game/remote.rs (+6 -1)
📝 crates/horizon-client/src/game/spill.rs (+6 -6)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java (+13 -1)

📄 Description

What and why

Three experience orb behaviours differed from vanilla.

  1. Pickup reach. Orbs were collected only when they touched the player's own box. Vanilla collects them inside the box inflated by (1, 0.5, 1), the same area dropped items already use here. Orbs now reach the player from about a block away.
  2. Merging. New orbs never merged, so a big XP drop became a cloud of separate orbs. Orbs now carry a count and merge the way vanilla does:
    • A newly awarded orb joins an existing orb of the same value within a 1 block box when the ids are a multiple of 40 apart (the merge id the code already drew from the level random), adding 1 to its count and resetting its age.
    • Every 20 ticks (tickCount % 20 == 1) an orb absorbs nearby orbs that can merge: counts add up and the smaller age is kept.
    • Picking up a merged orb gives its value once per count, one take every 2 ticks, and the orb stays until the count runs out.
    • The count is saved and loaded (Count) instead of being expanded into many orbs or lost.
    • Merging does not run for a client connected to someone else's server; that server owns the orbs. Villager trade XP orbs are spawned directly and are not merged, as in vanilla.
  3. Lava. An orb inside lava now gets thrown back out with a random sideways push and an upward speed of 0.2, instead of sinking.

Vanilla reference

  • Player.aiStep: pickup area getBoundingBox().inflate(1.0, 0.5, 1.0).
  • ExperienceOrb.tryMergeToExisting, canMerge, scanForMerges, merge, awardWithDirection.
  • ExperienceOrb.playerTouch: takeXpDelay = 2, count--, discard at 0.
  • ExperienceOrb.tick: the lava branch sets the motion to ((r - r) * 0.2F, 0.2F, (r - r) * 0.2F); addAdditionalSaveData / readAdditionalSaveData for Count.

Left out

Vanilla picks a random orb from the pickup area; here the first one in the list is still taken. Orbs have no random of their own in Horizon, so lava draws from a fresh entity random on first use and does not touch the level stream.

Self-check

cargo check -p horizon-client passes (also with --tests and --example client_probe). One existing unit test, orbs_expand_their_count, became orbs_keep_their_count because a saved Count now loads as one merged orb.


🔄 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/2199 **Author:** [@kacpherek](https://github.com/kacpherek) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/xp-orbs` --- ### 📝 Commits (3) - [`ee19d2c`](https://github.com/horizon-rust/horizon/commit/ee19d2c00cb0eb34cb33e2803c4208edd3bd35c2) Experience orbs: wider pickup area, merging, and lava bounce - [`92e5902`](https://github.com/horizon-rust/horizon/commit/92e59024f250df66bb7e0daf54beb33b38891b52) Give merged orbs their value once per count for LAN guests and dedicated players - [`8239417`](https://github.com/horizon-rust/horizon/commit/823941756f2981a76611538c1e66351b43da8b02) block_removal: print a merged orb once per count on both sides ### 📊 Changes **10 files changed** (+173 additions, -42 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entities.rs` (+57 -9) 📝 `crates/horizon-client/src/entity_nbt.rs` (+12 -8) 📝 `crates/horizon-client/src/game.rs` (+58 -10) 📝 `crates/horizon-client/src/game/commands.rs` (+2 -0) 📝 `crates/horizon-client/src/game/dispense_fixture.rs` (+10 -6) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+7 -1) 📝 `crates/horizon-client/src/game/pickups.rs` (+2 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+6 -1) 📝 `crates/horizon-client/src/game/spill.rs` (+6 -6) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaDispenserOracle.java` (+13 -1) </details> ### 📄 Description ## What and why Three experience orb behaviours differed from vanilla. 1. **Pickup reach.** Orbs were collected only when they touched the player's own box. Vanilla collects them inside the box inflated by (1, 0.5, 1), the same area dropped items already use here. Orbs now reach the player from about a block away. 2. **Merging.** New orbs never merged, so a big XP drop became a cloud of separate orbs. Orbs now carry a `count` and merge the way vanilla does: - A newly awarded orb joins an existing orb of the same value within a 1 block box when the ids are a multiple of 40 apart (the merge id the code already drew from the level random), adding 1 to its count and resetting its age. - Every 20 ticks (`tickCount % 20 == 1`) an orb absorbs nearby orbs that can merge: counts add up and the smaller age is kept. - Picking up a merged orb gives its value once per count, one take every 2 ticks, and the orb stays until the count runs out. - The count is saved and loaded (`Count`) instead of being expanded into many orbs or lost. - Merging does not run for a client connected to someone else's server; that server owns the orbs. Villager trade XP orbs are spawned directly and are not merged, as in vanilla. 3. **Lava.** An orb inside lava now gets thrown back out with a random sideways push and an upward speed of 0.2, instead of sinking. ## Vanilla reference - `Player.aiStep`: pickup area `getBoundingBox().inflate(1.0, 0.5, 1.0)`. - `ExperienceOrb.tryMergeToExisting`, `canMerge`, `scanForMerges`, `merge`, `awardWithDirection`. - `ExperienceOrb.playerTouch`: `takeXpDelay = 2`, `count--`, discard at 0. - `ExperienceOrb.tick`: the lava branch sets the motion to `((r - r) * 0.2F, 0.2F, (r - r) * 0.2F)`; `addAdditionalSaveData` / `readAdditionalSaveData` for `Count`. ## Left out Vanilla picks a random orb from the pickup area; here the first one in the list is still taken. Orbs have no random of their own in Horizon, so lava draws from a fresh entity random on first use and does not touch the level stream. ## Self-check `cargo check -p horizon-client` passes (also with `--tests` and `--example client_probe`). One existing unit test, `orbs_expand_their_count`, became `orbs_keep_their_count` because a saved `Count` now loads as one merged orb. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 04:14:39 +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#4096
No description provided.