From a3471e7a390505ddddf3dec4c2e4e2c84c4e9e7d Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Wed, 20 Mar 2024 19:04:49 +0500 Subject: [PATCH] fix: reset knocked state when activating Totem of Undying --- .../knockdowns/common/mixin/LivingEntityMixin.java | 12 ++++++++++++ gradle.properties | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/ru/octol1ttle/knockdowns/common/mixin/LivingEntityMixin.java b/common/src/main/java/ru/octol1ttle/knockdowns/common/mixin/LivingEntityMixin.java index 369a8b4..afd6eb4 100644 --- a/common/src/main/java/ru/octol1ttle/knockdowns/common/mixin/LivingEntityMixin.java +++ b/common/src/main/java/ru/octol1ttle/knockdowns/common/mixin/LivingEntityMixin.java @@ -2,8 +2,12 @@ package ru.octol1ttle.knockdowns.common.mixin; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.damage.DamageSource; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import ru.octol1ttle.knockdowns.common.KnockdownsUtils; import ru.octol1ttle.knockdowns.common.api.IKnockableDown; @Mixin(LivingEntity.class) @@ -12,4 +16,12 @@ public abstract class LivingEntityMixin { private boolean dontTargetKnockedPlayers(boolean original, LivingEntity target) { return original && !(target instanceof IKnockableDown knockable && knockable.is_KnockedDown()); } + + @Inject(method = "tryUseTotem", at = @At("RETURN")) + private void resetKnockedDownOnTotemUse(DamageSource source, CallbackInfoReturnable cir) { + LivingEntity $this = (LivingEntity) (Object) this; + if (cir.getReturnValue() && $this instanceof IKnockableDown knockable && knockable.is_KnockedDown()) { + KnockdownsUtils.resetKnockedState(knockable); + } + } } diff --git a/gradle.properties b/gradle.properties index ed344f3..6d54409 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.2.1 maven_group=ru.octol1ttle.knockdowns architectury_version=9.1.12