A few charging fixes

This commit is contained in:
Aidan Brady 2013-12-12 19:46:23 -05:00
parent 9ecb7c20fd
commit 11aa04a5df
4 changed files with 11 additions and 3 deletions

View file

@ -68,7 +68,7 @@ public class ContainerEnergyCube extends Container
ItemStack slotStack = currentSlot.getStack();
stack = slotStack.copy();
if(slotStack.getItem() instanceof IElectricItem || slotStack.getItem() instanceof IItemElectric || slotStack.itemID == Item.redstone.itemID)
if(ChargeUtils.canBeCharged(slotStack) || ChargeUtils.canBeDischarged(slotStack))
{
if(slotStack.itemID == Item.redstone.itemID)
{

View file

@ -141,4 +141,10 @@ public class ItemAtomicDisassembler extends ItemEnergized
return 0;
}
@Override
public boolean canSend(ItemStack itemStack)
{
return false;
}
}

View file

@ -152,13 +152,13 @@ public class ItemEnergized extends ItemMekanism implements IEnergizedItem, IItem
@Override
public boolean canReceive(ItemStack itemStack)
{
return true;
return getMaxEnergy(itemStack)-getEnergy(itemStack) > 0;
}
@Override
public boolean canSend(ItemStack itemStack)
{
return true;
return getEnergy(itemStack) > 0;
}
@Override

View file

@ -107,6 +107,7 @@ public final class ChargeUtils
public static boolean canBeDischarged(ItemStack itemstack)
{
return (itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) ||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) ||
(itemstack.getItem() instanceof IItemElectric && ((IItemElectric)itemstack.getItem()).discharge(itemstack, 1, false) != 0) ||
(itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) ||
itemstack.itemID == Item.redstone.itemID;
@ -120,6 +121,7 @@ public final class ChargeUtils
public static boolean canBeCharged(ItemStack itemstack)
{
return itemstack.getItem() instanceof IElectricItem ||
(itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canReceive(itemstack)) ||
(itemstack.getItem() instanceof IItemElectric && ((IItemElectric)itemstack.getItem()).recharge(itemstack, 1, false) != 0) ||
(itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0);
}