From 056af8b9c2ea790721ce19e05e90be7731fa69c1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 27 Dec 2016 11:53:09 +1100 Subject: [PATCH] SPIGOT-2964: Correct number of shelve sin PrepareEnchantEvent --- nms-patches/ContainerEnchantTable.patch | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/nms-patches/ContainerEnchantTable.patch b/nms-patches/ContainerEnchantTable.patch index 8072aa1c2d..e95eade472 100644 --- a/nms-patches/ContainerEnchantTable.patch +++ b/nms-patches/ContainerEnchantTable.patch @@ -71,9 +71,9 @@ + // CraftBukkit start + CraftItemStack item = CraftItemStack.asCraftMirror(itemstack); + org.bukkit.enchantments.EnchantmentOffer[] offers = new EnchantmentOffer[3]; -+ for (i = 0; i < 3; ++i) { -+ org.bukkit.enchantments.Enchantment enchantment = (this.h[i] >= 0) ? org.bukkit.enchantments.Enchantment.getById(this.h[i]) : null; -+ offers[i] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[i], this.costs[i]) : null; ++ for (j = 0; j < 3; ++j) { ++ org.bukkit.enchantments.Enchantment enchantment = (this.h[j] >= 0) ? org.bukkit.enchantments.Enchantment.getById(this.h[j]) : null; ++ offers[j] = (enchantment != null) ? new EnchantmentOffer(enchantment, this.i[j], this.costs[j]) : null; + } + + PrepareItemEnchantEvent event = new PrepareItemEnchantEvent(player, this.getBukkitView(), this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), item, offers, i); @@ -81,24 +81,24 @@ + this.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ for (i = 0; i < 3; ++i) { -+ this.costs[i] = 0; -+ this.h[i] = -1; -+ this.i[i] = -1; ++ for (j = 0; j < 3; ++j) { ++ this.costs[j] = 0; ++ this.h[j] = -1; ++ this.i[j] = -1; + } + return; + } + -+ for (i = 0; i < 3; i++) { -+ EnchantmentOffer offer = event.getOffers()[i]; ++ for (j = 0; j < 3; j++) { ++ EnchantmentOffer offer = event.getOffers()[j]; + if (offer != null) { -+ this.costs[i] = offer.getCost(); -+ this.h[i] = offer.getEnchantment().getId(); -+ this.i[i] = offer.getEnchantmentLevel(); ++ this.costs[j] = offer.getCost(); ++ this.h[j] = offer.getEnchantment().getId(); ++ this.i[j] = offer.getEnchantmentLevel(); + } else { -+ this.costs[i] = 0; -+ this.h[i] = -1; -+ this.i[i] = -1; ++ this.costs[j] = 0; ++ this.h[j] = -1; ++ this.i[j] = -1; + } + } + // CraftBukkit end