# StateHelper

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

**Since:** 1.8.4

Base helper for block and fluid states, exposing their named properties. [with(String,  
 String)](#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_with-String-String-) returns a new helper without modifying the wrapped state.  
 ```js
const reg = Client.getRegistryManager();  
const state = reg.getBlockState("minecraft:oak_stairs", "[facing=east]");  
const northFacing = state.with("facing", "north");  
Chat.log(northFacing.toMap().facing);  
 ```

## Type Parameters

- `U`: the block or fluid state wrapped by this helper.

## Constructors

### new StateHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_constructor-U-}

```js
new StateHelper(U extends StateHolder<?, ?> base)
```

Stores the supplied block or fluid state as the value wrapped by this helper.

**Parameters:**
- `base`: block or fluid state to wrap

## Methods

### toMap {#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_toMap-}

```js
toMap(): Map<String, String>
```

Returns every property of the wrapped state, including properties at their default values,  
 keyed by property name and valued by the property's game-defined value name. These names can
 be passed to [with(String, String)](#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_with-String-String-).

**Returns:** the property names and their current values.

**Since:** 1.8.4

### with {#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_with-String-String-}

```js
with(String property, String value): StateHelper<U extends StateHolder<?, ?>>
```

Returns a new helper with the named property set; the original helper and world are unchanged.  
 Throws [IllegalArgumentException](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/IllegalArgumentException.html) if the property is absent or the value is invalid.  
 Property names and value spellings are shown by [toMap()](#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_toMap-).

**Parameters:**
- `property`: property name, as shown by [toMap()](#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_toMap-).
- `value`: value spelling, as shown by [toMap()](#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_toMap-).

**Returns:** a new helper of the same kind holding the state with that property set.

**Since:** 1.8.4
