I'm trying to use mixins to change the values of float amount by whatever I feel like (atm amount * 300) using @ModifyVariable. But whenever I use it, nothing seems to happen.
Mixin code:
@Mixin(FabricEntityTypeBuilder.Living.class)
public class KniveBonusMixin {
@ModifyVariable(method = "applyDamage", at = @At("HEAD"), ordinal = 1,print = true)
private float injected(float amount) {
return amount * 300;
}
}
applyDamage code
protected void applyDamage(DamageSource source, float amount) {
//--- should be: amount = injected(amount)
if (!this.isInvulnerableTo(source)) {
amount = this.applyArmorToDamage(source, amount);
amount = this.modifyAppliedDamage(source, amount);
float var9 = Math.max(amount - this.getAbsorptionAmount(), 0.0F);
this.setAbsorptionAmount(this.getAbsorptionAmount() - (amount - var9));
float g = amount - var9;
if (g > 0.0F && g < 3.4028235E37F && source.getAttacker() instanceof ServerPlayerEntity serverPlayerEntity) {
serverPlayerEntity.increaseStat(Stats.DAMAGE_DEALT_ABSORBED, Math.round(g * 10.0F));
}
if (var9 != 0.0F) {
this.getDamageTracker().onDamage(source, var9);
this.setHealth(this.getHealth() - var9);
this.setAbsorptionAmount(this.getAbsorptionAmount() - var9);
this.emitGameEvent(GameEvent.ENTITY_DAMAGE);
}
}
}