[Question] EnergyNet-API giving me Nullpointerexceptions

    • Official Post

    Everytime when i try to place/break my new Energygenerating Block, i get a Nullpointerexception, when it tries to add/remove itself to the E-net. I'm 100% sure that i dont give the Functions a null as parameter, the parameter implements IEnergySource, so it should be right. The Mod itself is only loading, when IC² is installed (and its installed).


    java.lang.RuntimeException: java.lang.NullPointerException
    at ic2.api.EnergyNet.addTileEntity(EnergyNet.java:38)
    ...


    java.lang.RuntimeException: java.lang.NullPointerException
    at ic2.api.EnergyNet.removeTileEntity(EnergyNet.java:52)
    ...


    Here the part of the Code inside my TileEntity


    So, what am i doing wrong?

    • Official Post

    I used the pure API, and only copied a few Lines out of the decompiled IC²-Code, to see how you made it. Strangely if i call addToEnergynet in the updateEntity-Function, it does seemingly work without NPE (i just added try catch around all the E-net-Stuff). So my Addon works now. (even if i feel, that it is a bit hacked)