# BlockStateHelper

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

**Since:** 1.6.5

Represents one particular state of a block, including its property values. It extends
[StateHelper](StateHelper.md) with block-specific queries; [getUniversal()](#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getUniversal-) exposes properties as
typed values. States can be obtained from [BlockDataHelper.getBlockStateHelper()](BlockDataHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.BlockDataHelper_getBlockStateHelper-),  
[BlockHelper.getDefaultState()](BlockHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.BlockHelper_getDefaultState-), or from the registry with
[RegistryHelper.getBlockState(String)](../../classes/RegistryHelper.md#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlockState-String-).  
```js
const state = Client.getRegistryManager().getBlockState("minecraft:oak_stairs", "[facing=east]");  
Chat.log(`${state.getId()}: ${state.toMap().facing} ${state.toMap().half}`);  

// the properties as typed values rather than as names
const universal = state.getUniversal();  
Chat.log(`facing is ${universal.getHorizontalFacing().getName()}`);  
Chat.log(`waterlogged is ${universal.isWaterlogged()}`);  

// and the world's own opinion of the block
Chat.log(`solid ${state.isSolid()}, opaque ${state.isOpaque()}, light ${state.getLuminance()}`);  
```

## Constructors

### new BlockStateHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_constructor-BlockState-}

```js
new BlockStateHelper(BlockState base)
```

Wraps the supplied raw block state without copying or changing it.

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

## Methods

### allowsSpawning {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_allowsSpawning-BlockPosHelper-String-}

```js
allowsSpawning(BlockPosHelper pos, String entity): boolean
```

Returns the game's spawn-validity result for this state, position, and entity type. The
result can depend on the supplied position and world, not just on the state.

**Parameters:**
- `pos`: the position of the block to check
- `entity`: the entity type to check

**Returns:** `true` if the entity can spawn on this block state at the given position in the
current world.

**Since:** 1.6.5

### blocksMovement {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_blocksMovement-}

```js
blocksMovement(): boolean
```

Returns the legacy movement-blocking flag, excluding cobwebs and bamboo saplings.

**Returns:** `true` if the state blocks the movement of entities.

**Since:** 1.6.5

### emitsRedstonePower {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_emitsRedstonePower-}

```js
emitsRedstonePower(): boolean
```

Returns whether this state's block is a redstone signal source.

**Returns:** `true` if the state emits redstone power.

**Since:** 1.6.5

### exceedsCube {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_exceedsCube-}

```js
exceedsCube(): boolean
```

Returns the game's large-collision-shape flag for this state.

**Returns:** `true` if the state has a large collision shape.

**Since:** 1.6.5

### getBlock {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getBlock-}

```js
getBlock(): BlockHelper
```

Returns the block that owns this state.

**Returns:** the block the state belongs to.

**Since:** 1.6.5

### getFluidState {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getFluidState-}

```js
getFluidState(): FluidStateHelper
```

Returns the fluid state held by this block state. A state with no fluid returns an empty
state, not `null`; use [FluidStateHelper.isEmpty()](FluidStateHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_isEmpty-) to test it.

**Returns:** the fluid state of this block state.

**Since:** 1.8.4

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

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

Returns this state's destroy-speed value without a world, position, player, or tool. It is
block hardness, not an estimate of breaking time; unbreakable blocks report `-1`.

**Returns:** the hardness.

**Since:** 1.6.5

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

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

Returns the registry id of the block, independent of this state's properties.

**Returns:** the block's id.

**Since:** 1.8.4

### getLuminance {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getLuminance-}

```js
getLuminance(): int
```

Returns this state's light emission value.

**Returns:** the luminance.

**Since:** 1.6.5

### getPistonBehaviour {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getPistonBehaviour-}

```js
getPistonBehaviour(): String
```

Returns the piston push-reaction name for this state: `NORMAL`, `BLOCK`,  
`PUSH_ONLY`, `DESTROY`, or `IGNORE`.

**Returns:** the piston behaviour of the state.

**Since:** 1.6.5

### getUniversal {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getUniversal-}

```js
getUniversal(): UniversalBlockStateHelper
```

Returns a helper with typed accessors for the block-state properties it exposes. Unlike
[StateHelper.toMap()](StateHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_toMap-), these accessors return property values in their typed form; an
accessor for a property absent from this state throws rather than returning `false`.

**Returns:** a typed-property view of this state.

**Since:** 1.8.4

### hasBlockEntity {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_hasBlockEntity-}

```js
hasBlockEntity(): boolean
```

Returns whether this state has a block entity.

**Returns:** `true` if the state has a block entity.

**Since:** 1.6.5

### hasComparatorOutput {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_hasComparatorOutput-}

```js
hasComparatorOutput(): boolean
```

Returns whether this state supports an analog output signal.

**Returns:** `true` if the state has a comparator output.

**Since:** 1.6.5

### hasRandomTicks {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_hasRandomTicks-}

```js
hasRandomTicks(): boolean
```

Returns whether this state is marked for random ticking.

**Returns:** `true` if the state can be random ticked.

**Since:** 1.6.5

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

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

Returns whether this state's block belongs to the supplied block tag. Tag membership is
per block, not per state, and is data-driven, so it 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 state's block is in the tag

**Since:** 2.1.0

### isAir {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_isAir-}

```js
isAir(): boolean
```

Returns whether this state is marked as air.

**Returns:** `true` if the state is air.

**Since:** 1.6.5

### isBurnable {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_isBurnable-}

```js
isBurnable(): boolean
```

Returns whether this state is marked as ignitable by lava.

**Returns:** `true` if the state is burnable.

**Since:** 1.6.5

### isLiquid {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_isLiquid-}

```js
isLiquid(): boolean
```

Returns the state's liquid flag; this does not test whether it contains fluid.

**Returns:** `true` if the state is a liquid.

**Since:** 1.6.5

### isOpaque {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_isOpaque-}

```js
isOpaque(): boolean
```

Returns whether this state can occlude neighboring blocks.

**Returns:** `true` if the state is opaque.

**Since:** 1.6.5

### isReplaceable {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_isReplaceable-}

```js
isReplaceable(): boolean
```

Returns whether this state can be replaced in the default placement context.

**Returns:** `true` if the state can be replaced.

**Since:** 1.6.5

### isSolid {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_isSolid-}

```js
isSolid(): boolean
```

Returns the state's legacy solid flag; this is distinct from its opacity.

**Returns:** `true` if the state is solid.

**Since:** 1.6.5

### isToolRequired {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_isToolRequired-}

```js
isToolRequired(): boolean
```

Returns whether correct-tool status is required for this state's drops.

**Returns:** `true` if drops require a correct tool.

**Since:** 1.6.5

### shouldSuffocate {#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_shouldSuffocate-BlockPosHelper-}

```js
shouldSuffocate(BlockPosHelper pos): boolean
```

Returns the game's suffocation result for this state at the given position in the currently
loaded world.

**Parameters:**
- `pos`: the position of the block to check

**Returns:** `true` if an entity can suffocate in this block state at the given position in
the current world.

**Since:** 1.6.5

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

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

Returns a diagnostic representation containing the wrapped block's identifier and property map.

**Returns:** a diagnostic representation of the wrapped block state.
