Hello there, I currently have implemented a TileEntity that can be optionally powered by EU. But I have a few questions:
Since sources always transfer 1 packet of their maxvoltage, do I really need to only return needed power when i need more than networkVoltage in EU?
And currently I post the energy tile load event in invalidate/validate, but i get: TileEntityXXX was added too early, postponing.
What would be the better way to solve this?
IC2 API Energy sink
-
-
Hello there, I currently have implemented a TileEntity that can be optionally powered by EU. But I have a few questions:
Since sources always transfer 1 packet of their maxvoltage, do I really need to only return needed power when i need more than networkVoltage in EU?
You don't need to return needed power at all. You need to return power, that you don't need. Also EU/t != voltage.Code
Display Morepublic double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { if (this.energy >= (double)this.maxStorage) { return amount; } else { this.energy += amount; return 0.0D; } }
If you mean, that you want your machine to work only from certain voltage level, just add "|| voltage<minVoltage" to "if" condition, so it would be looking like this:Code
Display Morepublic double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { if (this.energy >= (double)this.maxStorage || voltage<minVoltage) { return amount; } else { this.energy += amount; return 0.0D; } }
And currently I post the energy tile load event in invalidate/validate, but i get: TileEntityXXX was added too early, postponing.
What would be the better way to solve this?
Write your overrided invalidate/validate method in this thread here. May be you called "super" validation function after posting event, or even forgot to call it?