Drop a client's remembered effects when it joins a world

A rejoining player kept the previous session's effect list, so the HUD
could show effects the server no longer had (nothing applied in combat,
no icon was earned). Vanilla's new LocalPlayer starts empty and gets its
effects from UpdateMobEffect; match that, and let the client-side tick
drop effects whose duration ran out, as its removeIf does.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
socksprox
2026-10-27 02:31:11 +01:00
parent e8891849a4
commit 7732ce986f
2 changed files with 7 additions and 2 deletions
+4 -2
View File
@@ -427,9 +427,11 @@ impl Game<'_> {
/// `MobEffectInstance.tickClient`): they count down, and the server
/// removes them. Their modifiers and flags move the predicted player.
pub(super) fn tick_client_effects(&mut self) {
for e in &mut self.potions.effects.list {
// LivingEntity.tickEffects (client): an exhausted effect drops.
self.potions.effects.list.retain_mut(|e| {
e.tick_client();
}
e.duration != 0
});
self.apply_effect_status();
}
/// Add an active effect to the player and update attributes / absorption.
+3
View File
@@ -394,6 +394,9 @@ impl Game<'_> {
self.carried = None;
self.using = None;
self.clicks.miss_time = 0;
// A new LocalPlayer has no effects: the server sends what it has
// (ClientboundUpdateMobEffectPacket on placement).
self.potions = Default::default();
self.set_mode_id(0);
self.experience = Experience {
level: 0,