GrowthcraftCE / Growthcraft-1.12

Growthcraft is a low-tech brewing, farming, and cooking Minecraft Mod.
GNU Affero General Public License v3.0
33 stars 22 forks source link

[4.1.1.500] (forked) Crash due to null ItemKeySchema passed in UserFermentingRecipe #297

Closed VonZeeple closed 4 years ago

VonZeeple commented 4 years ago

I'm working on a forked version of Growthcraft (synced with 4.1.1). During the initialization of user fermenting recipes, forge crashes because a null ItemKeySchema is passed in UserFermentingRecipe (for example with the poisoned cider recipe). There is indeed a @Nonnull keyword in frond of ItemKeySchema itemSchema. I don't know why it is working for anyone else however.

IceDragon200 commented 4 years ago

@VonZeeple Remove (or backup if you'd like, but make sure they're not in the growthcraft config) the json recipes and let Growthcraft regenerate them, if it crashes again you'll need to provide the full log file.

Since it crashes in the UserFermentingRecipe this is likely caused by a misconfigured user recipe

VonZeeple commented 4 years ago

Hi I regenerated the config, also tried with a config generated with working version. Anyway it appends before generating the files, when UserFermentingRecipe is called by UserFermentingRecipesConfig.addDefaultSchemas with a null ItemKeySchema. The null argument is explicitly passed by addFallbackDefault when generating the poisoned apple juice recipe.

VonZeeple commented 4 years ago

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Growthcraft Apples (growthcraft_apples) Caused by: java.lang.IllegalArgumentException: Argument for @Nonnull parameter 'itemSchema' of growthcraft/cellar/shared/processing/fermenting/user/UserFermentingRecipe. must not be null at growthcraft.cellar.shared.processing.fermenting.user.UserFermentingRecipe.$$$reportNull$$$0(UserFermentingRecipe.java) at growthcraft.cellar.shared.processing.fermenting.user.UserFermentingRecipe.(UserFermentingRecipe.java) at growthcraft.cellar.shared.processing.fermenting.user.UserFermentingRecipesConfig.addDefaultSchemas(UserFermentingRecipesConfig.java:24) at growthcraft.cellar.shared.processing.fermenting.user.UserFermentingRecipesConfig.addFallbackDefault(UserFermentingRecipesConfig.java:54) at growthcraft.cellar.shared.booze.UserApiCellarBoozeBuilder.fermentsFromFallback(UserApiCellarBoozeBuilder.java:73) at growthcraft.apples.common.Init.registerFermentations(Init.java:352) at growthcraft.apples.common.Init.initBoozes(Init.java:254) at growthcraft.apples.GrowthcraftApples.init(GrowthcraftApples.java:49) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:626) at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:218) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:196) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:135) at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:744) at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336) at net.minecraft.client.Minecraft.init(Minecraft.java:582) at net.minecraft.client.Minecraft.run(Minecraft.java:422) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25)

IceDragon200 commented 4 years ago

@VonZeeple I'm really not sure what recipe is trying to load to cause that, I'm also not all that familiar with the 1.12 codebase, so the best I can suggest at moment, add some logging lines in registerFermentations and print each recipe name/id until you find the one that crashes it.

Also sorry for the late reply, been a busy busy first 2 weeks at work

VonZeeple commented 4 years ago

this is due to the fallback recipe for the poisoned cider (line 352 in apples\common\Init). A fallback recipe doesn't accept an input item. So addFallbackDefault(@Nonnull Object inputFluid, @Nonnull FluidStack outputFluid, int time) in UserFermentingRecipesConfig passes a null item. This happens before the generation of the config files. It is quite clear what doesn't work in the code, i'm just confused by the fact that it seems to work on your side.

IceDragon200 commented 4 years ago

@VonZeeple Very odd indeed, I've only worked on the 1.7 codebase, but from what I can remember, we didn't have fallbacks at the time, I guess you can just comment out the line for now, though you may encounter several more similar cases later, gather all of them up if you can.

@Alatyami Can you shed any light on this fallback issue?

VonZeeple commented 4 years ago

I think their is a problem with @Nonnull annotation about everywhere in the code, for example in ItemTest:

public static boolean isValid(@Nonnull ItemStack stack) { if (stack == null) return false; if (stack.getItem() == null) return false; if (stack.isEmpty()) return false; return true; }

Also the case for findItemSlots(@Nonnull IInventory inv, @Nonnull List expected, @Nonnull int[] slotsSlice) crashing due to:

public int[] findItemSlots(@Nonnull IInventory inv, @Nonnull List expected) { return findItemSlots(inv, expected, null); }

ghost commented 4 years ago

In isValid it should be safe to remove the annotation, because there is an if with null check. Probably it is a copy&paste issue from my side.

VonZeeple commented 4 years ago

I updated IntelliJ and I now work on a fresh fork, and i don't have this error anymore... maybe there were a problem with my compiler...