Made a null check after get block energy container instead of checking for block to be an energy container in distributeEnergyNearby.
Problem caused by there being no null check after getting energy: In a mod of mine, when a create: crafts and additions (forge 1.20.1) accumulator is placed adjacent to its generator block, it would crash the game java.lang.NullPointerException: Cannot invoke "earth.terrarium.botarium.common.energy.base.EnergyContainer.insertEnergy(long, boolean)" because "energy" is null, there is a possibility that a similar crash could happen with other mods.
Tested:
Forge: Nothing appears to be broken and the above issue has been fixed.
Fabric: No testing done, however there shouldn't be any issues.
Changes in the commit:
replaced checking if a block is an energy block with checking with instead checking if energyContainer is null after it.
Some import changes by Intellij IDEA
Possible issues that could be caused:
none, in both forge and fabric energy container getting function first checks if that block is an energy container.
Made a null check after get block energy container instead of checking for block to be an energy container in distributeEnergyNearby.
Problem caused by there being no null check after getting energy: In a mod of mine, when a create: crafts and additions (forge 1.20.1) accumulator is placed adjacent to its generator block, it would crash the game
java.lang.NullPointerException: Cannot invoke "earth.terrarium.botarium.common.energy.base.EnergyContainer.insertEnergy(long, boolean)" because "energy" is null
, there is a possibility that a similar crash could happen with other mods.Tested:
Changes in the commit:
Possible issues that could be caused: