# FluidStateHelper

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

**Since:** 1.8.4

A fluid state describes a fluid type and its state properties. [BlockStateHelper.getFluidState()](BlockStateHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.BlockStateHelper_getFluidState-)
 returns an empty state rather than `null` for blocks without fluid; registry lookups by
 fluid id return the fluid type's default state. Properties are exposed through
 [StateHelper.toMap()](StateHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_toMap-) and [StateHelper.with(String, String)](StateHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_with-String-String-).  
 ```js
// is there a fluid in the block the player is standing on
const under = World.getBlock(Player.getPlayer().getBlockPos().down());  
if (under !== null) {
  const fluid = under.getBlockStateHelper().getFluidState();  
  if (fluid.isEmpty()) {
    Chat.log("dry ground");  
  } else {
    Chat.log(`${fluid.getId()} at level ${fluid.getLevel()}, still: ${fluid.isStill()}`);  
  }
}

// the same fluid, straight out of the registry
const lava = Client.getRegistryManager().getFluidState("minecraft:lava");  
Chat.log(`${lava.getId()} has blast resistance ${lava.getBlastResistance()}`);  
 ```

## Constructors

### new FluidStateHelper {#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_constructor-FluidState-}

```js
new FluidStateHelper(FluidState base)
```

Wraps the supplied fluid state.

**Parameters:**
- `base`: raw fluid state to wrap.

## Methods

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

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

Returns the explosion resistance of this fluid type; it does not vary by fluid state.

**Returns:** the blast resistance of this fluid.

**Since:** 1.8.4

### getBlockState {#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_getBlockState-}

```js
getBlockState(): BlockStateHelper
```

Returns the block state produced from this fluid state by the game's legacy block conversion.

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

**Since:** 1.8.4

### getHeight {#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_getHeight-}

```js
getHeight(): float
```

Returns this state type's own height as a fraction of a block, without considering the
 surrounding world. This may differ from the world- and position-dependent fluid height.

**Returns:** this state's own height as a fraction of a block.

**Since:** 1.8.4

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

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

Returns the fluid type's registry id (for example, `minecraft:water`); it identifies
 the fluid, not the block containing it.

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

**Since:** 1.8.4

### getLevel {#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_getLevel-}

```js
getLevel(): int
```

Returns the fluid amount on the game's scale. Source states return `8`; flowing states
 return their `level` property, in the range one through eight. Unlike flowing states,  
 source states have no `level` property in [StateHelper.toMap()](StateHelper.md#com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper_toMap-). This amount is
 distinct from [getHeight()](#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_getHeight-), which is defined by the fluid type.

**Returns:** the fluid amount on the game's scale.

**Since:** 1.8.4

### getVelocity {#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_getVelocity-BlockPosHelper-}

```js
getVelocity(BlockPosHelper pos): Pos3D
```

Returns the flow vector computed for this fluid state and position using the currently loaded
 client level. A loaded level is required.  
 ```js
// which way the current runs, at the block under the player
const pos = Player.getPlayer().getBlockPos().down();  
const block = World.getBlock(pos);  
if (block !== null) {
  const fluid = block.getBlockStateHelper().getFluidState();  
  if (!fluid.isEmpty()) {
    const flow = fluid.getVelocity(block.getBlockPos());  
    Chat.log(`flowing ${flow.getX()}, ${flow.getY()}, ${flow.getZ()}`);  
    if (flow.getY() > 0) {
      Chat.log("falling");  
    }
  }
}
 ```

**Parameters:**
- `pos`: position used to compute the flow

**Returns:** the computed flow vector.

**Since:** 1.8.4

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

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

Returns whether this fluid type is marked as randomly ticking.

**Returns:** `true` if this fluid type is randomly ticking; `false` otherwise.

**Since:** 1.8.4

### isEmpty {#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_isEmpty-}

```js
isEmpty(): boolean
```

Returns whether this is the empty fluid state.

**Returns:** `true` if this fluid is empty; `false` otherwise.

**Since:** 1.8.4

### isStill {#com.jsmacrosce.jsmacros.client.api.helper.world.FluidStateHelper_isStill-}

```js
isStill(): boolean
```

Returns whether this state is a source state.

**Returns:** `true` if this fluid is still, `false` otherwise.

**Since:** 1.8.4

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

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

Returns a diagnostic representation containing this fluid's registry id and state properties.

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