Vaerys_Dawn

Registering Potion mixes causes NPE

Jan 21st, 2021 (edited)
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     @Override
  2.     public void onResourceManagerReload(@Nonnull IResourceManager resourceManager) {
  3.         ModPotions.createMixes();
  4.         ...
  5.  
  6. // ModPotions.class
  7.     private static final ITag<Item> HONEY_BOTTLE_TAG = ItemTags.getCollection().get(new ResourceLocation("forge:honey_bottle"));
  8.  
  9.     public static void createMixes() {    V----- NPE happens here
  10.         addMix(Potions.AWKWARD, Ingredient.fromTag(HONEY_BOTTLE_TAG), CALMING_POTION.get());
  11.         addMix(CALMING_POTION.get(), Ingredient.fromItems(Items.GLOWSTONE_DUST), LONG_CALMING_POTION.get());
  12.     }
  13.  
  14.     private static void addMix(Potion basePotion, Ingredient fromTag, Potion outputPotion) {
  15.         ItemStack potion = new ItemStack(Items.POTION);
  16.         ItemStack splashPotion = new ItemStack(Items.SPLASH_POTION);
  17.         ItemStack lingeringPotion = new ItemStack(Items.LINGERING_POTION);
  18.         Ingredient gunpowder = Ingredient.fromItems(Items.GUNPOWDER);
  19.         Ingredient dragonBreath = Ingredient.fromItems(Items.DRAGON_BREATH);
  20.         Ingredient baseIngredient = Ingredient.fromStacks(PotionUtils.addPotionToItemStack(potion, basePotion));
  21.         Ingredient potionIngredient = Ingredient.fromStacks(PotionUtils.addPotionToItemStack(potion, outputPotion));
  22.         BrewingRecipeRegistry.addRecipe(baseIngredient, fromTag, PotionUtils.addPotionToItemStack(potion, outputPotion));
  23.         BrewingRecipeRegistry.addRecipe(potionIngredient, gunpowder, PotionUtils.addPotionToItemStack(splashPotion, outputPotion));
  24.         BrewingRecipeRegistry.addRecipe(potionIngredient, dragonBreath, PotionUtils.addPotionToItemStack(lingeringPotion, outputPotion));
  25.     }
  26.  
  27.  
  28.  
  29. java.util.concurrent.ExecutionException: java.lang.NullPointerException
  30.     at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357) ~[?:1.8.0_271] {}
  31.     at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908) ~[?:1.8.0_271] {}
  32.     at net.minecraft.client.Minecraft.method_29604(Minecraft.java:1917) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
  33.     at net.minecraft.client.Minecraft.startIntegratedServer(Minecraft.java:1769) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
  34.     at net.minecraft.client.Minecraft.startIntegratedServer(Minecraft.java:1739) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
  35.     at net.minecraft.client.gui.screen.WorldSelectionList$Entry.func_214443_e(WorldSelectionList.java:374) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  36.     at net.minecraft.client.gui.screen.WorldSelectionList$Entry.func_214438_a(WorldSelectionList.java:283) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  37.     at net.minecraft.client.gui.screen.WorldSelectionList$Entry.mouseClicked(WorldSelectionList.java:238) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  38.     at net.minecraft.client.gui.widget.list.AbstractList.mouseClicked(AbstractList.java:322) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  39.     at net.minecraft.client.gui.INestedGuiEventHandler.mouseClicked(INestedGuiEventHandler.java:44) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  40.     at net.minecraft.client.MouseHelper.lambda$mouseButtonCallback$0(MouseHelper.java:92) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  41.     at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:469) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  42.     at net.minecraft.client.MouseHelper.mouseButtonCallback(MouseHelper.java:90) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  43.     at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:185) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  44.     at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  45.     at net.minecraft.client.MouseHelper.lambda$registerCallbacks$5(MouseHelper.java:184) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  46.     at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
  47.     at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {}
  48.     at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
  49.     at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:93) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  50.     at net.minecraft.client.MainWindow.swapBuffers(MainWindow.java:305) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  51.     at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1033) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
  52.     at net.minecraft.client.Minecraft.run(Minecraft.java:612) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
  53.     at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
  54.     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_271] {}
  55.     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_271] {}
  56.     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_271] {}
  57.     at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_271] {}
  58.     at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {}
  59.     at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.6.jar:?] {}
  60.     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.6.jar:?] {}
  61.     at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.6.jar:?] {}
  62.     at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.6.jar:?] {}
  63.     at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.6.jar:?] {}
  64.     at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:105) [forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {}
  65. Caused by: java.lang.NullPointerException
  66.     at net.minecraft.item.crafting.Ingredient$TagList.getStacks(Ingredient.java:272) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  67.     at net.minecraft.item.crafting.Ingredient.lambda$new$4(Ingredient.java:47) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  68.     at java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90) ~[?:1.8.0_271] {}
  69.     at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958) ~[?:1.8.0_271] {}
  70.     at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) ~[?:1.8.0_271] {}
  71.     at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499) ~[?:1.8.0_271] {}
  72.     at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486) ~[?:1.8.0_271] {}
  73.     at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_271] {}
  74.     at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230) ~[?:1.8.0_271] {}
  75.     at java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196) ~[?:1.8.0_271] {}
  76.     at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_271] {}
  77.     at java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:449) ~[?:1.8.0_271] {}
  78.     at net.minecraft.item.crafting.Ingredient.<init>(Ingredient.java:47) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  79.     at net.minecraft.item.crafting.Ingredient.fromItemListStream(Ingredient.java:153) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  80.     at net.minecraft.item.crafting.Ingredient.fromTag(Ingredient.java:174) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  81.     at com.resourcefulbees.resourcefulbees.registry.ModPotions.createMixes(ModPotions.java:29) ~[main/:?] {re:classloading}
  82.     at com.resourcefulbees.resourcefulbees.data.RecipeBuilder.onResourceManagerReload(RecipeBuilder.java:37) ~[main/:?] {re:classloading}
  83.     at net.minecraft.resources.IResourceManagerReloadListener.lambda$reload$0(IResourceManagerReloadListener.java:18) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  84.     at java.util.concurrent.CompletableFuture.uniRun(CompletableFuture.java:719) ~[?:1.8.0_271] {}
  85.     at java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:701) ~[?:1.8.0_271] {}
  86.     at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:456) ~[?:1.8.0_271] {}
  87.     at net.minecraft.resources.AsyncReloader.lambda$null$3(AsyncReloader.java:66) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  88.     at net.minecraft.util.concurrent.ThreadTaskExecutor.run(ThreadTaskExecutor.java:139) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  89.     at net.minecraft.util.concurrent.RecursiveEventLoop.run(RecursiveEventLoop.java:22) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading}
  90.     at net.minecraft.util.concurrent.ThreadTaskExecutor.driveOne(ThreadTaskExecutor.java:109) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  91.     at net.minecraft.util.concurrent.ThreadTaskExecutor.driveUntil(ThreadTaskExecutor.java:122) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
  92.     at net.minecraft.client.Minecraft.method_29604(Minecraft.java:1916) ~[forge-1.16.4-35.1.32_mapped_snapshot_20210106-mixed-1.16.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
  93.     ... 32 more
  94.  
RAW Paste Data