From e2b3f7b4e94a01a6236675c0bfdb41fe70f3d25e Mon Sep 17 00:00:00 2001 From: Ludovic Marie <136255825+ludovic111@users.noreply.github.com> Date: Mon, 12 Oct 2026 13:26:18 +0200 Subject: [PATCH] Keep unsimulated entities' UUIDs across saves and save player equipment as vanilla save_entities forgot the UUID and compound of entities Horizon keeps but does not simulate, so the save on quit gave them new UUIDs. The player's equipment is written as LivingEntity does: omitted when empty, where PlayerEquipment.isEmpty also counts the selected hotbar item. Co-Authored-By: Claude Opus 5.5 --- crates/horizon-client/src/game/persist.rs | 1 + crates/horizon-client/src/save.rs | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/horizon-client/src/game/persist.rs b/crates/horizon-client/src/game/persist.rs index 5bc32a2e2..948039fcc 100644 --- a/crates/horizon-client/src/game/persist.rs +++ b/crates/horizon-client/src/game/persist.rs @@ -815,6 +815,7 @@ impl Game<'_> { .chain(self.armor_stands.iter().map(|e| e.id)) .chain(self.item_frames.iter().map(|e| e.id)) .chain(self.paintings.iter().map(|e| e.id)) + .chain(self.others.iter().map(|e| e.id)) .collect(); self.persist.uuids.retain(|id, _| alive.contains(id)); self.persist.raw.retain(|id, _| alive.contains(id)); diff --git a/crates/horizon-client/src/save.rs b/crates/horizon-client/src/save.rs index 5668bfde2..2029250fd 100644 --- a/crates/horizon-client/src/save.rs +++ b/crates/horizon-client/src/save.rs @@ -1837,8 +1837,16 @@ impl Level { }), ), ]; - // Vanilla writes `equipment` even when empty and omits an empty effect list. - entries.push(("equipment", Tag::compound(equipment))); + // LivingEntity.addAdditionalSaveData omits empty equipment and an empty + // effect list. PlayerEquipment.isEmpty also counts the selected hotbar + // item, which the codec never writes: holding one saves `equipment: {}`. + let holding = self + .inventory + .iter() + .any(|(slot, _, count, _)| i32::from(*slot) == self.selected_slot && *count > 0); + if holding || !equipment.is_empty() { + entries.push(("equipment", Tag::compound(equipment))); + } if self.active_effects.is_empty() { entries.retain(|(key, _)| *key != "active_effects"); }