[PR #5641] [MERGED] fix(saves): thrown snowballs, eggs and ender pearls are saved with their chunk #6409

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

📋 Pull Request Information

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

Base: main ← Head: fix/save-thrown-projectiles


📝 Commits (1)

  • db42089 fix(saves): thrown snowballs, eggs and ender pearls are saved with their chunk

📊 Changes

5 files changed (+219 additions, -31 deletions)

View changed files

📝 crates/horizon-client/src/entity_nbt.rs (+154 -9)
📝 crates/horizon-client/src/game/creatures.rs (+12 -2)
📝 crates/horizon-client/src/game/deflect.rs (+9 -8)
📝 crates/horizon-client/src/game/persist.rs (+40 -12)
📝 crates/horizon-client/src/projectiles.rs (+4 -0)

📄 Description

What and why

Horizon saved arrows and fireballs, but no thrown snowball, egg or ender pearl
A pearl in flight when the world closed or its chunk unloaded was gone, and a saved one from a vanilla world never came back to life
Vanilla saves all three: none of their entity types is noSave()

They are now written to the chunk's entities as ThrowableItemProjectile writes them
That means the Entity keys, Projectile's Owner, LeftOwner (only when set) and HasBeenShot, and the Item it flies as
A loaded Item (a blue egg's, a renamed one's) and UUID stay while the projectile is loaded and has not moved, as for arrows and fireballs
Otherwise the Item is the type's default item
They load back with their position, motion, rotation, LeftOwner and owner
On a chunk unload every projectile the chunk saves is removed with it, fireballs included, so a reloaded chunk doesn't hold two copies
One predicate (saved_with_chunk) decides both the save and the removal

A projectile now keeps its owner's UUID, as Projectile.owner keeps its EntityReference
It is set when the projectile is added: the acting player's UUID (the guest who threw it, or the window's own player on the default server thread), or the mob's
That is what its save writes as Owner, also once a guest has left, and also for an owner not found when it loaded
A projectile a player or another projectile turns back (a ghast's fireball, a wind charge) takes its new owner's UUID along
Before, every player-owned projectile was saved with the level's player UUID, a guest's too, and an owner not found was dropped on the next save
On load, the Owner of an arrow, a fireball or a thrown item is a connected guest again, or else a loaded mob
So a guest's arrow or fireball now reloads as theirs, and an ender pearl saved in flight still teleports its thrower once it lands

The thrown kinds share one id table, one writer and one reader (throwable_to_nbt, throwable_from_nbt)
Projectile's keys are in put_projectile, now shared with fireballs
Another thrown kind is one row in the table

Checked in real games with a fresh HORIZON_HOME, on both single-player paths
A snowball thrown up from y 300 is in the entity region after a save
A pearl thrown up from y 300, then a quit in flight: on reopening it falls on, lands and teleports the player with its 5 damage, on the server thread and in-frame
Tests: a round trip of all three kinds (flight, item, owner, LeftOwner, HasBeenShot), a loaded blue egg's item kept over its compound, an owner not here kept through a moved resave, and which kinds the chunk saves and removes

Left as is: a player's ender pearls stay in their chunk, as a vanilla autosave has them
Vanilla moves them into the player's data (ender_pearls) when the player leaves, spawns them again on join and keeps their chunk loaded
So a pearl far away (a stasis chamber) waits for its chunk, and a vanilla save's ender_pearls stay in the player's data unspawned
Left as is: a guest's pearls are not removed when the guest leaves a LAN world
Left as is: an owner who connects after the chunk loaded is not found later, though their UUID is kept (vanilla looks it up when needed)
Left as is: a colored egg thrown in Horizon saves minecraft:egg, since the thrown stack isn't recorded
Left as is: a projectile that moved after loading saves its type's default Item, and can_break is not kept, because Horizon keeps the loaded compound only for unmoved ones
Left as is: a projectile in a chunk that is not loaded when the world closes isn't saved, as for arrows
Left as is: thrown splash and lingering potions and experience bottles are their own state in Horizon, and still are not saved

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

world/entity/projectile/throwableitemprojectile/ThrowableItemProjectile.java:56-65 (Item, the default item when absent)
world/entity/projectile/Projectile.java:101-111 and :118-123 (Owner as an EntityReference, LeftOwner only when set, HasBeenShot)
world/entity/EntityTypes.java:364-367, :399-406, :917-920 (egg, ender pearl and snowball, none noSave())
world/entity/Entity.java:4122-4128 (shouldBeSaved)
server/level/ServerPlayer.java:515-543 and server/players/PlayerList.java:324-326 (a player's pearls in their data, removed with them)

Other projects' code

none

Self-check

Check Result
Scope ✅ 5 files, +219 −31
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 510 passed (59 s)
rustfmt ✅ (9 s)
clippy ✅ (2 min 18 s)
tests: horizon-client ✅ 1581 passed (5 min 40 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 (--quick): 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/5641 **Author:** [@reservedbytes](https://github.com/reservedbytes) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/save-thrown-projectiles` --- ### 📝 Commits (1) - [`db42089`](https://github.com/horizon-rust/horizon/commit/db4208923ef3328fef563c4a6b52082ae7c81006) fix(saves): thrown snowballs, eggs and ender pearls are saved with their chunk ### 📊 Changes **5 files changed** (+219 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/entity_nbt.rs` (+154 -9) 📝 `crates/horizon-client/src/game/creatures.rs` (+12 -2) 📝 `crates/horizon-client/src/game/deflect.rs` (+9 -8) 📝 `crates/horizon-client/src/game/persist.rs` (+40 -12) 📝 `crates/horizon-client/src/projectiles.rs` (+4 -0) </details> ### 📄 Description ## What and why Horizon saved arrows and fireballs, but no thrown snowball, egg or ender pearl A pearl in flight when the world closed or its chunk unloaded was gone, and a saved one from a vanilla world never came back to life Vanilla saves all three: none of their entity types is `noSave()` They are now written to the chunk's entities as `ThrowableItemProjectile` writes them That means the `Entity` keys, `Projectile`'s `Owner`, `LeftOwner` (only when set) and `HasBeenShot`, and the `Item` it flies as A loaded `Item` (a blue egg's, a renamed one's) and UUID stay while the projectile is loaded and has not moved, as for arrows and fireballs Otherwise the `Item` is the type's default item They load back with their position, motion, rotation, `LeftOwner` and owner On a chunk unload every projectile the chunk saves is removed with it, fireballs included, so a reloaded chunk doesn't hold two copies One predicate (`saved_with_chunk`) decides both the save and the removal A projectile now keeps its owner's UUID, as `Projectile.owner` keeps its `EntityReference` It is set when the projectile is added: the acting player's UUID (the guest who threw it, or the window's own player on the default server thread), or the mob's That is what its save writes as `Owner`, also once a guest has left, and also for an owner not found when it loaded A projectile a player or another projectile turns back (a ghast's fireball, a wind charge) takes its new owner's UUID along Before, every player-owned projectile was saved with the level's player UUID, a guest's too, and an owner not found was dropped on the next save On load, the `Owner` of an arrow, a fireball or a thrown item is a connected guest again, or else a loaded mob So a guest's arrow or fireball now reloads as theirs, and an ender pearl saved in flight still teleports its thrower once it lands The thrown kinds share one id table, one writer and one reader (`throwable_to_nbt`, `throwable_from_nbt`) `Projectile`'s keys are in `put_projectile`, now shared with fireballs Another thrown kind is one row in the table Checked in real games with a fresh `HORIZON_HOME`, on both single-player paths A snowball thrown up from y 300 is in the entity region after a save A pearl thrown up from y 300, then a quit in flight: on reopening it falls on, lands and teleports the player with its 5 damage, on the server thread and in-frame Tests: a round trip of all three kinds (flight, item, owner, `LeftOwner`, `HasBeenShot`), a loaded blue egg's item kept over its compound, an owner not here kept through a moved resave, and which kinds the chunk saves and removes Left as is: a player's ender pearls stay in their chunk, as a vanilla autosave has them Vanilla moves them into the player's data (`ender_pearls`) when the player leaves, spawns them again on join and keeps their chunk loaded So a pearl far away (a stasis chamber) waits for its chunk, and a vanilla save's `ender_pearls` stay in the player's data unspawned Left as is: a guest's pearls are not removed when the guest leaves a LAN world Left as is: an owner who connects after the chunk loaded is not found later, though their UUID is kept (vanilla looks it up when needed) Left as is: a colored egg thrown in Horizon saves `minecraft:egg`, since the thrown stack isn't recorded Left as is: a projectile that moved after loading saves its type's default `Item`, and `can_break` is not kept, because Horizon keeps the loaded compound only for unmoved ones Left as is: a projectile in a chunk that is not loaded when the world closes isn't saved, as for arrows Left as is: thrown splash and lingering potions and experience bottles are their own state in Horizon, and still are not saved ## Kind - [x] 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 `world/entity/projectile/throwableitemprojectile/ThrowableItemProjectile.java:56-65` (`Item`, the default item when absent) `world/entity/projectile/Projectile.java:101-111` and `:118-123` (`Owner` as an `EntityReference`, `LeftOwner` only when set, `HasBeenShot`) `world/entity/EntityTypes.java:364-367`, `:399-406`, `:917-920` (egg, ender pearl and snowball, none `noSave()`) `world/entity/Entity.java:4122-4128` (`shouldBeSaved`) `server/level/ServerPlayer.java:515-543` and `server/players/PlayerList.java:324-326` (a player's pearls in their data, removed with them) ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 5 files, +219 −31 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 510 passed (59 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (2 min 18 s) | | tests: horizon-client | ✅ 1581 passed (5 min 40 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 (--quick): 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 06:20:06 +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#6409
No description provided.