Interface DynamicAttributeTool
Functions in this interface will provide user context if it is available. These context parameters are provided on a best-effort basis, and implementations should not fail hard if they are absent.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault 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 anyEntityAttributes
your item should give when equipped, based on the stack.default int
getMiningLevel(net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user)
Deprecated.default int
getMiningLevel(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 float
getMiningSpeedMultiplier(net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user)
Deprecated.UsegetMiningSpeedMultiplier(Tag, BlockState, ItemStack, LivingEntity)
to detect tag and block.default float
getMiningSpeedMultiplier(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 float
postProcessMiningSpeed(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 anyEntityAttributes
your item should give when equipped, based on the stack.Appends to either attribute modifier NBT or the result from
Item.getAttributeModifiers(EquipmentSlot)
. The attributes returned from this method will only be applied to an entity when theItemStack
providing the attributes is modified, or the player re-selects the stack in their hotbar. If your attribute relies on data from outside the stack, such as the user's age, you will need to modify the stack in some way to re-assign attributes to the entity. A fix for this may be provided in the future.- Parameters:
slot
- The equipment slot this item is equipped in.stack
- The stack that's equipped.user
- The current user of the tool, if available.- 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.