Class EnchantmentLevelSetEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.enchanting.EnchantmentLevelSetEvent

public class EnchantmentLevelSetEvent extends net.neoforged.bus.api.Event
Fired when the enchantment level is set for each of the three potential enchantments in the enchanting table. The level is set to the vanilla value and can be modified by this event handler. The enchantRow is used to determine which enchantment level is being set, 1, 2, or 3. The power is a number from 0-15 and indicates how many bookshelves surround the enchanting table. The itemStack representing the item being enchanted is also available.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private final int
     
    private final net.minecraft.world.item.ItemStack
     
    private final net.minecraft.world.level.Level
     
    private final int
     
    private final net.minecraft.core.BlockPos
     
    private final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EnchantmentLevelSetEvent(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int enchantRow, int power, net.minecraft.world.item.ItemStack itemStack, int enchantLevel)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get the level of the enchantment for this row (0-30)
    int
    Get the row for which the enchantment level is being set
    net.minecraft.world.item.ItemStack
    Get the item being enchanted
    net.minecraft.world.level.Level
    Get the world object
    int
    Get the original level of the enchantment for this row (0-30)
    net.minecraft.core.BlockPos
    Get the pos of the enchantment table
    int
    Get the power (# of bookshelves) for the enchanting table
    void
    setEnchantLevel(int level)
    Set the new level of the enchantment (0-30)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • level

      private final net.minecraft.world.level.Level level
    • pos

      private final net.minecraft.core.BlockPos pos
    • enchantRow

      private final int enchantRow
    • power

      private final int power
    • itemStack

      private final net.minecraft.world.item.ItemStack itemStack
    • originalLevel

      private final int originalLevel
    • enchantLevel

      private int enchantLevel
  • Constructor Details

    • EnchantmentLevelSetEvent

      public EnchantmentLevelSetEvent(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, int enchantRow, int power, net.minecraft.world.item.ItemStack itemStack, int enchantLevel)
  • Method Details

    • getLevel

      public net.minecraft.world.level.Level getLevel()
      Get the world object
      Returns:
      the world object
    • getPos

      public net.minecraft.core.BlockPos getPos()
      Get the pos of the enchantment table
      Returns:
      the pos of the enchantment table
    • getEnchantRow

      public int getEnchantRow()
      Get the row for which the enchantment level is being set
      Returns:
      the row for which the enchantment level is being set
    • getPower

      public int getPower()
      Get the power (# of bookshelves) for the enchanting table
      Returns:
      the power (# of bookshelves) for the enchanting table
    • getItem

      public net.minecraft.world.item.ItemStack getItem()
      Get the item being enchanted
      Returns:
      the item being enchanted
    • getOriginalLevel

      public int getOriginalLevel()
      Get the original level of the enchantment for this row (0-30)
      Returns:
      the original level of the enchantment for this row (0-30)
    • getEnchantLevel

      public int getEnchantLevel()
      Get the level of the enchantment for this row (0-30)
      Returns:
      the level of the enchantment for this row (0-30)
    • setEnchantLevel

      public void setEnchantLevel(int level)
      Set the new level of the enchantment (0-30)
      Parameters:
      level - the new level of the enchantment (0-30)