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 4d256fd..6f6b651 100644 --- a/common/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java +++ b/common/src/main/java/ru/octol1ttle/knockdowns/common/KnockdownsUtils.java @@ -28,11 +28,4 @@ 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 ac6ce61..16a3e78 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,8 +41,15 @@ public class KnockdownsEvents { ServerPlayerEntity player = (ServerPlayerEntity) entity; - if (knockable.is_KnockedDown() || KnockdownsUtils.allTeammatesKnocked(server, player)) { - KnockdownsUtils.resetKnockedState(knockable); + 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); return EventResult.pass(); } @@ -94,11 +101,14 @@ public class KnockdownsEvents { knockable.set_ReviveTimer(knockable.get_ReviveTimer() - knockable.get_ReviverCount()); if (knockable.get_ReviveTimer() <= 0) { - KnockdownsUtils.resetKnockedState(knockable); + knockable.set_KnockedDown(false); + knockable.set_ReviverCount(0); + knockable.set_ReviveTimer(KnockdownsCommon.REVIVE_WAIT_TIME); + knockable.set_KnockedAge(0); player.setInvulnerable(false); player.setGlowing(false); - player.setHealth(player.getMaxHealth() * 0.3f); + player.setHealth(6.0f); } return; } @@ -132,6 +142,12 @@ 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 ed344f3..df19e26 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.2.0 +mod_version=2.1.1 maven_group=ru.octol1ttle.knockdowns architectury_version=9.1.12