diff --git a/src/main/java/com/pahimar/ee3/api/EnergyValueRegistryProxy.java b/src/main/java/com/pahimar/ee3/api/EnergyValueRegistryProxy.java index a61e23d1..91cb97e8 100644 --- a/src/main/java/com/pahimar/ee3/api/EnergyValueRegistryProxy.java +++ b/src/main/java/com/pahimar/ee3/api/EnergyValueRegistryProxy.java @@ -2,7 +2,6 @@ package com.pahimar.ee3.api; import com.pahimar.ee3.EquivalentExchange3; import cpw.mods.fml.common.Mod; -import net.minecraft.item.ItemStack; import java.util.List; @@ -93,20 +92,27 @@ public final class EnergyValueRegistryProxy return EE3Wrapper.ee3mod.getEnergyValueRegistry().getEnergyValue(object, strict); } - public List getStacksInRange(int start, int finish) + public List getStacksInRange(int start, int finish) { return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); } - public List getStacksInRange(float start, float finish) + public List getStacksInRange(float start, float finish) { return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); } - public List getStacksInRange(EnergyValue start, EnergyValue finish) + public List getStacksInRange(EnergyValue start, EnergyValue finish) { - // TODO Finish - return null; + init(); + + // NOOP if EquivalentExchange3 is not present + if (ee3Mod == null) + { + return null; + } + + return EE3Wrapper.ee3mod.getEnergyValueRegistry().getStacksInRange(start, finish); } private static void init() diff --git a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java index b7457c2a..ae039470 100644 --- a/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java +++ b/src/main/java/com/pahimar/ee3/exchange/EnergyValueRegistry.java @@ -7,6 +7,7 @@ import com.pahimar.ee3.recipe.RecipeRegistry; import com.pahimar.ee3.util.EnergyValueHelper; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import java.util.*; @@ -482,19 +483,19 @@ public class EnergyValueRegistry return computedStackMap; } - public List getStacksInRange(int start, int finish) + public List getStacksInRange(int start, int finish) { return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); } - public List getStacksInRange(float start, float finish) + public List getStacksInRange(float start, float finish) { return getStacksInRange(new EnergyValue(start), new EnergyValue(finish)); } - public List getStacksInRange(EnergyValue start, EnergyValue finish) + public List getStacksInRange(EnergyValue start, EnergyValue finish) { - List stacksInRange = new ArrayList(); + List stacksInRange = new ArrayList(); SortedMap> tailMap = energyValueRegistry.valueMappings.tailMap(start); SortedMap> headMap = energyValueRegistry.valueMappings.headMap(finish); @@ -520,7 +521,20 @@ public class EnergyValueRegistry { if (biggerMap.containsKey(value)) { - stacksInRange.addAll(energyValueRegistry.valueMappings.get(value)); + for (WrappedStack wrappedStack : energyValueRegistry.valueMappings.get(value)) + { + if (wrappedStack.getWrappedStack() instanceof ItemStack || wrappedStack.getWrappedStack() instanceof FluidStack) + { + stacksInRange.add(wrappedStack.getWrappedStack()); + } + else if (wrappedStack.getWrappedStack() instanceof OreStack) + { + for (ItemStack itemStack : OreDictionary.getOres(((OreStack) wrappedStack.getWrappedStack()).oreName)) + { + stacksInRange.add(itemStack); + } + } + } } } }