StateHelper
com.jsmacrosce.jsmacros.client.api.helper.world.StateHelper
Base helper for block and fluid states, exposing their named properties. 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
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
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).
Returns: the property names and their current values.
with
Returns a new helper with the named property set; the original helper and world are unchanged. Throws IllegalArgumentException if the property is absent or the value is invalid. Property names and value spellings are shown by toMap().
Parameters:
Returns: a new helper of the same kind holding the state with that property set.