Class StateHolder<O,S>

java.lang.Object
net.minecraft.world.level.block.state.StateHolder<O,S>
Direct Known Subclasses:
BlockBehaviour.BlockStateBase, FluidState

public abstract class StateHolder<O,S> extends Object
  • Field Details

  • Constructor Details

    • StateHolder

      protected StateHolder(O owner, it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap<Property<?>, Comparable<?>> values, com.mojang.serialization.MapCodec<S> propertiesCodec)
  • Method Details

    • cycle

      public <T extends Comparable<T>> S cycle(Property<T> property)
    • findNextInCollection

      protected static <T> T findNextInCollection(List<T> values, T current)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getProperties

      public Collection<Property<?>> getProperties()
    • hasProperty

      public boolean hasProperty(Property<?> property)
    • getValue

      public <T extends Comparable<T>> T getValue(Property<T> property)
      Returns:
      the value of the given Property for this state
    • getOptionalValue

      public <T extends Comparable<T>> Optional<T> getOptionalValue(Property<T> property)
    • getValueOrElse

      public <T extends Comparable<T>> T getValueOrElse(Property<T> property, T defaultValue)
    • getNullableValue

      private <T extends Comparable<T>> @Nullable T getNullableValue(Property<T> property)
    • setValue

      public <T extends Comparable<T>, V extends T> S setValue(Property<T> property, V value)
    • trySetValue

      public <T extends Comparable<T>, V extends T> S trySetValue(Property<T> property, V value)
    • setValueInternal

      private <T extends Comparable<T>, V extends T> S setValueInternal(Property<T> property, V value, Comparable<?> oldValue)
    • populateNeighbours

      public void populateNeighbours(Map<Map<Property<?>, Comparable<?>>, S> statesByValues)
    • makeNeighbourValues

      private Map<Property<?>, Comparable<?>> makeNeighbourValues(Property<?> property, Comparable<?> value)
    • getValues

      public Map<Property<?>, Comparable<?>> getValues()
    • codec

      protected static <O, S extends StateHolder<O,S>> com.mojang.serialization.Codec<S> codec(com.mojang.serialization.Codec<O> ownerCodec, Function<O,S> defaultState)