Interface EnchantItemEvent.CalculateEnchantment
- All Superinterfaces:
Cancellable
,EnchantItemEvent
,Event
,InteractContainerEvent
- Enclosing interface:
EnchantItemEvent
Triggers when the enchantments for an item are calculated.
This happens after a new item to enchant is put in the table
and again when the item is enchanted.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spongepowered.api.event.item.inventory.EnchantItemEvent
EnchantItemEvent.CalculateEnchantment, EnchantItemEvent.CalculateLevelRequirement, EnchantItemEvent.Post
Nested classes/interfaces inherited from interface org.spongepowered.api.event.item.inventory.container.InteractContainerEvent
InteractContainerEvent.Close, InteractContainerEvent.Open
-
Method Summary
Modifier and TypeMethodDescriptionReturns the list of enchantments to apply to the item.item()
The itemstack to enchant.int
The final level requirement fromEnchantItemEvent.CalculateLevelRequirement
.Returns the original list of enchantments to apply to the item.void
setEnchantments
(List<Enchantment> enchantments) Sets the list of enchantments to apply to the item.Methods inherited from interface org.spongepowered.api.event.Cancellable
isCancelled, setCancelled
Methods inherited from interface org.spongepowered.api.event.item.inventory.EnchantItemEvent
option, seed
Methods inherited from interface org.spongepowered.api.event.item.inventory.container.InteractContainerEvent
container, cursorTransaction
-
Method Details
-
item
ItemStackSnapshot item()The itemstack to enchant.- Returns:
- the itemstack to enchant.
-
levelRequirement
int levelRequirement()The final level requirement fromEnchantItemEvent.CalculateLevelRequirement
.In vanilla the maximum value is 30.
- Returns:
- the level requirement for the option
-
originalEnchantments
List<Enchantment> originalEnchantments()Returns the original list of enchantments to apply to the item.The first item in the list is used for display when previewing the enchantments.
- Returns:
- the list of enchantments
-
enchantments
List<Enchantment> enchantments()Returns the list of enchantments to apply to the item.The first item in the list is used for display when previewing the enchantments.
- Returns:
- the list of enchantments
-
setEnchantments
Sets the list of enchantments to apply to the item.The first item in the list is used for display when previewing the enchantments.
Note that when modifying the enchantment list you should return the same enchantments for the same seed and option.
See
Enchantment.randomListBuilder()
to generate enchantment lists.- Parameters:
enchantments
- the new list of enchantments
-