fix: reset knocked state when dying & all teammates are knocked

This commit is contained in:
Octol1ttle 2024-03-05 23:36:38 +05:00
parent 4e02f61903
commit 6194487c49
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
2 changed files with 10 additions and 13 deletions

View file

@ -28,4 +28,11 @@ public class KnockdownsUtils {
player.damage(/*Objects.requireNonNullElse(recent, */player.getDamageSources().generic()/*)*/, damage);
player.velocityModified = false;
}
public static void resetKnockedState(IKnockableDown knockable) {
knockable.set_KnockedDown(false);
knockable.set_ReviverCount(0);
knockable.set_ReviveTimer(KnockdownsCommon.REVIVE_WAIT_TIME);
knockable.set_KnockedAge(0);
}
}

View file

@ -41,15 +41,8 @@ public class KnockdownsEvents {
ServerPlayerEntity player = (ServerPlayerEntity) entity;
if (KnockdownsUtils.allTeammatesKnocked(server, player)) {
return EventResult.pass();
}
if (knockable.is_KnockedDown()) {
knockable.set_KnockedDown(false);
knockable.set_ReviverCount(0);
knockable.set_ReviveTimer(KnockdownsCommon.REVIVE_WAIT_TIME);
knockable.set_KnockedAge(0);
if (knockable.is_KnockedDown() || KnockdownsUtils.allTeammatesKnocked(server, player)) {
KnockdownsUtils.resetKnockedState(knockable);
return EventResult.pass();
}
@ -101,10 +94,7 @@ public class KnockdownsEvents {
knockable.set_ReviveTimer(knockable.get_ReviveTimer() - knockable.get_ReviverCount());
if (knockable.get_ReviveTimer() <= 0) {
knockable.set_KnockedDown(false);
knockable.set_ReviverCount(0);
knockable.set_ReviveTimer(KnockdownsCommon.REVIVE_WAIT_TIME);
knockable.set_KnockedAge(0);
KnockdownsUtils.resetKnockedState(knockable);
player.setInvulnerable(false);
player.setGlowing(false);