Fixed #168
This commit is contained in:
parent
1d0d7f05a1
commit
ae45fee974
2 changed files with 47 additions and 6 deletions
|
@ -1,16 +1,15 @@
|
||||||
package biomesoplenty.common.handlers;
|
package biomesoplenty.common.handlers;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import biomesoplenty.api.BOPBlockHelper;
|
import biomesoplenty.api.BOPBlockHelper;
|
||||||
import biomesoplenty.api.BOPItemHelper;
|
import biomesoplenty.api.BOPItemHelper;
|
||||||
import biomesoplenty.common.utils.ListUtils;
|
|
||||||
import cpw.mods.fml.common.IFuelHandler;
|
import cpw.mods.fml.common.IFuelHandler;
|
||||||
|
|
||||||
public class FurnaceFuelHandler implements IFuelHandler
|
public class FurnaceFuelHandler implements IFuelHandler
|
||||||
{
|
{
|
||||||
private static HashMap<ItemStack, Integer> fuelMap = new HashMap();
|
private static ArrayList<FuelValue> fuelList = new ArrayList<FuelValue>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBurnTime(ItemStack fuel)
|
public int getBurnTime(ItemStack fuel)
|
||||||
|
@ -46,11 +45,52 @@ public class FurnaceFuelHandler implements IFuelHandler
|
||||||
|
|
||||||
private static void addFuel(ItemStack stack, int value)
|
private static void addFuel(ItemStack stack, int value)
|
||||||
{
|
{
|
||||||
fuelMap.put(stack, value);
|
fuelList.add(new FuelValue(stack, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getFuelValue(ItemStack stack)
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package biomesoplenty.common.utils;
|
package biomesoplenty.common.utils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
@ -13,7 +14,7 @@ public class ListUtils
|
||||||
{
|
{
|
||||||
ItemStack stackToCompareTo = entry.getKey();
|
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;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue