# ToolComponentHelper

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

**Since:** 2.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

- [Rule](ToolComponentHelper.Rule.md)

## Methods

### canDestroyBlocksInCreative {#com.jsmacrosce.jsmacros.client.api.helper.inventory.ToolComponentHelper_canDestroyBlocksInCreative-}

```js
canDestroyBlocksInCreative(): boolean
```

**Returns:** whether the tool allows breaking blocks in Creative mode

### getDamagePerBlock {#com.jsmacrosce.jsmacros.client.api.helper.inventory.ToolComponentHelper_getDamagePerBlock-}

```js
getDamagePerBlock(): int
```

**Returns:** the configured durability cost per block broken

### getDefaultMiningSpeed {#com.jsmacrosce.jsmacros.client.api.helper.inventory.ToolComponentHelper_getDefaultMiningSpeed-}

```js
getDefaultMiningSpeed(): float
```

**Returns:** the fallback mining speed when no matching rule sets one

### getMiningSpeed {#com.jsmacrosce.jsmacros.client.api.helper.inventory.ToolComponentHelper_getMiningSpeed-BlockStateHelper-}

```js
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 {#com.jsmacrosce.jsmacros.client.api.helper.inventory.ToolComponentHelper_getRules-}

```js
getRules(): List<ToolComponentHelper.Rule>
```

**Returns:** the mining rules in the order Minecraft checks them

### isCorrectForDrops {#com.jsmacrosce.jsmacros.client.api.helper.inventory.ToolComponentHelper_isCorrectForDrops-BlockStateHelper-}

```js
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
