In 1.4.6, IEnergySink.demandsEnergy now returns an int instead of a boolean.
The javadoc only says "Determine how much energy the sink accepts. This value is unrelated to getMaxSafeInput(). Returns: max accepted input in eu"
How does IC2 use this number?
[API question] demandsEnergy changes
-
-
EnergyNet.java says it's being used much like the previous version:
Personally, I'm using it, and its friend injectEnergy, like so (from BeamMeUp source
Code
Display Morepublic int demandsEnergy() { return ENERGY_CAPACITY - energyStored; } public int injectEnergy(Direction directionFrom, int amount) { if(amount > MAX_ACCEPTED_EU) { // IC2 machines explode here, but we're still in alpha testing, so just pop off dropItem(CommonProxy.interdictorStack.copy()); worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord, zCoord, 0, 0); } energyStored += amount; return 0; }
It does mean I tend to end up with slightly more than ENERGY_CAPACITY EUs stored in the machine, but that really doesn't get in the way much, if at all.
-
ever vanilla IC2 implement it's own API not as expected, relax and standby for update\fix.
-
I'm using something like this:
Code
Display Morepublic int demandsEnergy() { return maxEnergy - energy - maxInput; } public int injectEnergy(Direction from, int amount) { //insert conversion algorithm here :P return leftover }
Note that my conversion algorithm uses maxEnergy in such a way that I don't ever have more energy than maxEnergy (so the input is consistent). -
This value is unrelated to getMaxSafeInput(). Returns: max accepted input in eu"
How does IC2 use this number?Probably not at all. I use that API-Hook to remove an "else"-Case from the Tooltip of my Machines.