From d69ddc3163257c4412d23018072cd4ed7a77a303 Mon Sep 17 00:00:00 2001 From: drXor Date: Sat, 15 Mar 2014 02:28:55 -0400 Subject: [PATCH] Allow enchanting tables to enchant any item when plugins prompt them to. --- ...nchanting-tables-to-enchant-any-item.patch | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 CraftBukkit-Patches/0120-Allow-enchanting-tables-to-enchant-any-item.patch diff --git a/CraftBukkit-Patches/0120-Allow-enchanting-tables-to-enchant-any-item.patch b/CraftBukkit-Patches/0120-Allow-enchanting-tables-to-enchant-any-item.patch new file mode 100644 index 0000000000..80540a095c --- /dev/null +++ b/CraftBukkit-Patches/0120-Allow-enchanting-tables-to-enchant-any-item.patch @@ -0,0 +1,34 @@ +From 718db1e4e0a70ff25b8c38305fb79afd0707233e Mon Sep 17 00:00:00 2001 +From: andrepl +Date: Sat, 15 Mar 2014 12:50:00 -0400 +Subject: [PATCH] Allow enchanting tables to enchant any item + + +diff --git a/src/main/java/net/minecraft/server/ContainerEnchantTable.java b/src/main/java/net/minecraft/server/ContainerEnchantTable.java +index cc36e2b..7c0d998 100644 +--- a/src/main/java/net/minecraft/server/ContainerEnchantTable.java ++++ b/src/main/java/net/minecraft/server/ContainerEnchantTable.java +@@ -152,6 +152,11 @@ public class ContainerEnchantTable extends Container { + if (this.costs[i] > 0 && itemstack != null && (entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) { + if (!this.world.isStatic) { + List list = EnchantmentManager.b(this.l, itemstack, this.costs[i]); ++ // Spigot - Provide an empty enchantment list ++ if (list == null) { ++ list = new java.util.ArrayList(); ++ } ++ // Spigot End + boolean flag = itemstack.getItem() == Items.BOOK; + + if (list != null) { +@@ -186,7 +191,7 @@ public class ContainerEnchantTable extends Container { + EnchantmentInstance enchantment = new EnchantmentInstance(enchantId, entry.getValue()); + Items.ENCHANTED_BOOK.a(itemstack, enchantment); + } else { +- item.addEnchantment(entry.getKey(), entry.getValue()); ++ item.addUnsafeEnchantment(entry.getKey(), entry.getValue()); // Spigot addEnchantment -> addUnsafeEnchantment + } + } catch (IllegalArgumentException e) { + /* Just swallow invalid enchantments */ +-- +1.8.3.2 +