@FunctionalInterface public interface CustomDamageHandler
ItemStack.damage(int, LivingEntity, Consumer)
is called.
This is useful for items that, for example, may drain durability from some other source before damaging
the stack itself.
Custom damage handlers can be set with FabricItemSettings.customDamage(net.fabricmc.fabric.api.item.v1.CustomDamageHandler)
.
Modifier and Type | Method and Description |
---|---|
int |
damage(net.minecraft.item.ItemStack stack,
int amount,
net.minecraft.entity.LivingEntity entity,
Consumer<net.minecraft.entity.LivingEntity> breakCallback)
Called to apply damage to the given stack.
|
int damage(net.minecraft.item.ItemStack stack, int amount, net.minecraft.entity.LivingEntity entity, Consumer<net.minecraft.entity.LivingEntity> breakCallback)
amount
- The amount of damage originally requestedbreakCallback
- Callback when the stack reaches zero damage. See ItemStack.damage(int, LivingEntity, Consumer)
and its callsites for more information.