terrarium-earth / Common-Storage-Lib

A Cross platform library for transferring and storing fluids, items and energy
MIT License
29 stars 4 forks source link

Fixed a possible nullptr exception caused by getEnergyContainer returning null on a block that is an energy container. #26

Closed nullTheCoder closed 1 year ago

nullTheCoder commented 1 year ago

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:

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.