diff --git a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch index 23fdf432c..6878c0d75 100644 --- a/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch +++ b/nms-patches/net/minecraft/world/inventory/ContainerEnchantTable.patch @@ -108,7 +108,7 @@ this.broadcastChanges(); }); } else { -@@ -167,9 +231,24 @@ +@@ -167,9 +231,26 @@ ItemStack itemstack2 = itemstack; List list = this.getEnchantmentList(itemstack, i, this.costs[i]); @@ -125,7 +125,9 @@ + } + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack2); + -+ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, i); ++ org.bukkit.enchantments.Enchantment hintedEnchantment = org.bukkit.enchantments.Enchantment.getByKey(CraftNamespacedKey.fromMinecraft(BuiltInRegistries.ENCHANTMENT.getKey(Enchantment.byId(enchantClue[i])))); ++ int hintedEnchantmentLevel = levelClue[i]; ++ EnchantItemEvent event = new EnchantItemEvent((Player) entityhuman.getBukkitEntity(), this.getBukkitView(), access.getLocation().getBlock(), item, this.costs[i], enchants, hintedEnchantment, hintedEnchantmentLevel, i); + world.getCraftServer().getPluginManager().callEvent(event); + + int level = event.getExpLevelCost(); @@ -135,7 +137,7 @@ if (flag) { itemstack2 = new ItemStack(Items.ENCHANTED_BOOK); -@@ -182,16 +261,29 @@ +@@ -182,16 +263,29 @@ this.enchantSlots.setItem(0, itemstack2); } @@ -172,7 +174,7 @@ if (!entityhuman.getAbilities().instabuild) { itemstack1.shrink(j); if (itemstack1.isEmpty()) { -@@ -254,6 +346,7 @@ +@@ -254,6 +348,7 @@ @Override public boolean stillValid(EntityHuman entityhuman) { @@ -180,7 +182,7 @@ return stillValid(this.access, entityhuman, Blocks.ENCHANTING_TABLE); } -@@ -304,4 +397,17 @@ +@@ -304,4 +399,17 @@ return itemstack; }