From ca4c118994117955cc682c572c407f317a0a7530 Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Tue, 10 Dec 2013 01:50:59 -0600 Subject: [PATCH] Rework furnace result log. Fixes BUKKIT-5115 This changes the logic for furnace smelt event to consider a result of null (read: air / invalid), which will still consume an item. It also properly considers item meta in the result, instead of only checking the item data value. --- .../minecraft/server/TileEntityFurnace.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/net/minecraft/server/TileEntityFurnace.java b/src/main/java/net/minecraft/server/TileEntityFurnace.java index 8fd6407cda..945969a3b6 100644 --- a/src/main/java/net/minecraft/server/TileEntityFurnace.java +++ b/src/main/java/net/minecraft/server/TileEntityFurnace.java @@ -255,7 +255,7 @@ public class TileEntityFurnace extends TileEntity implements IWorldInventory { // CraftBukkit start CraftItemStack source = CraftItemStack.asCraftMirror(this.items[0]); - CraftItemStack result = CraftItemStack.asCraftMirror(itemstack.cloneItemStack()); + org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack); FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(this.x, this.y, this.z), source, result); this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent); @@ -264,17 +264,19 @@ public class TileEntityFurnace extends TileEntity implements IWorldInventory { return; } - itemstack = CraftItemStack.asNMSCopy(furnaceSmeltEvent.getResult()); + result = furnaceSmeltEvent.getResult(); + itemstack = CraftItemStack.asNMSCopy(result); - if (this.items[2] == null) { - this.items[2] = itemstack.cloneItemStack(); - } else if (this.items[2].getItem() == itemstack.getItem()) { - // CraftBukkit - compare damage too - if (this.items[2].getData() == itemstack.getData()) { + if (itemstack != null) { + if (this.items[2] == null) { + this.items[2] = itemstack; + } else if (CraftItemStack.asCraftMirror(this.items[2]).isSimilar(result)) { this.items[2].count += itemstack.count; + } else { + return; } - // CraftBukkit end } + // CraftBukkit end --this.items[0].count; if (this.items[0].count <= 0) {