for (int i = Info.CB_SLOT_CHARGING; i < Info.CB_SLOT_CHARGING + 12; i++)
{
ItemStack stack = contents[i];
if (stack != null && stack.getItem() instanceof IElectricItem && stack.stackSize == 1)
{
IElectricItem item = (IElectricItem)(stack.getItem());
if (item.getTier(stack) <= baseTier)
{
int itemTransferLimit = item.getTransferLimit(stack);
if (itemTransferLimit == 0) itemTransferLimit = baseMaxInput;
int adjustedTransferLimit = (int)Math.ceil(chargeFactor * itemTransferLimit);
int amountNeeded;
int missing;
int consumption;
if (item.getChargedItemId(stack) != item.getEmptyItemId(stack) || stack.isStackable())
{
// Running stack.copy() on every item every tick would be a horrible thing for performance, but the workaround is needed
// for ElectricItem.charge adding stackTagCompounds for charge level to EmptyItemID batteries even when run in simulate mode.
// Limiting its use by what is hopefully a broad enough test to catch all cases where it's necessary in order to avoid problems.
// Using it for any item types listed as stackable and for any items where the charged and empty item IDs differ.
final ItemStack stackCopy = stack.copy();
amountNeeded = ElectricItem.charge(stackCopy, adjustedTransferLimit, baseTier, true, true);
if (amountNeeded == adjustedTransferLimit)
{
missing = ElectricItem.charge(stackCopy, item.getMaxCharge(stackCopy), baseTier, true, true);
}
else missing = amountNeeded;
}
else
{
amountNeeded = ElectricItem.charge(stack, adjustedTransferLimit, baseTier, true, true);
if (amountNeeded == adjustedTransferLimit)
{
missing = ElectricItem.charge(stack, item.getMaxCharge(stack), baseTier, true, true);
}
else missing = amountNeeded;
}
// How long will this item take and how much will it drain?