From 11aa04a5df19d6cd112367cd57b4afb63bf9d714 Mon Sep 17 00:00:00 2001 From: Aidan Brady Date: Thu, 12 Dec 2013 19:46:23 -0500 Subject: [PATCH] A few charging fixes --- .../common/inventory/container/ContainerEnergyCube.java | 2 +- common/mekanism/common/item/ItemAtomicDisassembler.java | 6 ++++++ common/mekanism/common/item/ItemEnergized.java | 4 ++-- common/mekanism/common/util/ChargeUtils.java | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/mekanism/common/inventory/container/ContainerEnergyCube.java b/common/mekanism/common/inventory/container/ContainerEnergyCube.java index 4288bdde1..a8d3efc07 100644 --- a/common/mekanism/common/inventory/container/ContainerEnergyCube.java +++ b/common/mekanism/common/inventory/container/ContainerEnergyCube.java @@ -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) { diff --git a/common/mekanism/common/item/ItemAtomicDisassembler.java b/common/mekanism/common/item/ItemAtomicDisassembler.java index 45c3f4e93..24306df13 100644 --- a/common/mekanism/common/item/ItemAtomicDisassembler.java +++ b/common/mekanism/common/item/ItemAtomicDisassembler.java @@ -141,4 +141,10 @@ public class ItemAtomicDisassembler extends ItemEnergized return 0; } + + @Override + public boolean canSend(ItemStack itemStack) + { + return false; + } } diff --git a/common/mekanism/common/item/ItemEnergized.java b/common/mekanism/common/item/ItemEnergized.java index 8a9ee25f1..f45607463 100644 --- a/common/mekanism/common/item/ItemEnergized.java +++ b/common/mekanism/common/item/ItemEnergized.java @@ -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 diff --git a/common/mekanism/common/util/ChargeUtils.java b/common/mekanism/common/util/ChargeUtils.java index f63fac820..25a3c76b6 100644 --- a/common/mekanism/common/util/ChargeUtils.java +++ b/common/mekanism/common/util/ChargeUtils.java @@ -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); }