Record Class EnvironmentAttributeMap
java.lang.Object
java.lang.Record
dev.wyck.environment.attribute.EnvironmentAttributeMap
@NullMarked
@AsOf("2.1.0")
public record EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, Map<ResourceKey, EnvironmentAttributeMap.Modification<?,?>> modifications, List<EnvironmentAttributeMap.Pending<?>> pending)
extends Record
A collection of EnvironmentAttributes.
- Since:
- 1.1.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder for creating WrappedEnvironmentAttributeMap instances.static final recordA fixed operation and argument applied to an environment attribute.static final recordA deferred attribute entry, holding a supplier and its exposed value. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes) EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, List<EnvironmentAttributeMap.Pending<?>> pending) EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, Map<ResourceKey, EnvironmentAttributeMap.Modification<?, ?>> modifications, List<EnvironmentAttributeMap.Pending<?>> pending) Creates an instance of aEnvironmentAttributeMaprecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the fully resolved directly set attribute map.builder()Creates a new Builder instance.static EnvironmentAttributeMapReads a Minecraft environment attribute map into a wrapper.booleanempty()final booleanIndicates whether some other object is "equal to" this one.<V> @Nullable Vget(EnvironmentAttributeSupplier<V> supplier) Returns the value of the given attribute, or null if it is not present.final inthashCode()Returns a hash code value for this object.<V,A> @Nullable EnvironmentAttributeMap.Modification <V, A> modification(EnvironmentAttributeSupplier<V> supplier) Returns the modifier for the given attribute, or null if that attribute is directly set or absent.Returns the modifiers in this map, indexed by their attribute keys.static <V> EnvironmentAttributeMapof(EnvironmentAttribute<V>... attributes) Creates a new WrappedEnvironmentAttributeMap from the given attributes.pending()Returns the value of thependingrecord component.final StringtoString()Returns a string representation of this record class.values()Returns the directly set wrapped attributes as a collection.with(EnvironmentAttributeMap source) Creates a new map containing every entry from this map plus every entry from the given map.with(EnvironmentAttributeSupplier<V> supplier, @Nullable V value) Creates a new WrappedEnvironmentAttributeMap with the given attribute added.with(FriendlyColorSupplier supplier, @Nullable String hex) Creates a new WrappedEnvironmentAttributeMap with the given color attribute added.<V,A> EnvironmentAttributeMap withModifier(EnvironmentAttributeSupplier<V> supplier, AttributeOperation operation, A argument) Creates a new map with a modifier for the given attribute.
-
Field Details
-
EMPTY
-
-
Constructor Details
-
EnvironmentAttributeMap
@AsOf("2.1.0") public EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, Map<ResourceKey, EnvironmentAttributeMap.Modification<?, ?>> modifications, List<EnvironmentAttributeMap.Pending<?>> pending) Creates an instance of aEnvironmentAttributeMaprecord class.- Parameters:
attributes- the value for theattributesrecord componentmodifications- the value for themodificationsrecord componentpending- the value for thependingrecord component
-
EnvironmentAttributeMap
-
EnvironmentAttributeMap
@AsOf("3.3.0") public EnvironmentAttributeMap(Map<ResourceKey, EnvironmentAttribute<?>> attributes, List<EnvironmentAttributeMap.Pending<?>> pending)
-
-
Method Details
-
attributes
Returns the fully resolved directly set attribute map.- Returns:
- the resolved attributes, in an unmodifiable map
- Since:
- 2.1.0
-
values
Returns the directly set wrapped attributes as a collection. Order matches insertion order.- Returns:
- the directly set wrapped attributes
- Since:
- 2.1.0
-
modifications
Returns the modifiers in this map, indexed by their attribute keys.- Returns:
- the attribute modifiers
- Since:
- 3.3.0
-
modification
@AsOf("3.3.0") public <V,A> @Nullable EnvironmentAttributeMap.Modification<V,A> modification(EnvironmentAttributeSupplier<V> supplier) Returns the modifier for the given attribute, or null if that attribute is directly set or absent.- Type Parameters:
V- the value type of the attributeA- the argument type of the modifier- Parameters:
supplier- the attribute supplier- Returns:
- the modifier associated with the attribute, or null if absent
- Since:
- 3.3.0
-
get
Returns the value of the given attribute, or null if it is not present. Pending values take precedence over resolved ones, and the most recently set pending value wins.- Type Parameters:
V- the type of the attribute- Parameters:
supplier- the attribute supplier- Returns:
- the directly set value associated with the supplier, or null if modified or absent
- Since:
- 3.0.0
-
empty
- Returns:
- true if the map is empty, false otherwise.
- Since:
- 1.1.0
-
toBuilder
- Returns:
- a new builder pre-populated with this map's attributes.
- Since:
- 2.1.0
-
with
@AsOf("2.1.0") public <V> EnvironmentAttributeMap with(EnvironmentAttributeSupplier<V> supplier, @Nullable V value) Creates a new WrappedEnvironmentAttributeMap with the given attribute added.- Type Parameters:
V- the type of the attribute- Parameters:
supplier- the attribute suppliervalue- the value to set- Returns:
- a new WrappedEnvironmentAttributeMap with the given attribute added
- Since:
- 2.1.0
-
withModifier
@AsOf("3.3.0") public <V,A> EnvironmentAttributeMap withModifier(EnvironmentAttributeSupplier<V> supplier, AttributeOperation operation, A argument) Creates a new map with a modifier for the given attribute.The operation and argument use the same types as an attribute timeline track. For example, multiplying a float attribute takes a
Floatargument, whileAttributeOperation.ALPHA_BLENDtakes anAlphaValuefor float attributes.- Type Parameters:
V- the value type of the attributeA- the argument type of the modifier- Parameters:
supplier- the attribute supplieroperation- the operation applied to the attributeargument- the operation argument- Returns:
- a new map containing the modifier
- Since:
- 3.3.0
-
with
@AsOf("2.1.0") public EnvironmentAttributeMap with(FriendlyColorSupplier supplier, @Nullable String hex) Creates a new WrappedEnvironmentAttributeMap with the given color attribute added.- Parameters:
supplier- the color attribute supplierhex- the hex value (e.g."#FF10F0")- Returns:
- a new WrappedEnvironmentAttributeMap with the given color attribute added
- Since:
- 2.1.0
-
with
Creates a new map containing every entry from this map plus every entry from the given map.Unlike
EnvironmentAttributeMap.Builder.merge(EnvironmentAttributeMap), colliding keys do not throw: any attribute, modifier, or pending value insourcefully replaces the entry for that key in this map, regardless of which form it took here.- Parameters:
source- the map whose entries take precedence- Returns:
- a new map with the given map's entries applied over this one
- Since:
- 3.4.0
-
builder
Creates a new Builder instance.- Returns:
- a new Builder instance
- Since:
- 1.1.0
-
of
@SafeVarargs @AsOf("2.1.0") public static <V> EnvironmentAttributeMap of(EnvironmentAttribute<V>... attributes) Creates a new WrappedEnvironmentAttributeMap from the given attributes.- Parameters:
attributes- the attributes to include- Returns:
- a new WrappedEnvironmentAttributeMap
- Since:
- 2.1.0
-
decode
Reads a Minecraft environment attribute map into a wrapper.- Parameters:
minecraftAttributeMap- the attribute map to read- Returns:
- the wrapper for it
- Since:
- 3.3.0
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
pending
Returns the value of thependingrecord component.- Returns:
- the value of the
pendingrecord component
-