diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java index 9ce641522..84e45cb36 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/ItemStackMixin.java @@ -27,6 +27,7 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.LivingEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.server.network.ServerPlayerEntity; @@ -45,13 +46,13 @@ public abstract class ItemStackMixin implements FabricItemStack { public abstract void decrement(int amount); @WrapOperation(method = "damage(ILnet/minecraft/entity/LivingEntity;Lnet/minecraft/entity/EquipmentSlot;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;damage(ILnet/minecraft/server/world/ServerWorld;Lnet/minecraft/server/network/ServerPlayerEntity;Ljava/util/function/Consumer;)V")) - private void hookDamage(ItemStack instance, int amount, ServerWorld serverWorld, ServerPlayerEntity serverPlayerEntity, Consumer consumer, Operation original, @Local(argsOnly = true) EquipmentSlot slot) { + private void hookDamage(ItemStack instance, int amount, ServerWorld serverWorld, ServerPlayerEntity serverPlayerEntity, Consumer consumer, Operation original, @Local(argsOnly = true) LivingEntity entity, @Local(argsOnly = true) EquipmentSlot slot) { CustomDamageHandler handler = ((ItemExtensions) getItem()).fabric_getCustomDamageHandler(); if (handler != null) { // Track whether an item has been broken by custom handler MutableBoolean mut = new MutableBoolean(false); - amount = handler.damage((ItemStack) (Object) this, amount, serverPlayerEntity, slot, () -> { + amount = handler.damage((ItemStack) (Object) this, amount, entity, slot, () -> { mut.setTrue(); this.decrement(1); consumer.accept(this.getItem());