From ae45fee974352b96e9d764c6da2dd8978969f332 Mon Sep 17 00:00:00 2001 From: Adubbz Date: Wed, 15 Jan 2014 09:32:57 +1100 Subject: [PATCH] Fixed #168 --- .../common/handlers/FurnaceFuelHandler.java | 50 +++++++++++++++++-- .../biomesoplenty/common/utils/ListUtils.java | 3 +- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/src/main/java/biomesoplenty/common/handlers/FurnaceFuelHandler.java b/src/main/java/biomesoplenty/common/handlers/FurnaceFuelHandler.java index 4b32ba1ea..e173712e5 100644 --- a/src/main/java/biomesoplenty/common/handlers/FurnaceFuelHandler.java +++ b/src/main/java/biomesoplenty/common/handlers/FurnaceFuelHandler.java @@ -1,16 +1,15 @@ package biomesoplenty.common.handlers; -import java.util.HashMap; +import java.util.ArrayList; import net.minecraft.item.ItemStack; import biomesoplenty.api.BOPBlockHelper; import biomesoplenty.api.BOPItemHelper; -import biomesoplenty.common.utils.ListUtils; import cpw.mods.fml.common.IFuelHandler; public class FurnaceFuelHandler implements IFuelHandler { - private static HashMap fuelMap = new HashMap(); + private static ArrayList fuelList = new ArrayList(); @Override public int getBurnTime(ItemStack fuel) @@ -46,11 +45,52 @@ public class FurnaceFuelHandler implements IFuelHandler private static void addFuel(ItemStack stack, int value) { - fuelMap.put(stack, value); + fuelList.add(new FuelValue(stack, value)); } private static int getFuelValue(ItemStack stack) { - return ListUtils.getItemStackMapValue(fuelMap, stack); + for (FuelValue fuelValue : fuelList) + { + ItemStack stackToCompareTo = fuelValue.getStack(); + + if (stackToCompareTo.getItem() == stack.getItem() && (stack.getItemDamage() == 32767 || stackToCompareTo.getItemDamage() == stack.getItemDamage())) return fuelValue.getValue(); + + return fuelValue.getValue(); + } + + return 0; + } + + public static class FuelValue + { + private ItemStack stack; + private int value; + + public FuelValue(ItemStack stack, int value) + { + this.setStack(stack); + this.setValue(value); + } + + public ItemStack getStack() + { + return stack; + } + + public void setStack(ItemStack stack) + { + this.stack = stack; + } + + public int getValue() + { + return value; + } + + public void setValue(int value) + { + this.value = value; + } } } diff --git a/src/main/java/biomesoplenty/common/utils/ListUtils.java b/src/main/java/biomesoplenty/common/utils/ListUtils.java index 65443fdfe..7771b4f04 100644 --- a/src/main/java/biomesoplenty/common/utils/ListUtils.java +++ b/src/main/java/biomesoplenty/common/utils/ListUtils.java @@ -1,5 +1,6 @@ package biomesoplenty.common.utils; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map.Entry; @@ -13,7 +14,7 @@ public class ListUtils { ItemStack stackToCompareTo = entry.getKey(); - if (stackToCompareTo.getItem() == stack.getItem() && stackToCompareTo.getItemDamage() == stack.getItemDamage()) return entry.getValue(); + if (stackToCompareTo.getItem() == stack.getItem() && (stack.getItemDamage() == 32767 || stackToCompareTo.getItemDamage() == stack.getItemDamage())) return entry.getValue(); } return null;