Jump to content

Recommended Posts

Posted

Okay, after a long time, my custom recipe type works, or at least implicitly, because I don't know how to apply it to my block, I don't know what to overwrite my block to accept my recipe type and not vanilla. 

 

Posted

This time I get such a bug and I don't really know where to look for the bug. What class.

[18:39:56] [Render thread/WARN] [minecraft/ClientRecipeBook]: Unknown recipe category: [!!!com.mojang.logging.LogUtils$1ToString@41a18b54=>java.lang.NullPointerException:Cannot invoke "Object.toString()" because the return value of "java.util.function.Supplier.get()" is null!!!]/anymod:oak_stairs_from_woodcutter

Posted

Only this shows up in the console.

public class WoodcutterRecipe implements Recipe<Container> {
    protected final Ingredient ingredient;
    protected final ItemStack result;
    protected final ResourceLocation id;
    protected final String group;

    public WoodcutterRecipe(Ingredient ingredient, ItemStack result, ResourceLocation id, String group) {
        this.ingredient = ingredient;
        this.result = result;
        this.id = id;
        this.group = group;
    }

    public RecipeType<?> getType() {
        return Type.TYPE;
    }

    public RecipeSerializer<?> getSerializer() {
        return Serializer.INSTANCE;
    }

    public ResourceLocation getId() {
        return this.id;
    }

    public String getGroup() {
        return this.group;
    }

    public ItemStack getResultItem() {
        return this.result;
    }

    public NonNullList<Ingredient> getIngredients() {
        NonNullList<Ingredient> nonnulllist = NonNullList.create();
        nonnulllist.add(this.ingredient);
        return nonnulllist;
    }

    public boolean canCraftInDimensions(int pWidth, int pHeight) {
        return true;
    }

    @Override
    public boolean matches(Container pContainer, Level pLevel) {
        return false;
    }

    public ItemStack assemble(Container pInv) {
        return this.result.copy();
    }

    public static class Type implements RecipeType<WoodcutterRecipe>{
        public static final Type TYPE = new Type();
    }

    public static class Serializer implements RecipeSerializer<WoodcutterRecipe> {
        public static final Serializer INSTANCE = new Serializer();
        public static final ResourceLocation ID = new ResourceLocation(AnyMod.MOD_ID, "woodcutter");
        public WoodcutterRecipe fromJson(ResourceLocation pRecipeId, JsonObject pJson) {
            String s = GsonHelper.getAsString(pJson, "group", "");
            Ingredient ingredient;
            if (GsonHelper.isArrayNode(pJson, "ingredient")) {
                ingredient = Ingredient.fromJson(GsonHelper.getAsJsonArray(pJson, "ingredient"));
            } else {
                ingredient = Ingredient.fromJson(GsonHelper.getAsJsonObject(pJson, "ingredient"));
            }

            String s1 = GsonHelper.getAsString(pJson, "result");
            int i = GsonHelper.getAsInt(pJson, "count");
            ItemStack itemstack = new ItemStack(Registry.ITEM.get(new ResourceLocation(s1)), i);
            return new WoodcutterRecipe(ingredient, itemstack, pRecipeId, s);
        }

        public WoodcutterRecipe fromNetwork(ResourceLocation pRecipeId, FriendlyByteBuf pBuffer) {
            String s = pBuffer.readUtf();
            Ingredient ingredient = Ingredient.fromNetwork(pBuffer);
            ItemStack itemstack = pBuffer.readItem();
            return new WoodcutterRecipe(ingredient, itemstack, pRecipeId, s);
        }

        public void toNetwork(FriendlyByteBuf pBuffer, WoodcutterRecipe pRecipe) {
            pBuffer.writeUtf(pRecipe.group);
            pRecipe.ingredient.toNetwork(pBuffer);
            pBuffer.writeItem(pRecipe.result);
        }

        @Override
        public RecipeSerializer<?> setRegistryName(ResourceLocation name) {
            return INSTANCE;
        }

        @Nullable
        @Override
        public ResourceLocation getRegistryName() {
            return ID;
        }

        @Override
        public Class<RecipeSerializer<?>> getRegistryType() {
            return Serializer.castClass(RecipeSerializer.class);
        }

        @SuppressWarnings("unchecked")
        private static <G> Class<G> castClass(Class<?> cls) {
            return (Class<G>)cls;
        }
    }
}

This is what my Recipe Type looks like.

Posted

I wonder whether not to extend it with the SingeItemRecipe class as it is in vanilla and use the access transormer to change the interface which is in the Serializer class which is in the above-mentioned class, which would allow to register the serializer in DeferredRegister.

