GTNewHorizons / GT-New-Horizons-Modpack

New Modpack with Gregtech, Thaumcraft and Witchery
https://www.gtnewhorizons.com/
Other
986 stars 299 forks source link

getBaseMetaTileEntity() returning null, resulting in a wide range of errors #13245

Closed Tommeh1 closed 7 months ago

Tommeh1 commented 1 year ago

Your GTNH Discord Username

No response

Your Pack Version

2.3.2

Your Server

Private Server

Java Version

Java 19

Type of Server

Vanilla Forge

The Reality

It turns out that the error, which can affect just about any machine as mentioned in #13143 can also cause more severe issues, for example disconnecting the client like shown below. In other cases it generally leads to random recipes failing, causing minor shortages for AE2 orders, jamming the order, or a general loss of items. Additionally it might explain a couple of random shutdowns of machines or machines using an odd power tier until restarted as power related checks are also affected.

The cause is most likely introduced in either 2.3.1 or 2.3.2 The trigger however is unknown, given that it can even cause issues with nobody online for machines that run essentially all the time.

This also ain't limited to a single mod adding machines, Gregtech, GT++, TecTech, GoodGenerator etc are all affected. There are also no limits as to what checks can end up having null returned by getBaseMetaTileEntity(), seemingly any check that needs it is affected.

[17:46:47] [Server thread/WARN]: Failed to handle packet for /<ip>:50156
java.lang.NullPointerException: Cannot invoke "gregtech.api.interfaces.tileentity.IGregTechTileEntity.setActive(boolean)" because the return value of "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Holder.getBaseMetaTileEntity()" is null
at com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_research.onRemoval(GT_MetaTileEntity_EM_research.java:576) ~[GT_MetaTileEntity_EM_research.class:?]
at gregtech.api.metatileentity.BaseMetaTileEntity.func_145843_s(BaseMetaTileEntity.java:942) ~[BaseMetaTileEntity.class:?]
at net.minecraft.world.chunk.Chunk.func_150805_f(Chunk.java:901) ~[apx.class:?]
at net.minecraft.world.World.func_147475_p(World.java:2609) ~[ahb.class:?]
at net.minecraft.block.Block.func_149749_a(Block.java:627) ~[aji.class:?]
at gregtech.common.blocks.GT_Block_Machines.func_149749_a(GT_Block_Machines.java:439) ~[GT_Block_Machines.class:?]
at net.minecraft.world.chunk.Chunk.func_150807_a(Chunk.java:600) ~[apx.class:?]
at net.minecraft.world.World.func_147465_d(World.java:451) ~[ahb.class:?]
at net.minecraft.world.World.func_147468_f(World.java:573) ~[ahb.class:?]
at gregtech.common.blocks.GT_Block_Machines.func_149636_a(GT_Block_Machines.java:469) ~[GT_Block_Machines.class:?]
at net.minecraft.server.management.ItemInWorldManager.func_73084_b(Unknown Source) ~[mx.class:?]
at net.minecraft.server.management.ItemInWorldManager.func_73074_a(Unknown Source) ~[mx.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147345_a(NetHandlerPlayServer.java:489) ~[nh.class:?]
at net.minecraft.network.play.client.C07PacketPlayerDigging.func_148833_a(SourceFile:53) ~[ji.class:?]
at net.minecraft.network.play.client.C07PacketPlayerDigging.func_148833_a(SourceFile:8) ~[ji.class:?]
at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:212) ~[ej.class:?]
at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:165) [nc.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:659) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334) [lt.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547) [MinecraftServer.class:?]
at fastcraft.u.a(F:289) [fastcraft-1.25.jar:?]
at fastcraft.H.aq(F:36) [fastcraft-1.25.jar:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:396) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685) [li.class:?]
[17:46:47] [Server thread/INFO]: RamseySpace lost connection: TextComponent{text='Internal server error', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null}}

Your Proposal

Fix whatever causes getBaseMetaTileEntity() on seemingly any machine to return null at random.

Final Checklist

Tommeh1 commented 1 year ago

Here is another potentially more severe example, causing a lapotronic super capacitor to freak out a few hundred times, risking that things might shutdown all over the place depending on how it behaves when it errors:

java.lang.NullPointerException: Cannot invoke "gregtech.api.interfaces.tileentity.IGregTechTileEntity.isInvalidTileEntity()" because the return value of "com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyTunnel.getBaseMetaTileEntity()" is null
    at common.tileentities.GTMTE_LapotronicSuperCapacitor.onRunningTick(GTMTE_LapotronicSuperCapacitor.java:718)
    at gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.runMachine(GT_MetaTileEntity_MultiBlockBase.java:426)
    at gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.onPostTick(GT_MetaTileEntity_MultiBlockBase.java:357)
    at gregtech.api.metatileentity.BaseMetaTileEntity.func_145845_h(BaseMetaTileEntity.java:522)
    at net.minecraft.world.World.func_72939_s(World.java:1939)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:1146)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at fastcraft.u.a(F:289)
    at fastcraft.H.aq(F:36)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:396)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)
Tommeh1 commented 1 year ago

Another similar issue:

java.lang.NullPointerException: Cannot read field "mStoredEnergy" because "this.mBaseMetaTileEntity" is null
    at gregtech.api.metatileentity.MetaTileEntity.getEUVar(MetaTileEntity.java:537)
    at com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor.checkRecipe(GT_TileEntity_ElectricImplosionCompressor.java:182)
    at gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.checkRecipe(GT_MetaTileEntity_MultiBlockBase.java:416)
    at gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.runMachine(GT_MetaTileEntity_MultiBlockBase.java:473)
    at gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.onPostTick(GT_MetaTileEntity_MultiBlockBase.java:357)
    at com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor.onPostTick(GT_TileEntity_ElectricImplosionCompressor.java:245)
    at gregtech.api.metatileentity.BaseMetaTileEntity.func_145845_h(BaseMetaTileEntity.java:522)
    at net.minecraft.world.World.func_72939_s(World.java:1939)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:1146)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at fastcraft.u.a(F:289)
    at fastcraft.H.aq(F:36)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:396)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)
