Package etithespirit.orimod.util.level
Class StateHelper
java.lang.Object
etithespirit.orimod.util.level.StateHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 itsFluidState
.static void
setBlockAndUpdateIn
(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos at, net.minecraft.world.level.block.state.StateHolder<?, ?> state) Sets the givenStateHolder
, which is expected to be aBlockState
orFluidState
, 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 anonymousStateHolder
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 anonymousStateHolder
into a single method call.
-
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 givenStateHolder
, which is expected to be aBlockState
orFluidState
, 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 itsFluidState
. Otherwise, this returns theBlockState
.- 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, ArgumentNullExceptionA utility to chain setValue calls on an anonymousStateHolder
into a single method call. For compliance with the method in use, values must be something that implementsComparable
(which all properties do).- Parameters:
state
- TheStateHolder
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 anonymousStateHolder
into a single method call. For compliance with the method in use, values must be something that implementsComparable
(which all properties do).- Parameters:
state
- TheStateHolder
to modify.key
- The first keyvalue
- The first value- Returns:
- The
StateHolder
this was called on
-