Class EnumProperty<T extends Enum<T> & StringIdentifiable>

java.lang.Object
net.minecraft.state.property.Property<T>
net.minecraft.state.property.EnumProperty<T>
Direct Known Subclasses:
DirectionProperty

public class EnumProperty<T extends Enum<T> & StringIdentifiable> extends Property<T>
Represents a property that has enum values.

Notes on the enum class:

See Properties for example usages.

Mappings:
Namespace Name
named net/minecraft/state/property/EnumProperty
intermediary net/minecraft/class_2754
official dwh
  • Field Details

    • HAS_HOLES

      private static final int HAS_HOLES
      Indicates that enums' ordinals are non-consecutive (thus, having "holes"). This makes some lookups' average speed from O(1) to O(n).
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named HAS_HOLES Lnet/minecraft/state/property/EnumProperty;HAS_HOLES:I
      intermediary field_54245 Lnet/minecraft/class_2754;field_54245:I
      official c Ldwh;c:I
    • values

      private final List<T extends Enum<T> & StringIdentifiable> values
      Mappings:
      Namespace Name Mixin selector
      named values Lnet/minecraft/state/property/EnumProperty;values:Ljava/util/List;
      intermediary field_12595 Lnet/minecraft/class_2754;field_12595:Ljava/util/List;
      official d Ldwh;d:Ljava/util/List;
    • byName

      private final Map<String,T extends Enum<T> & StringIdentifiable> byName
      Mappings:
      Namespace Name Mixin selector
      named byName Lnet/minecraft/state/property/EnumProperty;byName:Ljava/util/Map;
      intermediary field_12596 Lnet/minecraft/class_2754;field_12596:Ljava/util/Map;
      official e Ldwh;e:Ljava/util/Map;
    • minOrdinal

      protected int minOrdinal
      Mappings:
      Namespace Name Mixin selector
      named minOrdinal Lnet/minecraft/state/property/EnumProperty;minOrdinal:I
      intermediary field_54243 Lnet/minecraft/class_2754;field_54243:I
      official a Ldwh;a:I
    • maxOrdinal

      protected final int maxOrdinal
      Mappings:
      Namespace Name Mixin selector
      named maxOrdinal Lnet/minecraft/state/property/EnumProperty;maxOrdinal:I
      intermediary field_54244 Lnet/minecraft/class_2754;field_54244:I
      official b Ldwh;b:I
  • Constructor Details

    • EnumProperty

      protected EnumProperty(String name, Class<T> type, List<T> values)
      Mappings:
      Namespace Name Mixin selector
      named <init> Lnet/minecraft/state/property/EnumProperty;<init>(Ljava/lang/String;Ljava/lang/Class;Ljava/util/List;)V
      intermediary <init> Lnet/minecraft/class_2754;<init>(Ljava/lang/String;Ljava/lang/Class;Ljava/util/List;)V
      official <init> Ldwh;<init>(Ljava/lang/String;Ljava/lang/Class;Ljava/util/List;)V
  • Method Details

    • getValues

      public List<T> getValues()
      Returns all possible values of this property.
      Specified by:
      getValues in class Property<T extends Enum<T> & StringIdentifiable>
      Mappings:
      Namespace Name Mixin selector
      named getValues Lnet/minecraft/state/property/Property;getValues()Ljava/util/List;
      intermediary method_11898 Lnet/minecraft/class_2769;method_11898()Ljava/util/List;
      official a Ldwm;a()Ljava/util/List;
    • parse

      public Optional<T> parse(String name)
      Specified by:
      parse in class Property<T extends Enum<T> & StringIdentifiable>
      Mappings:
      Namespace Name Mixin selector
      named parse Lnet/minecraft/state/property/Property;parse(Ljava/lang/String;)Ljava/util/Optional;
      intermediary method_11900 Lnet/minecraft/class_2769;method_11900(Ljava/lang/String;)Ljava/util/Optional;
      official b Ldwm;b(Ljava/lang/String;)Ljava/util/Optional;
    • name

      public String name(T t)
      Description copied from class: Property
      Returns the name of the given value of this property.
      Specified by:
      name in class Property<T extends Enum<T> & StringIdentifiable>
      Mappings:
      Namespace Name Mixin selector
      named name Lnet/minecraft/state/property/EnumProperty;name(Ljava/lang/Enum;)Ljava/lang/String;
      intermediary method_11846 Lnet/minecraft/class_2754;method_11846(Ljava/lang/Enum;)Ljava/lang/String;
      official a Ldwh;a(Ljava/lang/Enum;)Ljava/lang/String;
    • ordinal

      public int ordinal(T t)
      Specified by:
      ordinal in class Property<T extends Enum<T> & StringIdentifiable>
      Mappings:
      Namespace Name Mixin selector
      named ordinal Lnet/minecraft/state/property/EnumProperty;ordinal(Ljava/lang/Enum;)I
      intermediary method_64221 Lnet/minecraft/class_2754;method_64221(Ljava/lang/Enum;)I
      official b Ldwh;b(Ljava/lang/Enum;)I
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Property<T extends Enum<T> & StringIdentifiable>
      Mappings:
      Namespace Name Mixin selector
      named equals Lnet/minecraft/state/property/Property;equals(Ljava/lang/Object;)Z
      intermediary equals Lnet/minecraft/class_2769;equals(Ljava/lang/Object;)Z
      official equals Ldwm;equals(Ljava/lang/Object;)Z
    • computeHashCode

      public int computeHashCode()
      Overrides:
      computeHashCode in class Property<T extends Enum<T> & StringIdentifiable>
      Mappings:
      Namespace Name Mixin selector
      named computeHashCode Lnet/minecraft/state/property/Property;computeHashCode()I
      intermediary method_11799 Lnet/minecraft/class_2769;method_11799()I
      official b Ldwm;b()I
    • of

      public static <T extends Enum<T> & StringIdentifiable> EnumProperty<T> of(String name, Class<T> type)
      Creates an enum property with all values of the given enum class.

      See notes on the enum class.

      Parameters:
      name - the name of the property; see the note on the name
      type - the type of the values the property contains
      Throws:
      IllegalArgumentException - if multiple values have the same name
      Mappings:
      Namespace Name Mixin selector
      named of Lnet/minecraft/state/property/EnumProperty;of(Ljava/lang/String;Ljava/lang/Class;)Lnet/minecraft/state/property/EnumProperty;
      intermediary method_11850 Lnet/minecraft/class_2754;method_11850(Ljava/lang/String;Ljava/lang/Class;)Lnet/minecraft/class_2754;
      official a Ldwh;a(Ljava/lang/String;Ljava/lang/Class;)Ldwh;
    • of

      public static <T extends Enum<T> & StringIdentifiable> EnumProperty<T> of(String name, Class<T> type, Predicate<T> filter)
      Creates an enum property with the values allowed by the given filter.

      See notes on the enum class.

      Parameters:
      name - the name of the property; see the note on the name
      type - the type of the values the property contains
      filter - the filter which specifies if a value is allowed; required to allow 2 or more values
      Throws:
      IllegalArgumentException - if multiple values have the same name
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named of Lnet/minecraft/state/property/EnumProperty;of(Ljava/lang/String;Ljava/lang/Class;Ljava/util/function/Predicate;)Lnet/minecraft/state/property/EnumProperty;
      intermediary method_11848 Lnet/minecraft/class_2754;method_11848(Ljava/lang/String;Ljava/lang/Class;Ljava/util/function/Predicate;)Lnet/minecraft/class_2754;
      official a Ldwh;a(Ljava/lang/String;Ljava/lang/Class;Ljava/util/function/Predicate;)Ldwh;
    • of

      public static <T extends Enum<T> & StringIdentifiable> EnumProperty<T> of(String name, Class<T> type, T[] values)
      Creates an enum property with the given values.

      See notes on the enum class.

      Parameters:
      name - the name of the property; see the note on the name
      type - the type of the values the property contains
      values - the values the property contains; required to have 2 or more values
      Throws:
      IllegalArgumentException - if multiple values have the same name
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named of Lnet/minecraft/state/property/EnumProperty;of(Ljava/lang/String;Ljava/lang/Class;[Ljava/lang/Enum;)Lnet/minecraft/state/property/EnumProperty;
      intermediary method_11849 Lnet/minecraft/class_2754;method_11849(Ljava/lang/String;Ljava/lang/Class;[Ljava/lang/Enum;)Lnet/minecraft/class_2754;
      official a Ldwh;a(Ljava/lang/String;Ljava/lang/Class;[Ljava/lang/Enum;)Ldwh;
    • of

      public static <T extends Enum<T> & StringIdentifiable> EnumProperty<T> of(String name, Class<T> type, List<T> values)
      Creates an enum property with the given values.

      See notes on the enum class.

      Parameters:
      name - the name of the property; see the note on the name
      type - the type of the values the property contains
      Throws:
      IllegalArgumentException - if multiple values have the same name
      See Also:
      Mappings:
      Namespace Name Mixin selector
      named of Lnet/minecraft/state/property/EnumProperty;of(Ljava/lang/String;Ljava/lang/Class;Ljava/util/List;)Lnet/minecraft/state/property/EnumProperty;
      intermediary method_11847 Lnet/minecraft/class_2754;method_11847(Ljava/lang/String;Ljava/lang/Class;Ljava/util/List;)Lnet/minecraft/class_2754;
      official a Ldwh;a(Ljava/lang/String;Ljava/lang/Class;Ljava/util/List;)Ldwh;