if(item.isDead)
continue;
ItemStack stack = item.getEntityItem();
if(stack != null && stack.getItem() instanceof IManaItem) {
IManaItem mana = (IManaItem) stack.getItem();
if(outputting && mana.canReceiveManaFromPool(stack, this) || !outputting && mana.canExportManaToPool(stack, this)) {
boolean didSomething = false;
if(outputting) {
if(canSpare) {
if(getCurrentMana() > 0 && mana.getMana(stack) < mana.getMaxMana(stack))
didSomething = true;
int manaVal = Math.min(1000, Math.min(getCurrentMana(), mana.getMaxMana(stack) - mana.getMana(stack)));
if(!worldObj.isRemote)
mana.addMana(stack, manaVal);
recieveMana(-manaVal);
}
} else {
if(canAccept) {
if(mana.getMana(stack) > 0 && !isFull())
didSomething = true;
int manaVal = Math.min(1000, Math.min(manaCap - getCurrentMana(), mana.getMana(stack)));
if(!worldObj.isRemote)
mana.addMana(stack, -manaVal);
recieveMana(manaVal);
}
}
if(didSomething) {