Class StateHelper

java.lang.Object
etithespirit.orimod.util.level.StateHelper

public final class StateHelper extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.level.block.state.StateHolder<?,?>
    getFluidOrBlock(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos at)
    If the given location in the given world has a fluid, this returns its FluidState.
    static void
    setBlockAndUpdateIn(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos at, net.minecraft.world.level.block.state.StateHolder<?,?> state)
    Sets the given StateHolder, which is expected to be a BlockState or FluidState, in the world at the given position.
    static net.minecraft.world.level.block.state.StateHolder<?,?>
    setManyValues(net.minecraft.world.level.block.state.StateHolder<?,?> state, Object... keysAndValues)
    A utility to chain setValue calls on an anonymous StateHolder into a single method call.
    static net.minecraft.world.level.block.state.StateHolder<?,?>
    setManyValues(net.minecraft.world.level.block.state.StateHolder<?,?> state, net.minecraft.world.level.block.state.properties.Property<?> key, Comparable<?> value)
    A utility to chain setValue calls on an anonymous StateHolder into a single method call.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • setBlockAndUpdateIn

      public static void setBlockAndUpdateIn(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos at, net.minecraft.world.level.block.state.StateHolder<?,?> state)
      Sets the given StateHolder, which is expected to be a BlockState or FluidState, in the world at the given position.
      Parameters:
      world - The world to modify.
      at - The location in the world to modify.
      state - The new block or fluid.
    • getFluidOrBlock

      public static net.minecraft.world.level.block.state.StateHolder<?,?> getFluidOrBlock(net.minecraft.world.level.BlockGetter world, net.minecraft.core.BlockPos at)
      If the given location in the given world has a fluid, this returns its FluidState. Otherwise, this returns the BlockState.
      Parameters:
      world - The world to read from.
      at - The location to read at.
      Returns:
      The fluid at that location, or the block if no fluid is present there.
    • setManyValues

      public static net.minecraft.world.level.block.state.StateHolder<?,?> setManyValues(net.minecraft.world.level.block.state.StateHolder<?,?> state, Object... keysAndValues) throws IllegalArgumentException, ArgumentNullException
      A utility to chain setValue calls on an anonymous StateHolder into a single method call. For compliance with the method in use, values must be something that implements Comparable (which all properties do).
      Parameters:
      state - The StateHolder to modify.
      keysAndValues - An ordered list of keys and values, in the order key0, value0, key1, value1, ...
      Returns:
      The StateHolder this was called on
      Throws:
      IllegalArgumentException
      ArgumentNullException
    • setManyValues

      public static net.minecraft.world.level.block.state.StateHolder<?,?> setManyValues(net.minecraft.world.level.block.state.StateHolder<?,?> state, net.minecraft.world.level.block.state.properties.Property<?> key, Comparable<?> value)
      A utility to chain setValue calls on an anonymous StateHolder into a single method call. For compliance with the method in use, values must be something that implements Comparable (which all properties do).
      Parameters:
      state - The StateHolder to modify.
      key - The first key
      value - The first value
      Returns:
      The StateHolder this was called on