This commit is contained in:
pahimar 2015-03-23 07:36:32 -04:00
parent a9bf0e6bea
commit 90e89673d3

View file

@ -530,41 +530,44 @@ public class EnergyValueRegistry implements INBTTaggable, JsonSerializer<EnergyV
{ {
List stacksInRange = new ArrayList<WrappedStack>(); List stacksInRange = new ArrayList<WrappedStack>();
SortedMap<EnergyValue, List<WrappedStack>> tailMap = energyValueRegistry.valueMappings.tailMap(start); if (valueMappings != null)
SortedMap<EnergyValue, List<WrappedStack>> headMap = energyValueRegistry.valueMappings.headMap(finish);
SortedMap<EnergyValue, List<WrappedStack>> smallerMap;
SortedMap<EnergyValue, List<WrappedStack>> biggerMap;
if (!tailMap.isEmpty() && !headMap.isEmpty())
{ {
SortedMap<EnergyValue, List<WrappedStack>> tailMap = energyValueRegistry.valueMappings.tailMap(start);
SortedMap<EnergyValue, List<WrappedStack>> headMap = energyValueRegistry.valueMappings.headMap(finish);
if (tailMap.size() <= headMap.size()) SortedMap<EnergyValue, List<WrappedStack>> smallerMap;
{ SortedMap<EnergyValue, List<WrappedStack>> biggerMap;
smallerMap = tailMap;
biggerMap = headMap;
}
else
{
smallerMap = headMap;
biggerMap = tailMap;
}
for (EnergyValue value : smallerMap.keySet()) if (!tailMap.isEmpty() && !headMap.isEmpty())
{ {
if (biggerMap.containsKey(value))
if (tailMap.size() <= headMap.size())
{ {
for (WrappedStack wrappedStack : energyValueRegistry.valueMappings.get(value)) smallerMap = tailMap;
biggerMap = headMap;
}
else
{
smallerMap = headMap;
biggerMap = tailMap;
}
for (EnergyValue value : smallerMap.keySet())
{
if (biggerMap.containsKey(value))
{ {
if (wrappedStack.getWrappedStack() instanceof ItemStack || wrappedStack.getWrappedStack() instanceof FluidStack) for (WrappedStack wrappedStack : energyValueRegistry.valueMappings.get(value))
{ {
stacksInRange.add(wrappedStack.getWrappedStack()); if (wrappedStack.getWrappedStack() instanceof ItemStack || wrappedStack.getWrappedStack() instanceof FluidStack)
}
else if (wrappedStack.getWrappedStack() instanceof OreStack)
{
for (ItemStack itemStack : OreDictionary.getOres(((OreStack) wrappedStack.getWrappedStack()).oreName))
{ {
stacksInRange.add(itemStack); stacksInRange.add(wrappedStack.getWrappedStack());
}
else if (wrappedStack.getWrappedStack() instanceof OreStack)
{
for (ItemStack itemStack : OreDictionary.getOres(((OreStack) wrappedStack.getWrappedStack()).oreName))
{
stacksInRange.add(itemStack);
}
} }
} }
} }