类 GetEnchantmentLevelEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.GetEnchantmentLevelEvent

public class GetEnchantmentLevelEvent extends net.minecraftforge.eventbus.api.Event
This event is fired whenever the enchantment level of a particular item is requested for gameplay purposes.
It is called from IForgeItemStack.getEnchantmentLevel(Enchantment) and IForgeItemStack.getAllEnchantments().

It is not fired for interactions with NBT, which means these changes will not reflect in the item tooltip.

  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • getStack

      public ItemStack getStack()
      Returns the item stack that is being queried against.
    • getEnchantments

      public Map<Enchantment,Integer> getEnchantments()
      Returns the mutable enchantment->level map.
    • getTargetEnchant

      @Nullable public @Nullable Enchantment getTargetEnchant()
      This method returns the specific enchantment being queried from IForgeItemStack.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 IForgeItemStack.getAllEnchantments() and all enchantments should be populated.

      返回:
      The specific enchantment being queried, or null, if all enchantments are being requested.
    • isTargetting

      public boolean isTargetting(Enchantment ench)
      Helper method around getTargetEnchant() 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.