Class BlockStateUtils

java.lang.Object
com.minecolonies.api.util.BlockStateUtils

public class BlockStateUtils extends Object
Utility class for handling block states and their properties
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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 hashmap
    static boolean
    stateEqualsStateByBlockAndProp(@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 properties
    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
    static boolean
    stateEqualsStateInPropertyByName(@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>>
    boolean
    stateEqualsStateWithoutProp(@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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 compare
      state2 - Second state to compare
      propertyName - 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 compare
      state2 - Second state to compare
      propertyName - 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 property
      name - 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 check
      name - 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 compare
      state2 - Second state to compare
      prop - 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 compare
      state2 - Second state to compare
      Returns:
      True if states are equal