[api request] IElectricItem.canBeCharged()

  • Needed for items that can not be charged at all, or can be charged only in a special way (crafting, inside special block(s)/machine(s) that know how to do it, etc.).


    Code
    public interface IElectricItem {
    	...
    	/**
    	 * Determine if the item can be charged.
    	 * 
    	 * @return Whether the item can be charged.
    	 */
    	boolean canBeCharged();
    	...
    }


    It should be checked at the beginning of ElectricItem.charge() and if returns false, ElectricItem.charge() should not charge the item.


    Code
    public final class ElectricItem {
    	...
    	public static int charge(ItemStack itemStack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate) {
    		...
    		if ( ((IElectricItem) itemStack.getItem()).canBeCharged() == false ) return 0;
    		...rest code...
    	}
    	...
    }


    Additional idea: SU-Battery can be rewritten in such a way to be discharged smoothly, like RE-Battery, but not be able to recharge. Empty batteries can be thrown away or placed into recycler.

  • I think that this suggstion should be taken a step further to:
    make the methods non-static and item specific, so we can change how thing charge/discharge/etc.
    of course so that newbies don't freak out when they have to specify all of these new methods, the current static methods would stay, so that they could just make it a call to th standard function


    because I find it annoying that my golden orb will technically run out of power after like 1.5 years of not putting it in your inventory (it resets it's power when in your inventory)

    • Official Post

    because I find it annoying that my golden orb will technically run out of power after like 1.5 years of not putting it in your inventory (it resets it's power when in your inventory)

    Moment? It runs out of Power? Why does it still contain the same amount of EU, even when not in Inventory? I tested that, as i have my own "Golden Orb" aka Debug-Scanner.

    • Official Post

    because of the way that ic2 discharges things, it can only reset when onUpdate() get's called instead of just ignoring the discharge call

    I know but i did the implementation like you described your Golden Orb, and the Orb is full even when its not in Playerinventory, while my Debugscanner isnt. And onUpdate() is Clientside Only!