Class EnchantedBlockLootEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.level.BlockEvent
net.neoforged.neoforge.event.enchanting.EnchantedBlockLootEvent
Fired on the server when a block's loot table queries the level of an enchantment to determine what the block will drop.
Notably, this fires when ApplyBonusCount or BonusLevelTableCondition check the level of an enchantment in-context.
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class BlockEvent
BlockEvent.BlockToolModificationEvent, BlockEvent.EntityMultiPlaceEvent, BlockEvent.EntityPlaceEvent, BlockEvent.FarmlandTrampleEvent, BlockEvent.FluidPlaceBlockEvent, BlockEvent.NeighborNotifyEvent, BlockEvent.PortalSpawnEvent -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Holder<Enchantment> private intprivate final ItemInstance -
Constructor Summary
ConstructorsConstructorDescriptionEnchantedBlockLootEvent(ServerLevel level, BlockPos pos, BlockState state, ItemInstance tool, Holder<Enchantment> enchantment, int enchantmentLevel) -
Method Summary
Modifier and TypeMethodDescriptionintgetTool()Returns the tool used to break the block, fromLootContextParams.TOOL.voidsetEnchantmentLevel(int enchantmentLevel) Sets the new enchantment level.Methods inherited from class BlockEvent
getLevel, getPos, getState
-
Field Details
-
tool
-
enchantment
-
enchantmentLevel
private int enchantmentLevel
-
-
Constructor Details
-
EnchantedBlockLootEvent
@Internal public EnchantedBlockLootEvent(ServerLevel level, BlockPos pos, BlockState state, ItemInstance tool, Holder<Enchantment> enchantment, int enchantmentLevel)
-
-
Method Details
-
getTool
Returns the tool used to break the block, fromLootContextParams.TOOL.- Returns:
- the tool used to break the block, from
LootContextParams.TOOL
-
getEnchantment
-
getEnchantmentLevel
public int getEnchantmentLevel() -
setEnchantmentLevel
public void setEnchantmentLevel(int enchantmentLevel) Sets the new enchantment level.- Throws:
IllegalArgumentException- if the enchantment level is negative.
-