i found that adding a overflow buffer, then refilling the internal buffer from that eliminate that problem.
When the overflow buffer is empty you request more power
Code
public void onUpdate() {
if (overflow > 0) {
if (_buffered < _bufferSize) {
int res = (int) (_bufferSize - _buffered);
if (res < overflow) {
_buffered += res;
overflow -= res;
} else {
res = (int) overflow;
overflow = 0;
_buffered += res;
}
}
}
}
@Override
public double demandedEnergyUnits() {
if (overflow > 0)
return 0;
else
return _bufferSize - _buffered;
}
@Override
public double injectEnergyUnits(ForgeDirection directionFrom, double amount) {
int res = 0;
_buffered += amount;
if (_buffered > _bufferSize) {
res = (int) (_buffered - _bufferSize);
_buffered = _bufferSize;
overflow += res;
return 0;
}
return res;
}
Display More
I know this is a old post, but it may help others that have the same issue, delete it if unwanted