# BlockHelper

`com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper`

**Since:** 1.6.5

Describes a block type independently of any world position; [BlockStateHelper](BlockStateHelper.md) represents
one of that block's variants.  
```js
const block = Client.getRegistryManager().getBlock("stone");  
Chat.log(`${block.getId()} is called ${block.getName()}`);  

// inspect its default state and all defined variants
Chat.log(`default state has ${block.getDefaultState().getId()}`);  
Chat.log(`and ${block.getStates().size()} states in total`);  

// the item that places it
const stack = block.getDefaultItemStack();  
Chat.log(`${stack.getItemId()} holds up to ${stack.getMaxCount()}`);  
```

## Constructors

### new BlockHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_constructor-Block-}

```js
new BlockHelper(Block base)
```

Wraps the supplied block type.

**Parameters:**
- `base`: raw block type to wrap

## Methods

### canMobSpawnInside {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_canMobSpawnInside-}

```js
canMobSpawnInside(): boolean
```

Tests whether the block's default state is non-solid and non-liquid.

**Returns:** `true` if its default state is non-solid and non-liquid.

**Since:** 1.6.5

### getBlastResistance {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getBlastResistance-}

```js
getBlastResistance(): float
```

Returns this block's explosion resistance.

**Returns:** the explosion resistance value.

**Since:** 1.6.5

### getDefaultItemStack {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getDefaultItemStack-}

```js
getDefaultItemStack(): ItemStackHelper
```

Returns the default stack for the item's form of this block. Blocks without a dedicated item
use the item returned by Minecraft's block-to-item mapping.  
```js
// the item that places a block, as a stack of one
const block = Client.getRegistryManager().getBlock("oak_stairs");  
const stack = block.getDefaultItemStack();  
Chat.log(`${stack.getItemId()} x ${stack.getCount()}`);  

// a stack of sixty-four of it, ready to place
const many = stack.copy().getCreative().setCount(64);  
Chat.log(`${many.getCount()} of ${many.getItemId()}`);  
```

**Returns:** the default item stack of the block.

**Since:** 1.6.5

### getDefaultState {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getDefaultState-}

```js
getDefaultState(): BlockStateHelper
```

Returns the block's registered default state.  
```js
// the plain form of a block that comes in variants
const stairs = Client.getRegistryManager().getBlock("oak_stairs");  
const plain = stairs.getDefaultState();  
for (const [name, value] of plain.toMap()) {
  Chat.log(`${name} is ${value}`);  
}

// and the same block, a named variant instead
const turned = Client.getRegistryManager().getBlockState("oak_stairs", "[facing=east]");  
Chat.log(`${plain.toMap().facing} versus ${turned.toMap().facing}`);  
```

**Returns:** the default state of the block.

**Since:** 1.6.5

### getHardness {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getHardness-}

```js
getHardness(): float
```

Returns the block's default destroy-time value, independent of block state. An unbreakable
block uses `-1`; [BlockStateHelper.getHardness()](BlockStateHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getHardness-) reports state-specific hardness.

**Returns:** the default destroy-time value.

**Since:** 1.6.5

### getId {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getId-}

```js
getId(): String
```

Returns the block's full registry identifier, such as `minecraft:stone`.

**Returns:** the identifier of the block.

**Since:** 1.6.5

### getJumpVelocityMultiplier {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getJumpVelocityMultiplier-}

```js
getJumpVelocityMultiplier(): float
```

Returns this block's jump factor.

**Returns:** the jump factor multiplier.

**Since:** 1.6.5

### getName {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getName-}

```js
getName(): TextHelper
```

Returns the block's display name as text.

**Returns:** the name of the block.

**Since:** 1.8.4

### getSlipperiness {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getSlipperiness-}

```js
getSlipperiness(): float
```

Returns this block's friction value.

**Returns:** the friction value.

**Since:** 1.6.5

### getStates {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getStates-}

```js
getStates(): List<BlockStateHelper>
```

Returns every possible state defined for this block.

**Returns:** all possible block states of the block.

**Since:** 1.6.5

### getTags {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getTags-}

```js
getTags(): List<String>
```

Returns the identifiers of the tags assigned to this block, as full ids.

**Returns:** the full identifiers of the block's tags.

**Since:** 1.6.5

### getVelocityMultiplier {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getVelocityMultiplier-}

```js
getVelocityMultiplier(): float
```

Returns this block's entity movement speed factor.

**Returns:** the speed factor multiplier.

**Since:** 1.6.5

### hasDynamicBounds {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_hasDynamicBounds-}

```js
hasDynamicBounds(): boolean
```

Returns whether this block's shape is marked dynamic.

**Returns:** `true` if its shape is dynamic.

**Since:** 1.6.5

### hasTag {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_hasTag-String-}

```js
hasTag(String tag): boolean
```

Returns whether this block belongs to the supplied block tag. Tag membership is
data-driven and can differ between loaded datapacks. Unknown tags and tags from other
registries return `false`.

**Parameters:**
- `tag`: the block tag id, optionally prefixed with `#` or missing its namespace

**Returns:** `true` if this block is in the tag

**Since:** 2.1.0

### toString {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_toString-}

```js
toString(): String
```

Returns a diagnostic representation containing this block type's identifier.

**Returns:** diagnostic representation of the wrapped block type
