Package com.minecolonies.api.util
Class BlockStateUtils
java.lang.Object
com.minecolonies.api.util.BlockStateUtils
Utility class for handling block states and their properties
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.level.block.state.properties.Property<?> getPropertyByName(@NotNull Collection<net.minecraft.world.level.block.state.properties.Property<?>> properties, @NotNull String name) Checks a list of properties for a matching name.static net.minecraft.world.level.block.state.properties.Property<?> getPropertyByNameFromState(@NotNull net.minecraft.world.level.block.state.BlockState state, @NotNull String name) Get the property object of a state matching the given name Caches lookups in the propertyBlockMap hashmapstatic booleanstateEqualsStateByBlockAndProp(@NotNull net.minecraft.world.level.block.state.BlockState state1, @NotNull net.minecraft.world.level.block.state.BlockState state2, @NotNull String propertyName) Checks if two states contain the same block and are equal in the given property, or all propertiesstatic booleanstateEqualsStateInBlockAndProp(net.minecraft.world.level.block.state.BlockState state1, net.minecraft.world.level.block.state.BlockState state2) Check if two states are equal in Block and Propertiesstatic booleanstateEqualsStateInPropertyByName(@NotNull net.minecraft.world.level.block.state.BlockState state1, @NotNull net.minecraft.world.level.block.state.BlockState state2, @NotNull String propertyName) Compares two states by a property matching the given propertyName.static <T extends Comparable<T>>
booleanstateEqualsStateWithoutProp(@NotNull net.minecraft.world.level.block.state.BlockState state1, @NotNull net.minecraft.world.level.block.state.BlockState state2, @NotNull net.minecraft.world.level.block.state.properties.Property<T> prop) Compare two Blockstates ignoring one Property
-
Method Details
-
stateEqualsStateByBlockAndProp
public static boolean stateEqualsStateByBlockAndProp(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState state1, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState state2, @NotNull @NotNull String propertyName) Checks if two states contain the same block and are equal in the given property, or all properties- Parameters:
state1- First state to comparestate2- Second state to comparepropertyName- property name to search for- Returns:
- true or false
-
stateEqualsStateInPropertyByName
public static boolean stateEqualsStateInPropertyByName(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState state1, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState state2, @NotNull @NotNull String propertyName) Compares two states by a property matching the given propertyName. Compared by the name of the Property-value, use when property is an enum without an actual value.- Parameters:
state1- First state to comparestate2- Second state to comparepropertyName- the property name we're searching for- Returns:
- true if states match in the property
-
getPropertyByNameFromState
public static net.minecraft.world.level.block.state.properties.Property<?> getPropertyByNameFromState(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState state, @NotNull @NotNull String name) Get the property object of a state matching the given name Caches lookups in the propertyBlockMap hashmap- Parameters:
state- Blockstate we're checking for a propertyname- name of the property to find- Returns:
- the property.
-
getPropertyByName
public static net.minecraft.world.level.block.state.properties.Property<?> getPropertyByName(@NotNull @NotNull Collection<net.minecraft.world.level.block.state.properties.Property<?>> properties, @NotNull @NotNull String name) Checks a list of properties for a matching name.- Parameters:
properties- the properties to checkname- the property name we're looking for- Returns:
- Property object found
-
stateEqualsStateWithoutProp
public static <T extends Comparable<T>> boolean stateEqualsStateWithoutProp(@NotNull @NotNull net.minecraft.world.level.block.state.BlockState state1, @NotNull @NotNull net.minecraft.world.level.block.state.BlockState state2, @NotNull @NotNull net.minecraft.world.level.block.state.properties.Property<T> prop) Compare two Blockstates ignoring one Property- Parameters:
state1- First state to comparestate2- Second state to compareprop- Property to not compare- Returns:
- true if states are equal without the property
-
stateEqualsStateInBlockAndProp
public static boolean stateEqualsStateInBlockAndProp(net.minecraft.world.level.block.state.BlockState state1, net.minecraft.world.level.block.state.BlockState state2) Check if two states are equal in Block and Properties- Parameters:
state1- First state to comparestate2- Second state to compare- Returns:
- True if states are equal
-