From 6194487c491ed306bbf21d4e6c22f2a7584eaa0a Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Tue, 5 Mar 2024 23:36:38 +0500 Subject: [PATCH] fix: reset knocked state when dying & all teammates are knocked --- .../knockdowns/common/KnockdownsUtils.java | 7 +++++++ .../common/events/KnockdownsEvents.java | 16 +++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java b/common/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java index 6f6b651..4d256fd 100644 --- a/common/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java +++ b/common/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java @@ -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); + } } diff --git a/common/src/main/java/ru/octol1ttle/knockdowns/common/events/KnockdownsEvents.java b/common/src/main/java/ru/octol1ttle/knockdowns/common/events/KnockdownsEvents.java index 16a3e78..299bc51 100644 --- a/common/src/main/java/ru/octol1ttle/knockdowns/common/events/KnockdownsEvents.java +++ b/common/src/main/java/ru/octol1ttle/knockdowns/common/events/KnockdownsEvents.java @@ -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);