Merge pull request #807 from ludovic111/fix/guest-death-health
🤖 Agent: merged: dead guest gets health 0. Combined check of main + perf-ticks-6's six: clippy, tests, 8 harnesses PASS.
This commit is contained in:
@@ -137,7 +137,8 @@ pub struct Guest {
|
||||
/// What the client believes the inventory menu holds (for change detection).
|
||||
pub menu_sent: Vec<Option<ItemStack>>,
|
||||
pub menu_state: i32,
|
||||
pub sent_health: Option<(f32, i32, f32)>,
|
||||
/// `lastSentHealth`, `lastSentFood` and `lastFoodSaturationZero`.
|
||||
pub sent_health: Option<(f32, i32, bool)>,
|
||||
pub sent_xp: Option<(f32, i32, i32)>,
|
||||
/// Where the player last died (Player.lastDeathLocation), sent with the respawn.
|
||||
pub last_death: Option<[i32; 3]>,
|
||||
|
||||
@@ -1585,17 +1585,15 @@ impl Hub {
|
||||
self.flush_advancements(i, true);
|
||||
}
|
||||
}
|
||||
let health = {
|
||||
let g = &self.guests[i];
|
||||
(g.health, g.food, g.saturation)
|
||||
};
|
||||
// A dead player's health isn't sent (the death screen shows from the combat kill).
|
||||
if self.guests[i].sent_health != Some(health) && !self.guests[i].dead {
|
||||
let g = &mut self.guests[i];
|
||||
// Sent when the health or the food level changes, or the saturation
|
||||
// reaches or leaves zero; a dead player's health of 0 too.
|
||||
let g = &mut self.guests[i];
|
||||
let health = (g.health, g.food, g.saturation == 0.0);
|
||||
if g.sent_health != Some(health) {
|
||||
g.send(&C::SetHealth(play::SetHealth {
|
||||
health: health.0,
|
||||
food: health.1,
|
||||
saturation: health.2,
|
||||
health: g.health,
|
||||
food: g.food,
|
||||
saturation: g.saturation,
|
||||
}));
|
||||
g.sent_health = Some(health);
|
||||
}
|
||||
|
||||
+4
-1
@@ -454,6 +454,9 @@ def check_hazards(host, guest, out):
|
||||
# A fresh life: full health, so no regeneration eats food while the guest runs.
|
||||
guest('command', command='kill @s')
|
||||
guest.wait(20)
|
||||
# ServerPlayer.doTick sends the dead player's health of 0 too.
|
||||
died = {'screen': guest('state').get('screen'), 'health': remote(guest)['health']}
|
||||
assert died == {'screen': 'dead', 'health': 0.0}, f'the guest was killed: {died}'
|
||||
guest.raw('respawn')
|
||||
guest.wait(40)
|
||||
# Sprint-jumping down a stone lane: ServerPlayer.jumpFromGround and checkMovementStatistics.
|
||||
@@ -506,7 +509,7 @@ def check_hazards(host, guest, out):
|
||||
assert spent > 1.0, f'no hunger from moving: {hunger} ({spent:.2f} spent)'
|
||||
for name, (before, after) in hurt.items():
|
||||
assert after < before, f'{name} never hurt the guest: health {before} -> {after} (all: {hurt})'
|
||||
return {'hunger': hunger, **hurt}
|
||||
return {'died': died, 'hunger': hunger, **hurt}
|
||||
|
||||
|
||||
def check_pvp(host, guest, out):
|
||||
|
||||
Reference in New Issue
Block a user