daedalus4096 / PrimalMagick

Harness the magick of the primal sources of the land.
MIT License
9 stars 11 forks source link

Missing null check in TileEntity.getCapability() casuing NPE with some other mods #241

Closed shBLOCK closed 6 months ago

shBLOCK commented 6 months ago

https://github.com/daedalus4096/PrimalMagick/blob/f7d3e52b5fe7f691eacea03052447d05d3a15504/src/main/java/com/verdantartifice/primalmagick/common/tiles/base/AbstractTileSidedInventoryPM.java#L106-L117

Here the 2nd parameter (face) is nullable, causing an NPE in the getInventoryIndexForFace() method when used with other mods.

Here's one example of the crash with the MultiStorage mod (I only kept the useful part of the log):

java.lang.NullPointerException: Cannot invoke "net.minecraft.core.Direction.ordinal()" because "face" is null
    at com.verdantartifice.primalmagick.common.tiles.devices.ResearchTableTileEntity.getInventoryIndexForFace(ResearchTableTileEntity.java:64) ~[primalmagick-4.0.9.jar%231141!/:4.0.9] {re:classloading,pl:rei_plugin_compatibilities:B}
    at com.verdantartifice.primalmagick.common.tiles.base.AbstractTileSidedInventoryPM.getCapability(AbstractTileSidedInventoryPM.java:109) ~[primalmagick-4.0.9.jar%231141!/:4.0.9] {re:classloading,pl:rei_plugin_compatibilities:B}
    at shetiphian.multistorage.common.misc.InventoryWatcher.getInventory(InventoryWatcher.java:26) ~[multistorage-forge-1.20.1-1.0.jar%231086!/:forge-1.20.1-1.0] {re:mixin,re:classloading,pl:rei_plugin_compatibilities:B}
    at shetiphian.multistorage.common.misc.InventoryWatcher.isInventory(InventoryWatcher.java:21) ~[multistorage-forge-1.20.1-1.0.jar%231086!/:forge-1.20.1-1.0] {re:mixin,re:classloading,pl:rei_plugin_compatibilities:B}
    at net.minecraft.world.level.Level.handler$djd000$multistorage_changeTracker_save(Level.java:11538) ~[server-1.20.1-20230612.114412-srg.jar%231315!/:?]