Posted (edited)
34 minuty temu diesieben07 powiedział:

Dotyczy również tego typu RecipeType.

In this way? Because I really don't know.

 

Edited by Squander
Posted

[18:24:54] [Render thread/WARN] [minecraft/Minecraft]: Failed to load datapacks, can't proceed with server load
java.util.concurrent.ExecutionException: java.lang.NullPointerException: Registry Object not present: anymod:woodcutter
    at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396) ~[?:?] {}
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073) ~[?:?] {}
    at net.minecraft.client.Minecraft.makeWorldStem(Minecraft.java:2123) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.doLoadLevel(Minecraft.java:1949) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.lambda$doLoadLevel$36(Minecraft.java:1953) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.DatapackLoadFailureScreen.lambda$init$0(DatapackLoadFailureScreen.java:24) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.Button.onPress(Button.java:29) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.AbstractButton.onClick(AbstractButton.java:17) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.AbstractWidget.mouseClicked(AbstractWidget.java:111) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.components.events.ContainerEventHandler.mouseClicked(ContainerEventHandler.java:31) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHandler.lambda$onPress$0(MouseHandler.java:93) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.gui.screens.Screen.wrapScreenError(Screen.java:528) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHandler.onPress(MouseHandler.java:90) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.MouseHandler.lambda$setup$4(MouseHandler.java:195) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.util.thread.BlockableEventLoop.execute(BlockableEventLoop.java:90) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.MouseHandler.lambda$setup$5(MouseHandler.java:194) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar%2354!/:build 10] {}
    at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar%2360!/:build 10] {}
    at org.lwjgl.glfw.GLFW.glfwWaitEventsTimeout(GLFW.java:3174) ~[lwjgl-glfw-3.2.2.jar%2354!/:build 10] {}
    at com.mojang.blaze3d.systems.RenderSystem.limitDisplayFPS(RenderSystem.java:187) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:1095) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.Minecraft.run(Minecraft.java:668) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    at net.minecraft.client.main.Main.main(Main.java:205) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:runtimedistcleaner:A}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {}
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {}
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {}
    at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {}
    at net.minecraftforge.fml.loading.targets.ForgeClientUserdevLaunchHandler.lambda$launchService$0(ForgeClientUserdevLaunchHandler.java:24) ~[fmlloader-1.18.2-40.0.51.jar%230!/:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-9.1.3.jar%2310!/:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53) [modlauncher-9.1.3.jar%2310!/:?] {}
    at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71) [modlauncher-9.1.3.jar%2310!/:?] {}
    at cpw.mods.modlauncher.Launcher.run(Launcher.java:106) [modlauncher-9.1.3.jar%2310!/:?] {}
    at cpw.mods.modlauncher.Launcher.main(Launcher.java:77) [modlauncher-9.1.3.jar%2310!/:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26) [modlauncher-9.1.3.jar%2310!/:?] {}
    at cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23) [modlauncher-9.1.3.jar%2310!/:?] {}
    at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:149) [bootstraplauncher-1.0.0.jar:?] {}
Caused by: java.lang.NullPointerException: Registry Object not present: anymod:woodcutter
    at java.util.Objects.requireNonNull(Objects.java:334) ~[?:?] {}
    at net.minecraftforge.registries.RegistryObject.get(RegistryObject.java:320) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2375%2381!/:?] {re:classloading,xf:fml:forge:registry_object_binary_compat}
    at me.squander.anymod.recipe.WoodcutterRecipe.getType(WoodcutterRecipe.java:29) ~[%2380!/:?] {re:classloading}
    at net.minecraft.world.item.crafting.RecipeManager.apply(RecipeManager.java:72) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading}
    at net.minecraft.world.item.crafting.RecipeManager.apply(RecipeManager.java:34) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading}
    at net.minecraft.server.packs.resources.SimplePreparableReloadListener.lambda$reload$1(SimplePreparableReloadListener.java:12) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading}
    at java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718) ~[?:?] {}
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482) ~[?:?] {}
    at net.minecraft.server.packs.resources.SimpleReloadInstance.lambda$new$3(SimpleReloadInstance.java:65) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading}
    at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:146) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:22) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading}
    at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:116) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:129) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.client.Minecraft.makeWorldStem(Minecraft.java:2122) ~[forge-1.18.2-40.0.51_mapped_parchment_1.18.1-2022.03.06-1.18.2-recomp.jar%2376!/:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
    ... 33 more

Posted
2 minutes ago, Squander said:

Registry Object not present: anymod:woodcutter

did you register the DeferredRegister to the ModEventBos in your main mod class constructor

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.