Record Class ItemEnchantments
java.lang.Object
java.lang.Record
fr.fidorial.item.component.ItemEnchantments
- Record Components:
levels- the level of each enchantment, keyed by enchantment,1-255
The enchantments a stack carries, under
minecraft:enchantments, or stores, under
minecraft:stored_enchantments.- Since:
- 0.1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ItemEnchantmentsNo enchantment at all.static final intThe highest level an enchantment may have on a stack. -
Constructor Summary
ConstructorsConstructorDescriptionItemEnchantments(Map<TypedKey<EnchantmentDefinition>, Integer> levels) Creates an instance of aItemEnchantmentsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.booleanhas(TypedKey<EnchantmentDefinition> enchantment) Returns whetherenchantmentis present.final inthashCode()Returns a hash code value for this object.booleanisEmpty()Returns whether no enchantment is present.intlevel(TypedKey<EnchantmentDefinition> enchantment) Returns the level ofenchantment,0when absent.levels()Returns the value of thelevelsrecord component.final StringtoString()Returns a string representation of this record class.with(TypedKey<EnchantmentDefinition> enchantment, int level) Returns a copy withenchantmentset tolevel.without(TypedKey<EnchantmentDefinition> enchantment) Returns a copy withoutenchantment, or this instance if it is absent.
-
Field Details
-
MAX_LEVEL
public static final int MAX_LEVELThe highest level an enchantment may have on a stack.- See Also:
-
EMPTY
No enchantment at all.
-
-
Constructor Details
-
ItemEnchantments
Creates an instance of aItemEnchantmentsrecord class.- Parameters:
levels- the value for thelevelsrecord component
-
-
Method Details
-
level
Returns the level ofenchantment,0when absent.- Parameters:
enchantment- the enchantment- Returns:
- the level of
enchantment,0when absent - Since:
- 0.1.0
-
has
Returns whetherenchantmentis present.- Parameters:
enchantment- the enchantment- Returns:
- whether
enchantmentis present - Since:
- 0.1.0
-
isEmpty
public boolean isEmpty()Returns whether no enchantment is present.- Returns:
- whether no enchantment is present
- Since:
- 0.1.0
-
with
Returns a copy withenchantmentset tolevel.- Parameters:
enchantment- the enchantmentlevel- the level, from1to 255- Returns:
- a copy with
enchantmentset tolevel - Throws:
IllegalArgumentException- if the level is out of range- Since:
- 0.1.0
-
without
Returns a copy withoutenchantment, or this instance if it is absent.- Parameters:
enchantment- the enchantment- Returns:
- a copy without
enchantment, or this instance if it is absent - Since:
- 0.1.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). -
levels
-