Class EnchantedEntityLootEvent

java.lang.Object
net.neoforged.bus.api.Event

public class EnchantedEntityLootEvent extends LivingEvent
Fired on the server when an entity is dropping loot and the level of a specific enchantment is being queried.

Notably, this fires when EnchantedCountIncreaseFunction or LootItemRandomChanceWithEnchantedBonusCondition are evaluated, as well as when

invalid reference
EnchantmentEffectComponent#EQUIPMENT_DROPS
is being processed. Mods that implement similar loot conditions or functions should fire this event as well.

If you do not need the additional context of this event, prefer GetEnchantmentLevelEvent for managing enchantment levels.

  • Field Details

  • Constructor Details

  • Method Details

    • getEntity

      public LivingEntity getEntity()
      Returns the entity that is dropping loot. This is generally the entity that was killed.

      To get the attacking entity, use the damage source.

      Overrides:
      getEntity in class LivingEvent
    • getDamageSource

      public DamageSource getDamageSource()
    • getEnchantment

      public Holder<Enchantment> getEnchantment()
    • getEnchantmentLevel

      public int getEnchantmentLevel()
    • setEnchantmentLevel

      public void setEnchantmentLevel(int enchantmentLevel)
      Sets the new enchantment level.
      Throws:
      IllegalArgumentException - if the enchantment level is negative.