类 ItemAttributeModifierEvent.ItemAttributeModifiersBuilder
java.lang.Object
net.neoforged.neoforge.event.ItemAttributeModifierEvent.ItemAttributeModifiersBuilder
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.
-
嵌套类概要
嵌套类修饰符和类型类说明private static final record
Internal key class. -
字段概要
字段修饰符和类型字段说明private List
<ItemAttributeModifiers.Entry> private Map
<ItemAttributeModifierEvent.ItemAttributeModifiersBuilder.Key, ItemAttributeModifiers.Entry> -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明(专用程序包) 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()
(专用程序包) void
clear()
(专用程序包) List
<ItemAttributeModifiers.Entry> 返回 an unmodifiable view of the underlying entry list。(专用程序包) boolean
removeIf
(Predicate<ItemAttributeModifiers.Entry> condition) Removes modifiers based on a condition.(专用程序包) boolean
removeModifier
(Holder<Attribute> attribute, ResourceLocation id) Removes a modifier for the target attribute with the given id.(专用程序包) ItemAttributeModifiers.Entry
replaceModifier
(Holder<Attribute> attribute, AttributeModifier modifier, EquipmentSlotGroup slot) Adds a modifier to the list, replacing any existing modifiers with the same id.
-
字段详细资料
-
entries
-
entriesByKey
private Map<ItemAttributeModifierEvent.ItemAttributeModifiersBuilder.Key,ItemAttributeModifiers.Entry> entriesByKey
-
-
构造器详细资料
-
ItemAttributeModifiersBuilder
ItemAttributeModifiersBuilder(ItemAttributeModifiers defaultModifiers)
-
-
方法详细资料
-
getEntryView
List<ItemAttributeModifiers.Entry> getEntryView()返回 an unmodifiable view of the underlying entry list。- 返回:
- 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.- 返回:
- true if the modifier was added
-
removeModifier
Removes a modifier for the target attribute with the given id.- 返回:
- true if a modifier was removed
-
replaceModifier
@Nullable ItemAttributeModifiers.Entry replaceModifier(Holder<Attribute> attribute, AttributeModifier modifier, EquipmentSlotGroup slot) Adds a modifier to the list, replacing any existing modifiers with the same id.- 返回:
- the previous modifier, or null if there was no previous modifier with the same id
-
removeIf
Removes modifiers based on a condition.- 返回:
- true if any modifiers were removed
-
clear
void clear() -
build
-