summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-12-13 08:44:50 +1100
committermd_5 <git@md-5.net>2016-12-13 08:44:50 +1100
commitc6d6844254193bfc92822816e79120d97b95ff97 (patch)
tree79d11cd3c469fd41ff13516496ce7136ce5fe43f /nms-patches
parent4f479728ee68a15a6d2df78fce8cf9e514e43b65 (diff)
downloadcraftbukkit-c6d6844254193bfc92822816e79120d97b95ff97.tar
craftbukkit-c6d6844254193bfc92822816e79120d97b95ff97.tar.gz
craftbukkit-c6d6844254193bfc92822816e79120d97b95ff97.tar.lz
craftbukkit-c6d6844254193bfc92822816e79120d97b95ff97.tar.xz
craftbukkit-c6d6844254193bfc92822816e79120d97b95ff97.zip
SPIGOT-2913: Only one enchantment applied to items
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/ContainerEnchantTable.patch29
1 files changed, 8 insertions, 21 deletions
diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch
index 95f4e2a7..71e79dd7 100644
--- a/nms-patches/ContainerEnchantTable.patch
+++ b/nms-patches/ContainerEnchantTable.patch
@@ -106,26 +106,13 @@
this.b();
}
} else {
-@@ -174,27 +236,59 @@
- return false;
- } else if (this.costs[i] > 0 && !itemstack.isEmpty() && (entityhuman.expLevel >= j && entityhuman.expLevel >= this.costs[i] || entityhuman.abilities.canInstantlyBuild)) {
- if (!this.world.isClientSide) {
-- List list = this.a(itemstack, i, this.costs[i]);
-+ // CraftBukkit start - Use the data generated by the PostPrepareItemEnchantEvent
-+ List list;
-+ if (this.h[i] < 0) {
-+ list = this.a(itemstack, i, this.costs[i]);
-+ } else {
-+ list = Collections.singletonList(new WeightedRandomEnchant(Enchantment.c(this.h[i]), this.i[i]));
-+ }
-+ // CraftBukkit end
-+ boolean flag = itemstack.getItem() == Items.BOOK;
-
-- if (!list.isEmpty()) {
+@@ -177,24 +239,49 @@
+ List list = this.a(itemstack, i, this.costs[i]);
+
+ if (!list.isEmpty()) {
- entityhuman.enchantDone(j);
-- boolean flag = itemstack.getItem() == Items.BOOK;
-+ if (list != null) {
+ // CraftBukkit start
+ boolean flag = itemstack.getItem() == Items.BOOK;
+ Map<org.bukkit.enchantments.Enchantment, Integer> enchants = new java.util.HashMap<org.bukkit.enchantments.Enchantment, Integer>();
+ for (Object obj : list) {
+ WeightedRandomEnchant instance = (WeightedRandomEnchant) obj;
@@ -176,7 +163,7 @@
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1.subtract(j);
if (itemstack1.isEmpty()) {
-@@ -229,6 +323,11 @@
+@@ -229,6 +316,11 @@
public void b(EntityHuman entityhuman) {
super.b(entityhuman);
@@ -188,7 +175,7 @@
if (!this.world.isClientSide) {
for (int i = 0; i < this.enchantSlots.getSize(); ++i) {
ItemStack itemstack = this.enchantSlots.splitWithoutUpdate(i);
-@@ -242,6 +341,7 @@
+@@ -242,6 +334,7 @@
}
public boolean a(EntityHuman entityhuman) {
@@ -196,7 +183,7 @@
return this.world.getType(this.position).getBlock() != Blocks.ENCHANTING_TABLE ? false : entityhuman.d((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
-@@ -294,4 +394,17 @@
+@@ -294,4 +387,17 @@
return itemstack;
}