Skip to content

FluidStateHelper ​

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

Since1.8.4

A fluid state describes a fluid type and its state properties. 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() and 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 ​

new FluidStateHelper(FluidState base)#
Wraps the supplied fluid state.

Parameters:

  • base: raw fluid state to wrap.

Methods ​

getBlastResistance ​

getBlastResistance(): floatSince1.8.4#
Returns the explosion resistance of this fluid type; it does not vary by fluid state.
Returns: the blast resistance of this fluid.

getBlockState ​

getBlockState(): BlockStateHelperSince1.8.4#
Returns the block state produced from this fluid state by the game's legacy block conversion.
Returns: the block state of this fluid.

getHeight ​

getHeight(): floatSince1.8.4#
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.

getId ​

getId(): StringSince1.8.4#
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.

getLevel ​

getLevel(): intSince1.8.4#
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(). This amount is distinct from getHeight(), which is defined by the fluid type.
Returns: the fluid amount on the game's scale.

getVelocity ​

getVelocity(BlockPosHelper pos): Pos3DSince1.8.4#
Returns the flow vector computed for this fluid state and position using the currently loaded client level. A loaded level is required.
// 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.

hasRandomTicks ​

hasRandomTicks(): booleanSince1.8.4#
Returns whether this fluid type is marked as randomly ticking.
Returns: true if this fluid type is randomly ticking; false otherwise.

isEmpty ​

isEmpty(): booleanSince1.8.4#
Returns whether this is the empty fluid state.
Returns: true if this fluid is empty; false otherwise.

isStill ​

isStill(): booleanSince1.8.4#
Returns whether this state is a source state.
Returns: true if this fluid is still, false otherwise.

toString ​

toString(): String#
Returns a diagnostic representation containing this fluid's registry id and state properties.
Returns: a diagnostic representation of the wrapped fluid state.