Interface EnchantItemEvent.CalculateEnchantment
-
- All Superinterfaces:
Cancellable
,EnchantItemEvent
,Event
,InteractContainerEvent
- Enclosing interface:
- EnchantItemEvent
public static interface EnchantItemEvent.CalculateEnchantment extends 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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.List<Enchantment>
enchantments()
Returns the list of enchantments to apply to the item.ItemStackSnapshot
item()
The itemstack to enchant.int
levelRequirement()
The final level requirement fromEnchantItemEvent.CalculateLevelRequirement
.java.util.List<Enchantment>
originalEnchantments()
Returns the original list of enchantments to apply to the item.void
setEnchantments(java.util.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 Detail
-
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
java.util.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
java.util.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
void setEnchantments(java.util.List<Enchantment> enchantments)
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
-
-