Class EnchantedEntityLootEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.enchanting.EnchantedEntityLootEvent
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
is being processed.
Mods that implement similar loot conditions or functions should fire this event as well.
invalid reference
EnchantmentEffectComponent#EQUIPMENT_DROPS
If you do not need the additional context of this event, prefer GetEnchantmentLevelEvent for managing enchantment levels.
-
Nested Class Summary
Nested classes/interfaces inherited from class LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEventNested classes/interfaces inherited from class EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final @Nullable DamageSourceprivate final Holder<Enchantment> private int -
Constructor Summary
ConstructorsConstructorDescriptionEnchantedEntityLootEvent(LivingEntity entity, DamageSource damageSource, Holder<Enchantment> enchantment, int enchantmentLevel) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the entity that is dropping loot.voidsetEnchantmentLevel(int enchantmentLevel) Sets the new enchantment level.
-
Field Details
-
damageSource
-
enchantment
-
enchantmentLevel
private int enchantmentLevel
-
-
Constructor Details
-
EnchantedEntityLootEvent
@Internal public EnchantedEntityLootEvent(LivingEntity entity, DamageSource damageSource, Holder<Enchantment> enchantment, int enchantmentLevel)
-
-
Method Details
-
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:
getEntityin classLivingEvent
-
getDamageSource
-
getEnchantment
-
getEnchantmentLevel
public int getEnchantmentLevel() -
setEnchantmentLevel
public void setEnchantmentLevel(int enchantmentLevel) Sets the new enchantment level.- Throws:
IllegalArgumentException- if the enchantment level is negative.
-