Tommeh1 commented 1 year ago

Yet another case:

java.lang.NullPointerException: Cannot invoke "gregtech.api.interfaces.tileentity.IGregTechTileEntity.doExplosion(long)" because the return value of "gregtech.api.metatileentity.MetaTileEntity.getBaseMetaTileEntity()" is null
    at com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_computer.extraExplosions_EM(GT_MetaTileEntity_EM_computer.java:406)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.explodeMultiblock(GT_MetaTileEntity_MultiblockBase_EM.java:2111)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.doExplosion(GT_MetaTileEntity_MultiblockBase_EM.java:2153)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doEnergyExplosion(BaseMetaTileEntity.java:1315)
    at gregtech.common.blocks.GT_Block_Machines.func_149690_a(GT_Block_Machines.java:518)
    at net.minecraft.world.Explosion.func_77279_a(Explosion.java:212)
    at net.minecraft.world.WorldServer.func_72885_a(WorldServer.java:902)
    at net.minecraft.world.World.func_72876_a(World.java:2403)
    at gregtech.api.metatileentity.MetaTileEntity.doExplosion(MetaTileEntity.java:1104)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_research.extraExplosions_EM(GT_MetaTileEntity_EM_research.java:583)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.explodeMultiblock(GT_MetaTileEntity_MultiblockBase_EM.java:2111)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.doExplosion(GT_MetaTileEntity_MultiblockBase_EM.java:2153)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doEnergyExplosion(BaseMetaTileEntity.java:1315)
    at gregtech.common.blocks.GT_Block_Machines.func_149690_a(GT_Block_Machines.java:518)
    at net.minecraft.world.Explosion.func_77279_a(Explosion.java:212)
    at net.minecraft.world.WorldServer.func_72885_a(WorldServer.java:902)
    at net.minecraft.world.World.func_72876_a(World.java:2403)
    at gregtech.api.metatileentity.MetaTileEntity.doExplosion(MetaTileEntity.java:1104)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doEnergyExplosion(BaseMetaTileEntity.java:1315)
    at gregtech.common.blocks.GT_Block_Machines.func_149690_a(GT_Block_Machines.java:518)
    at net.minecraft.world.Explosion.func_77279_a(Explosion.java:212)
    at net.minecraft.world.WorldServer.func_72885_a(WorldServer.java:902)
    at net.minecraft.world.World.func_72876_a(World.java:2403)
    at gregtech.api.metatileentity.MetaTileEntity.doExplosion(MetaTileEntity.java:1104)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.explodeMultiblock(GT_MetaTileEntity_MultiblockBase_EM.java:2134)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.doExplosion(GT_MetaTileEntity_MultiblockBase_EM.java:2153)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doEnergyExplosion(BaseMetaTileEntity.java:1315)
    at gregtech.common.blocks.GT_Block_Machines.func_149690_a(GT_Block_Machines.java:518)
    at net.minecraft.world.Explosion.func_77279_a(Explosion.java:212)
    at net.minecraft.world.WorldServer.func_72885_a(WorldServer.java:902)
    at net.minecraft.world.World.func_72876_a(World.java:2403)
    at gregtech.api.metatileentity.MetaTileEntity.doExplosion(MetaTileEntity.java:1104)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doEnergyExplosion(BaseMetaTileEntity.java:1315)
    at gregtech.common.blocks.GT_Block_Machines.func_149690_a(GT_Block_Machines.java:518)
    at net.minecraft.world.Explosion.func_77279_a(Explosion.java:212)
    at net.minecraft.world.WorldServer.func_72885_a(WorldServer.java:902)
    at net.minecraft.world.World.func_72876_a(World.java:2403)
    at gregtech.api.metatileentity.MetaTileEntity.doExplosion(MetaTileEntity.java:1104)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.doExplosion(GT_MetaTileEntity_MultiblockBase_EM.java:2154)
    at gregtech.api.metatileentity.BaseMetaTileEntity.doExplosion(BaseMetaTileEntity.java:1354)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.explodeMultiblock(GT_MetaTileEntity_MultiblockBase_EM.java:2137)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.onPostTick(GT_MetaTileEntity_MultiblockBase_EM.java:1176)
    at gregtech.api.metatileentity.BaseMetaTileEntity.func_145845_h(BaseMetaTileEntity.java:522)
    at net.minecraft.world.World.func_72939_s(World.java:1939)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:1146)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at fastcraft.u.a(F:289)
    at fastcraft.H.aq(F:36)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:396)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)
Tommeh1 commented 1 year ago

And another:

java.lang.NullPointerException: Cannot read field "mStoredEnergy" because "this.mBaseMetaTileEntity" is null
    at gregtech.api.metatileentity.MetaTileEntity.setEUVar(MetaTileEntity.java:544)
    at com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM.onPostTick(GT_MetaTileEntity_MultiblockBase_EM.java:1203)
    at gregtech.api.metatileentity.BaseMetaTileEntity.func_145845_h(BaseMetaTileEntity.java:522)
    at net.minecraft.world.World.func_72939_s(World.java:1939)
    at net.minecraft.world.WorldServer.func_72939_s(WorldServer.java:1146)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:636)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547)
    at fastcraft.u.a(F:289)
    at fastcraft.H.aq(F:36)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:396)
    at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:685)