Package net.minecraft.state.property
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:
- The enum class is required to have 2 or more values.
- The enum class is required to provide a name for each value by
overriding
StringIdentifiable.asString(). - The names of the values are required to match the valid name pattern.
Otherwise,
IllegalArgumentExceptionwill be thrown during the validation of a property.
See Properties for example
usages.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.state.property.Property
Property.Value<T extends Comparable<T>> -
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description protectedEnumProperty(String name, Class<T> type, Collection<T> values) -
Method Summary
Modifier and Type Method Description intcomputeHashCode()booleanequals(Object object)Collection<T>getValues()Returns all possible values of this property.Stringname(T t)Returns the name of the given value of this property.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.static <T extends Enum<T> & StringIdentifiable>
EnumProperty<T>of(String name, Class<T> type, Collection<T> values)Creates an enum property with the given values.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.static <T extends Enum<T> & StringIdentifiable>
EnumProperty<T>of(String name, Class<T> type, T[] values)Creates an enum property with the given values.Optional<T>parse(String name)Methods inherited from class net.minecraft.state.property.Property
createValue, createValue, getName, getType, getValueCodec, hashCode, stream, toString
-
Field Details
-
values
-
byName
-
-
Constructor Details
-
EnumProperty
-
-
Method Details
-
getValues
Returns all possible values of this property. -
parse
-
name
Description copied from class:PropertyReturns the name of the given value of this property. -
equals
-
computeHashCode
public int computeHashCode()- Overrides:
computeHashCodein classProperty<T extends Enum<T> & StringIdentifiable>
-
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.- Parameters:
name- the name of the property; see the note on the nametype- the type of the values the property contains- Throws:
IllegalArgumentException- if multiple values have the same name
-
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.- Parameters:
name- the name of the property; see the note on the nametype- the type of the values the property containsfilter- 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:
of(String, Class)
-
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.- Parameters:
name- the name of the property; see the note on the nametype- the type of the values the property containsvalues- the values the property contains; required to have 2 or more values- Throws:
IllegalArgumentException- if multiple values have the same name- See Also:
of(String, Class)
-
of
public static <T extends Enum<T> & StringIdentifiable> EnumProperty<T> of(String name, Class<T> type, Collection<T> values)Creates an enum property with the given values.- Parameters:
name- the name of the property; see the note on the nametype- the type of the values the property containsvalues- the values the property contains; required to have 2 or more values- Throws:
IllegalArgumentException- if multiple values have the same name- See Also:
of(String, Class)
-