marcin212 / Zetta-Industries

mod for minecraft
zlib License
24 stars 13 forks source link

[1.12.2] QuarryFixer passes a null block to ItemBlock #79

Closed LordRalex closed 6 years ago

LordRalex commented 6 years ago

Offending line: https://github.com/marcin212/Zetta-Industries/blob/1.12.2/src/main/java/com/bymarcin/zettaindustries/mods/quarryfixer/QuarryFixer.java#L23

Sponge expects that when you create the ItemBlock, that it can determine the type by looking at the item passed in. Since this is done at class initialization and you have not initialized the item, it calls new ItemBlock(null) and this causes a crash when used with Sponge.

As the item should not be created till the preInit(), this line should not create the item.

[21:08:30] [Server thread/ERROR] [net.minecraft.server.MinecraftServer]: Encountered an unexpected exception
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Zetta Industries (zettaindustries)

Caused by: java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_171]
    at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_171]
    at com.bymarcin.zettaindustries.modmanager.ModManager.loadMod(ModManager.java:113) ~[ModManager.class:?]
    at com.bymarcin.zettaindustries.modmanager.ModManager.preInit(ModManager.java:82) ~[ModManager.class:?]
    at com.bymarcin.zettaindustries.ZettaIndustries.preInit(ZettaIndustries.java:80) ~[ZettaIndustries.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:627) ~[forge-1.12.2-14.23.4.2739-universal.jar:?]
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[minecraft_server.1.12.2.jar:?]
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218) ~[forge-1.12.2-14.23.4.2739-universal.jar:?]
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196) ~[forge-1.12.2-14.23.4.2739-universal.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[minecraft_server.1.12.2.jar:?]
    at net.minecraftforge.fml.common.LoadController.redirect$onPost$zza000(LoadController.java:560) ~[LoadController.class:?]
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135) ~[LoadController.class:?]
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627) ~[Loader.class:?]
    at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:99) ~[FMLServerHandler.class:?]
    at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:332) ~[FMLCommonHandler.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:125) ~[nz.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486) [MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_171]
Caused by: java.lang.NullPointerException
    at java.util.Objects.requireNonNull(Objects.java:203) ~[?:1.8.0_171]
    at java.util.Optional.<init>(Optional.java:96) ~[?:1.8.0_171]
    at java.util.Optional.of(Optional.java:108) ~[?:1.8.0_171]
    at net.minecraft.item.ItemBlock.handler$onConstructed$zho000(ItemBlock.java:547) ~[ahb.class:?]
    at net.minecraft.item.ItemBlock.<init>(ItemBlock.java:35) ~[ahb.class:?]
    at com.bymarcin.zettaindustries.mods.quarryfixer.QuarryFixer.<clinit>(QuarryFixer.java:23) ~[QuarryFixer.class:?]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_171]
    at java.lang.Class.forName(Class.java:264) ~[?:1.8.0_171]
    at com.bymarcin.zettaindustries.modmanager.ModManager.loadMod(ModManager.java:113) ~[ModManager.class:?]
    at com.bymarcin.zettaindustries.modmanager.ModManager.preInit(ModManager.java:82) ~[ModManager.class:?]
    at com.bymarcin.zettaindustries.ZettaIndustries.preInit(ZettaIndustries.java:80) ~[ZettaIndustries.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:627) ~[forge-1.12.2-14.23.4.2739-universal.jar:?]
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source) ~[?:?]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[minecraft_server.1.12.2.jar:?]
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218) ~[forge-1.12.2-14.23.4.2739-universal.jar:?]
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196) ~[forge-1.12.2-14.23.4.2739-universal.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_171]
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) ~[minecraft_server.1.12.2.jar:?]
    at com.google.common.eventbus.EventBus.post(EventBus.java:217) ~[minecraft_server.1.12.2.jar:?]
    at net.minecraftforge.fml.common.LoadController.redirect$onPost$zza000(LoadController.java:560) ~[LoadController.class:?]
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135) ~[LoadController.class:?]
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627) ~[Loader.class:?]
    at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:99) ~[FMLServerHandler.class:?]
    at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:332) ~[FMLCommonHandler.class:?]
    at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:125) ~[nz.class:?]
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:486) ~[MinecraftServer.class:?]
    at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_171]
phase commented 6 years ago

Well it seems like that line should just be removed since it's initialized in the preInit.

https://github.com/marcin212/Zetta-Industries/blob/9329d1f55232dadd499df8944f834f39e10146cb/src/main/java/com/bymarcin/zettaindustries/mods/quarryfixer/QuarryFixer.java#L37-L41