Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[SOLVED] [MC1.20.1] [FORGE MDK 47.2.0] Vanilla Items not working in custom item recipe creation - RecipeProvider.

Featured Replies

Posted

So, I've been trying out coding a mof, these are some tests for what I can do with it, and now I am creating a RecipeProvider. I know java, but minecraft modding not exactly, I've seen people ask for recipe assist here, but none matched my problem, so before I show the code, I want to remind you that the same code works if I put in modded items, but with vanilla, it doesn't.

Okay, here is the code:

ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.STEEL_ALLOY_POWDER.get(), 6)

.pattern("###")

.pattern("///")

.pattern("///")

.define("/", IRON_INGOT.get()) //here is the problem, it shows that Cannot resolve method ".get()" in  Item 

.define("#", COAL.get()) //same here

.requires(IRON_INGOT, COAL)

.unlockedBy(getHasName(ModItems.STEEL_ALLOY_POWDER.get(), has(Items.IRON_INGOT.get(), Items.COAL.get()))) same problem here, and it only appears with Vanilla Items

.save(pWriter);

Maybe I am just blind, but does someone mind helping, cause I've been stuck finding a solution for 2 days.

 

[Edit] I tried taking the ".get()" function off, cause it worked for ".requires" tag, it doesn't

[Edit #2] The solution for given problem turns out to be, to encase the symbol in '/' not "/" afterwards everything should work perfectly!

Edited by SpideyMagma
Issue Solved

Vanilla Items are directly Item instances you do not need to call #get like for your Mod Items (which are RegistryObjects)

  • Author
4 minutes ago, Luis_ST said:

Vanilla Items are directly Item instances you do not need to call #get like for your Mod Items (which are RegistryObjects)

I tried, but it didn't work, and now when I return to Mods own added items, it doesn't work either, I am just stunned, cause shapeless works either way, but shaped doesn't, I've looked through multiple tutorials showing the process of adding datagen to a mod, all of them use this method, but I don't know why it doesn't work from me, maybe I'm just dumb..

Remove the #get call for all vanilla Items then post the log and the full class.

Please use the code feature of the forum.

  • Author
38 minutes ago, Luis_ST said:

Remove the #get call for all vanilla Items then post the log and the full class.

Please use the code feature of the forum.

Okay, here is the full class

package com.alexisotter.star_valley.datagen;

import com.alexisotter.star_valley.StarValley;
import com.alexisotter.star_valley.block.ModBlocks;
import com.alexisotter.star_valley.item.custom.ModItems;
import net.minecraft.data.PackOutput;
import net.minecraft.data.recipes.*;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.level.ItemLike;
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;

import java.util.List;
import java.util.function.Consumer;

public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder {
    private static final List<ItemLike> STEEL_SMELTABLE = List.of(ModItems.STEEL_ALLOY_POWDER.get(), ModBlocks.DEEPSLATE_STEEL_ORE.get());

    public ModRecipeProvider(PackOutput pOutput) {
        super(pOutput);
    }

    @Override
    protected void buildRecipes(Consumer<FinishedRecipe> pWriter) {
        oreSmelting(pWriter, STEEL_SMELTABLE, RecipeCategory.MISC, ModItems.STEEL_INGOT.get(), 0.35f, 300, "steel");
        oreBlasting(pWriter, STEEL_SMELTABLE, RecipeCategory.MISC, ModItems.STEEL_INGOT.get(), 0.35f, 150, "steel");

        ShapedRecipeBuilder.shaped(RecipeCategory.MISC, ModItems.STEEL_ALLOY_POWDER.get())
                .pattern("CCC")
                .pattern("III")
                .pattern("III")
                .define("I", Items.IRON_INGOT)
                .define("C", Items.COAL)
                .unlockedBy(getHasName(Items.IRON_INGOT), has(Items.IRON_INGOT))
                .save(pWriter);
    }

    protected static void oreSmelting(Consumer<FinishedRecipe> pFinishedRecipeConsumer, List<ItemLike> pIngredients, RecipeCategory pCategory,
                                      ItemLike pResult, float pExperience, int pCookingTIme, String pGroup) {
        oreCooking(pFinishedRecipeConsumer, RecipeSerializer.SMELTING_RECIPE, pIngredients, pCategory,
                pResult, pExperience, pCookingTIme, pGroup, "_from_smelting");
    }

    protected static void oreBlasting(Consumer<FinishedRecipe> pFinishedRecipeConsumer, List<ItemLike> pIngredients, RecipeCategory pCategory,
                                      ItemLike pResult, float pExperience, int pCookingTime, String pGroup) {
        oreCooking(pFinishedRecipeConsumer, RecipeSerializer.BLASTING_RECIPE, pIngredients, pCategory,
                pResult, pExperience, pCookingTime, pGroup, "_from_blasting");
    }

    protected static void oreCooking(Consumer<FinishedRecipe> pFinishedRecipeConsumer, RecipeSerializer<? extends AbstractCookingRecipe> pCookingSerializer,
                                     List<ItemLike> pIngredients, RecipeCategory pCategory, ItemLike pResult, float pExperience, int pCookingTime,
                                     String pGroup, String pRecipeName) {
        for(ItemLike itemlike : pIngredients) {
            SimpleCookingRecipeBuilder.generic(Ingredient.of(itemlike), pCategory, pResult, pExperience, pCookingTime,
                    pCookingSerializer).group(pGroup).unlockedBy(getHasName(itemlike), has(itemlike)).save(pFinishedRecipeConsumer,
                    StarValley.MOD_ID + ":" + (pResult) + pRecipeName + "_" + getItemName(itemlike));
        }

    }
}

here is what the log outputs in IntelliJ:

C:\Users\Alexis

\Modding\forge-1.20.1-47.2.0-star_valley\src\main\java\com\alexisotter\star_valley\datagen\ModRecipeProvider.java:34: error: no suitable method found for define(String,Item)
                .define("I", Items.IRON_INGOT)
                ^
    method ShapedRecipeBuilder.define(Character,TagKey<Item>) is not applicable
      (argument mismatch; String cannot be converted to Character)
    method ShapedRecipeBuilder.define(Character,ItemLike) is not applicable
      (argument mismatch; String cannot be converted to Character)
    method ShapedRecipeBuilder.define(Character,Ingredient) is not applicable
      (argument mismatch; String cannot be converted to Character)

  • Author
17 hours ago, Luis_ST said:

Remove the #get call for all vanilla Items then post the log and the full class.

Please use the code feature of the forum.

So umm... I approached tyhe code with a fresh mind today, and it turns out, I was just being dumb, you see, to get the ".define" tag to work pSymbol needs to be encased in 'exampleSymbol' not "exampleSymbol", I put this out here for anyone who might have run into the same problem.

  • SpideyMagma changed the title to [SOLVED] [MC1.20.1] [FORGE MDK 47.2.0] Vanilla Items not working in custom item recipe creation - RecipeProvider.
18 hours ago, SpideyMagma said:

String cannot be converted to Character

This was your problem if you don't know the difference between string and character. i would recommend learning the basics of java before modding Minecraft,

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.