From b7fcd446b6eed116764021d0c13e20e795a63b3c Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Sun, 25 Oct 2026 09:36:32 +0100 Subject: [PATCH] Fireballs: LeftOwner and HasBeenShot are saved as Projectile writes them Projectile.addAdditionalSaveData writes LeftOwner only when it is set and HasBeenShot always (true from the first tick on); fireball_to_nbt wrote LeftOwner:0b and no HasBeenShot. Same shape as arrow_to_nbt. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/entity_nbt.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/horizon-client/src/entity_nbt.rs b/crates/horizon-client/src/entity_nbt.rs index 3c014e59b..bf0764a6b 100644 --- a/crates/horizon-client/src/entity_nbt.rs +++ b/crates/horizon-client/src/entity_nbt.rs @@ -1183,7 +1183,17 @@ pub fn fireball_to_nbt( "acceleration_power", Tag::Double(p.acceleration.to_bits()), ); - put(&mut tag, "LeftOwner", Tag::Byte(i8::from(p.left_owner))); + // Projectile: LeftOwner only when set; HasBeenShot once it has ticked + // (a fireball saved before its first tick keeps what it was loaded with). + if let Tag::Compound(map) = &mut tag { + map.remove(&"LeftOwner".into()); + } + if p.left_owner { + put(&mut tag, "LeftOwner", Tag::Byte(1)); + } + if p.age > 0 || tag.get("HasBeenShot").is_none() { + put(&mut tag, "HasBeenShot", Tag::Byte(i8::from(p.age > 0))); + } if let Some(power) = power { put(&mut tag, "ExplosionPower", Tag::Byte(power as i8)); } @@ -2214,6 +2224,9 @@ mod fireball_nbt_tests { let back = fireball_to_nbt(&p, [1, 2, 3, 4], None, None).unwrap(); assert_eq!(number(back.get("ExplosionPower")), Some(4)); assert_eq!(float(back.get("acceleration_power")), Some(0.0)); + // Projectile.addAdditionalSaveData: no LeftOwner unless set, HasBeenShot always. + assert!(back.get("LeftOwner").is_none()); + assert_eq!(number(back.get("HasBeenShot")), Some(0)); assert_eq!( read_doubles::<3>(back.get("Motion")), Some([0.0, -0.5, 1.0])