Class ToolManager
java.lang.Object
net.fabricmc.fabric.api.tool.attribute.v1.ToolManager
API facing part to register tool handlers and get information about how tools are handled.
Implement
DynamicAttributeTool
to change the mining level or speed of your tool depending on the ItemStack
.-
Method Summary
Modifier and TypeMethodDescriptionstatic float
handleBreakingSpeed
(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user) Handles the breaking speed breaking a block.static float
handleBreakingSpeedIgnoresVanilla
(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user) Handles the breaking speed breaking a block, ignores vanilla tools on vanilla blocks.static boolean
handleIsEffectiveOn
(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user) Handles if the tool is effective on a block.static boolean
handleIsEffectiveOnIgnoresVanilla
(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user) Handles if the tool is effective on a block, ignores vanilla tools on vanilla blocks.static boolean
handleIsEffectiveOnIgnoresVanilla
(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable net.minecraft.entity.LivingEntity user, boolean vanillaResult) Handles if the tool is effective on a block, ignores vanilla tools on vanilla blocks.
-
Method Details
-
handleIsEffectiveOn
public static boolean handleIsEffectiveOn(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user) Handles if the tool is effective on a block.- Parameters:
state
- the block state to breakstack
- the item stack involved with breaking the blockuser
- the user involved in breaking the block, null if not applicable.- Returns:
- whether the tool is effective
-
handleIsEffectiveOnIgnoresVanilla
public static boolean handleIsEffectiveOnIgnoresVanilla(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user, boolean vanillaResult) Handles if the tool is effective on a block, ignores vanilla tools on vanilla blocks.- Parameters:
state
- the block state to breakstack
- the item stack involved with breaking the blockuser
- the user involved in breaking the block, null if not applicable.vanillaResult
- whether the tool is considered effective by vanilla- Returns:
- whether the tool is effective
-
handleIsEffectiveOnIgnoresVanilla
public static boolean handleIsEffectiveOnIgnoresVanilla(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user) Handles if the tool is effective on a block, ignores vanilla tools on vanilla blocks.- Parameters:
state
- the block state to breakstack
- the item stack involved with breaking the blockuser
- the user involved in breaking the block, null if not applicable.- Returns:
- whether the tool is effective
-
handleBreakingSpeed
public static float handleBreakingSpeed(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user) Handles the breaking speed breaking a block.- Parameters:
state
- the block state to breakstack
- the item stack involved with breaking the blockuser
- the user involved in breaking the block, null if not applicable.- Returns:
- the speed multiplier in breaking the block, 1.0 if no change.
-
handleBreakingSpeedIgnoresVanilla
public static float handleBreakingSpeedIgnoresVanilla(net.minecraft.block.BlockState state, net.minecraft.item.ItemStack stack, @Nullable @Nullable net.minecraft.entity.LivingEntity user) Handles the breaking speed breaking a block, ignores vanilla tools on vanilla blocks.- Parameters:
state
- the block state to breakstack
- the item stack involved with breaking the blockuser
- the user involved in breaking the block, null if not applicable.- Returns:
- the speed multiplier in breaking the block, 1.0 if no change.
-