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
Code
public boolean mAddedToEnergyNet = false;
// Called by Blockplacement
public void onCreated() {
addToEnergyNet();
}
// Called by Blockremoval
public void onRemoval() {
removeFromEnergyNet();
}
private boolean addToEnergyNet() {
if (!worldObj.isRemote) {
EnergyNet tEnergyNet = EnergyNet.getForWorld(worldObj);
if (tEnergyNet != null) {
tEnergyNet.addTileEntity(this);
mAddedToEnergyNet = true;
}
}
return mAddedToEnergyNet;
}
private boolean removeFromEnergyNet() {
if (!worldObj.isRemote) {
EnergyNet tEnergyNet = EnergyNet.getForWorld(worldObj);
if (tEnergyNet != null) {
tEnergyNet.removeTileEntity(this);
mAddedToEnergyNet = true;
}
}
return !mAddedToEnergyNet;
}
Display More
So, what am i doing wrong?