Interface DynamicAttributeTool
public interface DynamicAttributeTool
Interface for adding various tool attributes to items.
-
Field Summary
-
Method Summary
Modifier and Type Method Description default Multimap<net.minecraft.entity.attribute.EntityAttribute,net.minecraft.entity.attribute.EntityAttributeModifier>getDynamicModifiers(net.minecraft.entity.EquipmentSlot slot, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user)Add modifiers for anyEntityAttributesyour item should give when equipped, based on the stack.default intgetMiningLevel(net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user)Deprecated.default intgetMiningLevel(net.minecraft.tag.Tag<net.minecraft.item.Item> tag, net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user)Determines the mining level of the passed stack, which is used for calculating what blocks this tool is allowed to break.default floatgetMiningSpeedMultiplier(net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user)Deprecated.UsegetMiningSpeedMultiplier(Tag, BlockState, ItemStack, LivingEntity)to detect tag and block.default floatgetMiningSpeedMultiplier(net.minecraft.tag.Tag<net.minecraft.item.Item> tag, net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user)Determines the mining speed multiplier of the passed stack, which is one factor in overall mining speed.default floatpostProcessMiningSpeed(net.minecraft.tag.Tag<net.minecraft.item.Item> tag, net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user, float currentSpeed, boolean isEffective)Post process the mining speed, this takes place after the mining speed has been calculated.
-
Field Details
-
EMPTY
static final Multimap<net.minecraft.entity.attribute.EntityAttribute,net.minecraft.entity.attribute.EntityAttributeModifier> EMPTY
-
-
Method Details
-
getMiningLevel
@Deprecated default int getMiningLevel(net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user)Deprecated.UsegetMiningLevel(Tag, BlockState, ItemStack, LivingEntity)to detect tag and block.Determines the mining level of the passed stack, which is used for calculating what blocks this tool is allowed to break.- Parameters:
stack- The item stack being used to mine the blockuser- The current user of the tool, or null if there isn't any- Returns:
- The mining level of the item. 3 is equal to a diamond pick.
-
getMiningLevel
default int getMiningLevel(net.minecraft.tag.Tag<net.minecraft.item.Item> tag, net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user)Determines the mining level of the passed stack, which is used for calculating what blocks this tool is allowed to break.- Parameters:
tag- The tool tag the item stack is being compared tostate- The block to minestack- The item stack being used to mine the blockuser- The current user of the tool, or null if there isn't any- Returns:
- The mining level of the item. 3 is equal to a diamond pick.
-
getMiningSpeedMultiplier
@Deprecated default float getMiningSpeedMultiplier(net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user)Deprecated.UsegetMiningSpeedMultiplier(Tag, BlockState, ItemStack, LivingEntity)to detect tag and block.Determines the mining speed multiplier of the passed stack, which is one factor in overall mining speed.- Parameters:
stack- The item stack being used to mine the blockuser- The current user of the tool, or null if there isn't any- Returns:
- The mining speed multiplier of the item. 8.0 is equal to a diamond pick.
-
getMiningSpeedMultiplier
default float getMiningSpeedMultiplier(net.minecraft.tag.Tag<net.minecraft.item.Item> tag, net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user)Determines the mining speed multiplier of the passed stack, which is one factor in overall mining speed.- Parameters:
tag- The tool tag the item stack is being compared tostate- The block to minestack- The item stack being used to mine the blockuser- The current user of the tool, or null if there isn't any- Returns:
- The mining speed multiplier of the item. 8.0 is equal to a diamond pick.
-
postProcessMiningSpeed
default float postProcessMiningSpeed(net.minecraft.tag.Tag<net.minecraft.item.Item> tag, net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user, float currentSpeed, boolean isEffective)Post process the mining speed, this takes place after the mining speed has been calculated.This allows bypassing the regular computation formula.
- Parameters:
tag- The tool tag the item stack is handled bystate- The block to minestack- The item stack being used to mine the blockuser- The current user of the tool, or null if there isn't anycurrentSpeed- The mining speed before post processisEffective- whether the tool has been handled- Returns:
- the speed after post processing
-
getDynamicModifiers
default Multimap<net.minecraft.entity.attribute.EntityAttribute,net.minecraft.entity.attribute.EntityAttributeModifier> getDynamicModifiers(net.minecraft.entity.EquipmentSlot slot, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user)Add modifiers for anyEntityAttributesyour item should give when equipped, based on the stack.Appends to either attribute modifier NBT or the result from
Item.getAttributeModifiers(EquipmentSlot).- Parameters:
slot- The equipment slot this item is equipped in.stack- The stack that's equipped.user- The current user of the tool, or none if there isn't any- Returns:
- The dynamic modifiers to add on top of other modifiers on this stack. If none, return
EMPTY.
-
getMiningLevel(Tag, BlockState, ItemStack, LivingEntity)to detect tag and block.