{
float computedValue = 0f;
for (WrappedStack wrappedStack : wrappedStacks)
{
EnergyValue wrappedStackValue;
int stackSize = -1;
if (wrappedStack.getWrappedStack() instanceof ItemStack)
{
ItemStack itemStack = (ItemStack) wrappedStack.getWrappedStack();
// Check if we are dealing with a potential fluid
if (FluidContainerRegistry.getFluidForFilledItem(itemStack) != null)
{
if (itemStack.getItem().getContainerItem(itemStack) != null)
{
stackSize = FluidContainerRegistry.getFluidForFilledItem(itemStack).amount;
wrappedStackValue = EnergyValueRegistry.getInstance().getEnergyValue(FluidContainerRegistry.getFluidForFilledItem(itemStack));
}
else
{
wrappedStackValue = EnergyValueRegistry.getInstance().getEnergyValue(wrappedStack);
}
}
// If we are dealing with a "tool" (container item), assume it's value is 0 (since it won't be used up in the recipe)
else if (itemStack.getItem() != null && itemStack.getItem().getContainerItem(itemStack) != null)
{
wrappedStackValue = new EnergyValue(0);
}
else
{
wrappedStackValue = EnergyValueRegistry.getInstance().getEnergyValue(wrappedStack);
}
}
else
{
wrappedStackValue = EnergyValueRegistry.getInstance().getEnergyValue(wrappedStack);
}
if (wrappedStackValue != null)
{
if (stackSize == -1)
{
stackSize = wrappedStack.getStackSize();
}
computedValue += wrappedStackValue.getEnergyValue() * stackSize;
}
else
{
return null;
}
}
return new EnergyValue(computedValue);
}