From fcf2d0fd4271eca8961d8792205e25346780de6f Mon Sep 17 00:00:00 2001 From: aromaa Date: Sun, 15 Dec 2024 01:51:56 +0200 Subject: [PATCH] Fix sprint kb being added twice --- .../world/entity/player/PlayerMixin_Attack_Impl.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin_Attack_Impl.java b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin_Attack_Impl.java index cb4c42b6ce1..daa23d981be 100644 --- a/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin_Attack_Impl.java +++ b/src/mixins/java/org/spongepowered/common/mixin/core/world/entity/player/PlayerMixin_Attack_Impl.java @@ -43,7 +43,9 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.Slice; @@ -213,6 +215,14 @@ public abstract class PlayerMixin_Attack_Impl extends LivingEntityMixin_Attack_I return this.attackImpl$attackEvent.knockbackModifier(); } + @ModifyConstant(method = "attack", constant = @Constant(floatValue = 1.0F), slice = @Slice( + from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;getKnockback(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/damagesource/DamageSource;)F"), + to = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/LivingEntity;knockback(DDD)V")) + ) + private float attackImpl$noDoubleAddKb(final float constant) { + return 0.0F; + } + /** * Prevents the {@link SoundEvents#PLAYER_ATTACK_NODAMAGE} when event was canceled */