Delfayne / ThaumicEnergistics

A bridge between Thaumcraft and Applied Energistics.
MIT License
8 stars 10 forks source link

Essentia Import bus crash (Ticking GridNode) #28

Closed Nivid-IT closed 6 months ago

Nivid-IT commented 6 months ago

Describe the bug Connecting an ME Essentia Import Bus to an Advanced Alchemical Furnace immediately crashes my server due to "Ticking GridNode"

Description: Ticking GridNode

java.lang.NullPointerException: Ticking GridNode
    at thaumicenergistics.part.PartEssentiaImportBus.doWork(PartEssentiaImportBus.java:74)
    at thaumicenergistics.part.PartSharedEssentiaBus.tickingRequest(PartSharedEssentiaBus.java:163)
    at appeng.me.cache.TickManagerCache.onUpdateTick(TickManagerCache.java:91)
    at appeng.me.GridCacheWrapper.onUpdateTick(GridCacheWrapper.java:40)
    at appeng.me.Grid.update(Grid.java:229)
    at appeng.hooks.TickHandler.onTick(TickHandler.java:196)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_2129_TickHandler_onTick_TickEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus.forgeBridge$post(EventBus.java:1256)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:1206)
    at net.minecraftforge.fml.common.FMLCommonHandler.onPostServerTick(FMLCommonHandler.java:266)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:712)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:1817)
    at java.lang.Thread.run(Thread.java:748)
-- PartEssentiaImportBus being ticked. --
  CurrentTickRate: 22
  MinTickRate: 5
  MaxTickRate: 40
  MachineType: thaumicenergistics.part.PartEssentiaImportBus
  GridBlockType: thaumicenergistics.integration.appeng.grid.ThEGridBlock
  ConnectedSides: [INTERNAL]

Crashlog attached below.

Steps to Reproduce Steps to reproduce the behavior:

  1. Have a functional Advanced Alchemical Furnace that's running
  2. Place down an ME Essentia Import bus against any side of the furnace to connect it to an ME network

Expected behavior For the server not to crash.

Screenshots image

Version Information

Additional context Some exception handling and/or null checks seem to be missing, a third party kindly provided these which resolved the issue for my server.

Logs/Crashlogs https://pastebin.com/fNf9bcX1

Rishum-P commented 6 months ago

I resolved this for the user above by just adding some null checks to https://github.com/Delfayne/ThaumicEnergistics/blob/2795a6107945832f3ddde8fa2ca429a2b5e9898f/src/main/java/thaumicenergistics/part/PartEssentiaImportBus.java#L73

Just to check if container, container.getAspects() or container.getAspects().getAspects() is null. This is probably not the route cause of the issue but did resolve the crash.

Delfayne commented 6 months ago

I'd not heard that someone had ported this forward. I'll add it to the test environment and try to understand the root cause.

Delfayne commented 6 months ago

I currently presume this is down to chunkloading. The method that gets the connected tile entity clearly can return null if the chunk is not loaded.

The export bus logic for instance, starts with an instanceof IAspectContainer check. This implicitly also checks for nullness. The import bus make no such check.