Saved state: burning, air and falling survive a reopen; InLove for every animal

- Guests' player data saves Fire, Air and fall_distance and puts them back
  on their body when they come back (single player's players are guests
  of the integrated server), so a burning player still burns after a
  reopen (#1323); the old single player's level.dat keeps fall_distance
  too (#1327).
- Every Animal saves and loads InLove, so a fed animal stays in love
  across a reopen and is not fed again (#1396).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-23 08:38:58 +02:00
parent 5bb492ca54
commit d522d8fe50
7 changed files with 135 additions and 2 deletions
+12
View File
@@ -310,6 +310,18 @@ mod tests {
}
}
#[test]
fn love_ticks_survive_a_save() {
// Animal.addAdditionalSaveData / readAdditionalSaveData: "InLove" (#1396).
let mut m = rabbit();
m.extra.in_love = 570;
let tag = crate::entity_nbt::mob_to_nbt(&m, [0, 0, 0, 1], None);
assert_eq!(tag.get("InLove"), Some(&horizon_world::nbt::Tag::Int(570)));
let types = HashMap::from([(m.kind.id.clone(), m.kind.clone())]);
let back = crate::entity_nbt::mob_from_nbt(&tag, &types, 2).unwrap();
assert_eq!(back.extra.in_love, 570);
}
#[test]
fn landing_waits_then_real_hop_clock_moves_the_model() {
let mut m = rabbit();