Jump to content

Recommended Posts

Posted

I have a little problem.

When I runData, I get this error.

Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.item.CreativeModeTab.getRecipeFolderName()" because the return value of "net.minecraft.world.item.Item.getItemCategory()" is null

These are my recipes:

ShapedRecipeBuilder.shaped(ModBlocks.FLINT_BLOCK.get()).define('#', Items.FLINT).pattern("###").pattern("###").pattern("###").unlockedBy("has_material", has(Items.FLINT)).save(pFinishedRecipeConsumer);
ShapedRecipeBuilder.shaped(ModBlocks.CHARCOAL_BLOCK.get()).define('#', Items.CHARCOAL).pattern("###").pattern("###").pattern("###").unlockedBy("has_material", has(Items.CHARCOAL)).save(pFinishedRecipeConsumer);

How can I fix this?

 

Posted (edited)

Here is my creative mode tab declaration.

    public static final CreativeModeTab TAB_BETTER_MATERIALS = new CreativeModeTab("better_materials") {
        @Override public @NotNull ItemStack makeIcon() {return new ItemStack(ModBlockItems.FLINT_BLOCK.get());}
    };

Here are my BlockItems, which have a creative mode tab set.

    public static final RegistryObject<Item> FLINT_BLOCK = BLOCK_ITEMS.register("flint_block", ()-> new BlockItem(ModBlocks.FLINT_BLOCK.get(), new Item.Properties().tab(BetterMaterials.TAB_BETTER_MATERIALS)));
    public static final RegistryObject<Item> CHARCOAL_BLOCK = BLOCK_ITEMS.register("charcoal_block", ()-> new BlockItem(ModBlocks.FLINT_BLOCK.get(), new Item.Properties().tab(BetterMaterials.TAB_BETTER_MATERIALS)) {
        @Override public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {return 16000;}
    });

The recipe is for a Block, and the block doesn't have a creative mode tab, the blockitem has. Could it be an error from the anonymous class, even tho the error is thrown twice for both blocks...

Edited by Darkorg69
Posted
Spoiler
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:39)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
	at [email protected]/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at MC-BOOTSTRAP/[email protected]/net.minecraftforge.fml.loading.targets.ForgeDataUserdevLaunchHandler.lambda$launchService$0(ForgeDataUserdevLaunchHandler.java:41)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37)
	... 7 more
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.item.CreativeModeTab.getRecipeFolderName()" because the return value of "net.minecraft.world.item.Item.getItemCategory()" is null
	at TRANSFORMER/[email protected]/net.minecraft.data.recipes.ShapedRecipeBuilder.save(ShapedRecipeBuilder.java:94)
	at TRANSFORMER/[email protected]/net.minecraft.data.recipes.RecipeBuilder.save(RecipeBuilder.java:21)
	at TRANSFORMER/[email protected]/darkorg.bettermaterials.data.common.ModRecipeProvider.buildCraftingRecipes(ModRecipeProvider.java:31)
	at TRANSFORMER/[email protected]/net.minecraft.data.recipes.RecipeProvider.run(RecipeProvider.java:97)
	at TRANSFORMER/[email protected]/net.minecraft.data.DataGenerator.run(DataGenerator.java:44)
	at TRANSFORMER/[email protected]/net.minecraftforge.forge.event.lifecycle.GatherDataEvent$DataGeneratorConfig.lambda$runAll$0(GatherDataEvent.java:98)
	at MC-BOOTSTRAP/[email protected]/cpw.mods.modlauncher.api.LamdbaExceptionUtils.lambda$rethrowConsumer$0(LamdbaExceptionUtils.java:34)
	at java.base/java.util.HashMap$Values.forEach(HashMap.java:1065)
	at TRANSFORMER/[email protected]/net.minecraftforge.forge.event.lifecycle.GatherDataEvent$DataGeneratorConfig.runAll(GatherDataEvent.java:94)
	at TRANSFORMER/[email protected]/net.minecraftforge.data.loading.DatagenModLoader.begin(DatagenModLoader.java:45)
	at TRANSFORMER/[email protected]/net.minecraft.data.Main.main(Main.java:67)
	... 13 more
Caused by: java.lang.reflect.InvocationTargetException

Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.item.CreativeModeTab.getRecipeFolderName()" because the return value of "net.minecraft.world.item.Item.getItemCategory()" is null


> Task :runData FAILED

Execution failed for task ':runData'.
> Process 'command 'C:\Program Files\Java\jdk-17.0.2\bin\java.exe'' finished with non-zero exit value 1

 

Here is the log.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.