Skip to content

ToolComponentHelper ​

com.jsmacrosce.jsmacros.client.api.helper.inventory.ToolComponentHelper

Since2.3.0

Reads the mining behavior configured on a stack, without considering player attributes or effects.

js
const tool = Player.getPlayer()?.getMainHand().getComponents().getTool();  
if (tool != null) Chat.log(`${tool.getDamagePerBlock()} durability per block`);

Nested types ​

Methods ​

canDestroyBlocksInCreative ​

canDestroyBlocksInCreative(): boolean#
Returns: whether the tool allows breaking blocks in Creative mode

getDamagePerBlock ​

getDamagePerBlock(): int#
Returns: the configured durability cost per block broken

getDefaultMiningSpeed ​

getDefaultMiningSpeed(): float#
Returns: the fallback mining speed when no matching rule sets one

getMiningSpeed ​

getMiningSpeed(BlockStateHelper state): float#
Finds the first matching rule that sets a mining speed and falls back to the default speed.

Parameters:

  • state: the block state to test
Returns: the mining speed from this component

getRules ​

Returns: the mining rules in the order Minecraft checks them

isCorrectForDrops ​

isCorrectForDrops(BlockStateHelper state): boolean#
Finds the first matching rule that specifies whether this tool is suitable for drops. This reports the tool rule; actual drops also depend on how the block is broken.

Parameters:

  • state: the block state to test
Returns: whether the rule allows drops; false if no matching rule sets the value