Package net.neoforged.neoforge.event
Class ItemAttributeModifierEvent.ItemAttributeModifiersBuilder
java.lang.Object
net.neoforged.neoforge.event.ItemAttributeModifierEvent.ItemAttributeModifiersBuilder
- Enclosing class:
ItemAttributeModifierEvent
Advanced version of
ItemAttributeModifiers.Builder
which supports removal and better sanity-checking.
The original builder only supports additions and does not guarantee that no duplicate modifiers exist for a given id.
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static final record
Internal key class. -
Field Summary
Modifier and TypeFieldDescriptionprivate List
<ItemAttributeModifiers.Entry> private Map
<ItemAttributeModifierEvent.ItemAttributeModifiersBuilder.Key, ItemAttributeModifiers.Entry> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) boolean
addModifier
(Holder<Attribute> attribute, AttributeModifier modifier, EquipmentSlotGroup slot) Attempts to add a new modifier, refusing if one is already present with the same id.build
(boolean showInTooltip) (package private) void
clear()
(package private) List
<ItemAttributeModifiers.Entry> Returns an unmodifiable view of the underlying entry list.(package private) boolean
removeIf
(Predicate<ItemAttributeModifiers.Entry> condition) Removes modifiers based on a condition.(package private) boolean
removeModifier
(Holder<Attribute> attribute, ResourceLocation id) Removes a modifier for the target attribute with the given id.
-
Field Details
-
entries
-
entriesByKey
private Map<ItemAttributeModifierEvent.ItemAttributeModifiersBuilder.Key,ItemAttributeModifiers.Entry> entriesByKey
-
-
Constructor Details
-
ItemAttributeModifiersBuilder
ItemAttributeModifiersBuilder(ItemAttributeModifiers defaultModifiers)
-
-
Method Details
-
getEntryView
List<ItemAttributeModifiers.Entry> getEntryView()Returns an unmodifiable view of the underlying entry list.- Returns:
- an unmodifiable view of the underlying entry list
-
addModifier
boolean addModifier(Holder<Attribute> attribute, AttributeModifier modifier, EquipmentSlotGroup slot) Attempts to add a new modifier, refusing if one is already present with the same id.- Returns:
- true if the modifier was added
-
removeModifier
Removes a modifier for the target attribute with the given id.- Returns:
- true if a modifier was removed
-
removeIf
Removes modifiers based on a condition.- Returns:
- true if any modifiers were removed
-
clear
void clear() -
build
-