EnergySource - Firing EnergyTileLoadEvent too early?

  • Hey,


    I'm trying to create an energy source and seem to be doing something wrong.


    My energy source works perfectly fine if I place some consumer (like a BatBox) before placing my block, doing it the other way around does simply nothing. Placing some cables and a consumer at the end is the same as placing the cusomer directly next to my block, it works when placing the consumer first (and having the cable where my block will be) but not the other way around.


    Code from my base class with some comments: Pastebin


    My guess would be that I fire EnergyTileLoadEvent too early but I when I added some code that would fire this event 100 ticks later than it does right now, it didn't help.


    Edit:
    Just tested again. When placing a my block next to a consumer this consumer starts getting energy, if I place a new consumer next to my block, while the old one still recharges, it also works. Placing new consumers once all currenct consumers are fully charged does nothing.


    Example:
    I place a compressor and next to it my block, the compressor starts charging. If I add another compressor while the first one is charging, the other compressor also charges. If I place a third compressor once the other two are fully charged, the third compressor gets nothing.



    I'm publishing the EnergySourceTileEvent regardless of connected consumers / energy usage, should I keep track of connected IEnergyAcceptors and only emit energy if at least one of them is an IEnergySink where demandsEnergy > 0?

  • Thread can be closed, I'm stupid.


    My last test made me check when I'm calling distribute which only happens when the demand is > 0 which only happens if _buffered < _bufferSize -> Once the buffer is full, the source won't ever send again.


    Sorry.