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..ac6ce61 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,14 +94,11 @@ 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); - player.setHealth(6.0f); + player.setHealth(player.getMaxHealth() * 0.3f); } return; } @@ -142,12 +132,6 @@ public class KnockdownsEvents { } return CompoundEventResult.pass(); }); - InteractionEvent.RIGHT_CLICK_BLOCK.register((player, hand, pos, direction) -> { - if (KnockdownsUtils.isKnockedOrReviving(player)) { - return EventResult.interruptFalse(); - } - return EventResult.pass(); - }); } private static void registerOnEntityUse() { diff --git a/gradle.properties b/gradle.properties index df19e26..ed344f3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.1 enabled_platforms=fabric,forge archives_base_name=knockdowns -mod_version=2.1.1 +mod_version=2.2.0 maven_group=ru.octol1ttle.knockdowns architectury_version=9.1.12