fix: reset knocked state when activating Totem of Undying

This commit is contained in:
Octol1ttle 2024-03-20 19:04:49 +05:00
parent 4968a7ca7f
commit a3471e7a39
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
2 changed files with 13 additions and 1 deletions

View file

@ -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<Boolean> cir) {
LivingEntity $this = (LivingEntity) (Object) this;
if (cir.getReturnValue() && $this instanceof IKnockableDown knockable && knockable.is_KnockedDown()) {
KnockdownsUtils.resetKnockedState(knockable);
}
}
}

View file

@ -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