diff --git a/src/main/java/org/spongepowered/common/util/DamageEventUtil.java b/src/main/java/org/spongepowered/common/util/DamageEventUtil.java index fa8a4779dd5..e471f06d4d6 100644 --- a/src/main/java/org/spongepowered/common/util/DamageEventUtil.java +++ b/src/main/java/org/spongepowered/common/util/DamageEventUtil.java @@ -222,7 +222,7 @@ public static DamageFunction provideCriticalAttackFunction(final Player player, } public static DamageFunction provideCooldownAttackStrengthFunction(final Player player, final float attackStrength) { - final var modifier = DamageEventUtil.buildAttackDamageModifier(DamageModifierTypes.ATTACK_STRENGTH, player); + final var modifier = DamageEventUtil.buildAttackDamageModifier(DamageModifierTypes.ATTACK_COOLDOWN, player); final DoubleUnaryOperator function = (damage) -> damage * (0.2F + attackStrength * attackStrength * 0.8F); return new DamageFunction(modifier, function); } diff --git a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/world/entity/player/PlayerMixin_Vanilla_Attack_Impl.java b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/world/entity/player/PlayerMixin_Vanilla_Attack_Impl.java index cd9c042866d..cf301126b75 100644 --- a/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/world/entity/player/PlayerMixin_Vanilla_Attack_Impl.java +++ b/vanilla/src/mixins/java/org/spongepowered/vanilla/mixin/core/world/entity/player/PlayerMixin_Vanilla_Attack_Impl.java @@ -25,31 +25,28 @@ package org.spongepowered.vanilla.mixin.core.world.entity.player; import net.minecraft.world.entity.player.Player; -import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; import org.spongepowered.asm.mixin.injection.Slice; import org.spongepowered.common.util.DamageEventUtil; @Mixin(Player.class) -public class PlayerMixin_Vanilla_Attack_Impl { +public abstract class PlayerMixin_Vanilla_Attack_Impl { private DamageEventUtil.Attack attackImpl$attack; /** * Captures the crit multiplier as a function */ - @ModifyVariable(method = "attack", ordinal = 2, + @ModifyConstant(method = "attack", constant = @Constant(floatValue = 1.5F), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;isSprinting()Z", ordinal = 1), - to = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Player;walkDist:F")), - at = @At(value = "JUMP", opcode = Opcodes.IFEQ) + to = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/player/Player;walkDist:F")) ) - public boolean attackImpl$critHook(final boolean isCritical) { + public float attackImpl$critHook(final float constant) { // if (isCritical) damage *= 1.5F; - if (isCritical) { - final var bonusDamageFunc = DamageEventUtil.provideCriticalAttackFunction(this.attackImpl$attack.sourceEntity(), 1.5); - this.attackImpl$attack.functions().add(bonusDamageFunc); - } - return isCritical; + final var bonusDamageFunc = DamageEventUtil.provideCriticalAttackFunction(this.attackImpl$attack.sourceEntity(), constant); + this.attackImpl$attack.functions().add(bonusDamageFunc); + return constant; } }