类 GetEnchantmentLevelEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.enchanting.GetEnchantmentLevelEvent
public class GetEnchantmentLevelEvent
extends net.neoforged.bus.api.Event
This event is fired whenever the enchantment level of a particular item is requested for gameplay purposes.
It is called from
and
.
It is called from
引用无效
IItemStackExtension#getEnchantmentLevel(Enchantment)
引用无效
IItemStackExtension#getAllEnchantments()
It is not fired for interactions with NBT, which means these changes will not reflect in the item tooltip.
-
字段概要
字段修饰符和类型字段说明protected final ItemEnchantments.Mutable
protected final HolderLookup.RegistryLookup
<Enchantment> protected final ItemStack
protected final @Nullable Holder
<Enchantment> -
构造器概要
构造器构造器说明GetEnchantmentLevelEvent
(ItemStack stack, ItemEnchantments.Mutable enchantments, @Nullable Holder<Enchantment> targetEnchant, HolderLookup.RegistryLookup<Enchantment> lookup) -
方法概要
修饰符和类型方法说明Returns the mutable enchantment->level map.getHolder
(ResourceKey<Enchantment> key) Attempts to resolve aHolder.Reference
for a target enchantment.返回 the underlying registry lookup, which can be used to access enchantment Holders。getStack()
Returns the item stack that is being queried against.@Nullable Holder
<Enchantment> This method returns the specific enchantment being queried from引用无效
IItemStackExtension#getEnchantmentLevel(Enchantment)
boolean
isTargetting
(Holder<Enchantment> ench) Helper method aroundgetTargetEnchant()
that checks if the target is the specified enchantment, or if the target is null.boolean
isTargetting
(ResourceKey<Enchantment> ench) Helper method aroundgetTargetEnchant()
that checks if the target is the specified enchantment, or if the target is null.
-
字段详细资料
-
stack
-
enchantments
-
targetEnchant
-
lookup
-
-
构造器详细资料
-
GetEnchantmentLevelEvent
public GetEnchantmentLevelEvent(ItemStack stack, ItemEnchantments.Mutable enchantments, @Nullable @Nullable Holder<Enchantment> targetEnchant, HolderLookup.RegistryLookup<Enchantment> lookup)
-
-
方法详细资料
-
getStack
Returns the item stack that is being queried against. -
getEnchantments
Returns the mutable enchantment->level map. -
getTargetEnchant
This method returns the specific enchantment being queried from引用无效
IItemStackExtension#getEnchantmentLevel(Enchantment)
If this is value is present, you only need to adjust the level of that enchantment.
If this value is null, then the event was fired from
引用无效
IItemStackExtension#getAllEnchantments()
- 返回:
- The specific enchantment being queried, or null, if all enchantments are being requested.
-
isTargetting
Helper method aroundgetTargetEnchant()
that checks if the target is the specified enchantment, or if the target is null.- 参数:
ench
- The enchantment to check.- 返回:
- If modifications to the passed enchantment are relevant for this event.
- 另请参阅:
-
isTargetting
Helper method aroundgetTargetEnchant()
that checks if the target is the specified enchantment, or if the target is null.- 参数:
ench
- The enchantment to check.- 返回:
- If modifications to the passed enchantment are relevant for this event.
- 另请参阅:
-
getHolder
Attempts to resolve aHolder.Reference
for a target enchantment. Since enchantments are data, they are not guaranteed to exist.- 参数:
key
- The target resource key- 返回:
- If the holder was available, an Optional containing it; otherwise an empty Optional.
-
getLookup
返回 the underlying registry lookup, which can be used to access enchantment Holders。- 返回:
- the underlying registry lookup, which can be used to access enchantment Holders
-