0
\$\begingroup\$

I'm using Forge on IntelliJ IDEA to make a mod for Minecraft, and I think I am stuck on where I need to register a recipe for an item.

How I got to that idea: I tested it out and everything worked. No bugs/errors: The item that would be made with the recipe (a rubber band) was available right away in creative mode. However, when I was trying to do the recipe part for creating the rubber band, which would include getting a dandelion that leads to an achievement(?) that shows the player they would then be able to make a rubber band with dandelions, the achievement only showed the regular recipe that's in the original game.

I know the setup of the files that import other methods works because I tried it out with this example. It also shows that the rubber_band.json was made in the resources, so my guess is that the part that went wrong is most likely how I did not include the registration of the recipe for the rubber band. I'm just unsure how to get that settled.

Here is what I have so far:

public class Recipes extends RecipeProvider { public Recipes(DataGenerator generatorIn) { super(generatorIn); } @Override protected void buildCraftingRecipes(Consumer<FinishedRecipe> consumer) { ShapelessRecipeBuilder.shapeless(Registration.RUBBER_BAND.get()) .requires(Items.DANDELION, 9) .unlockedBy("has_dandelion", has(Items.DANDELION)) .save(consumer); } } 

^ with imports, this is the recipes (the only one I have so far)

 public static final RegistryObject<Item> RUBBER_BAND = ITEMS.register("rubber_band", () -> new Item(ITEM_PROPERTIES)); // public static final TagKey<Item> DANDELION_ITEM = TagKey.create(Registry.ITEM_REGISTRY, new ResourceLocation(glow.MODID, "dandelion_item")); public static final DeferredRegister<RecipeType<?>> RECIPES = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS.getRegistryName(), glow.MODID); public static final RegistryObject<RecipeType<CraftingRecipe>> RUBBER_BAND_RECIPE = RECIPES.register("rubber_band_recipe", () -> new Recipe<ITEM_RECIPE>); 

^ this is towards registration

singleTexture(Registration.RUBBER_BAND.getId().getPath(), mcLoc("item/generated"), "layer0", modLoc("item/rubber_band")); 

^ this is towards ItemModelProvider

tag(Registration.DANDELION_ITEM) .add(Registration.RUBBER_BAND.get()); 

^ these are the tags

add(Registration.RUBBER_BAND.get(), "Rubber band"); 

^ this is the name

I am following this tutorial and this tutorial to get the format organized (and understand things better). I am also using this doc to see what I'm looking for, though I'm still not getting a good grasp on reading it.

Once more, my goal is to be able to craft the rubber band.

This is what it should look like at the crafting table:

Crafting table recipe

The player should also unlock the recipe when picking up the dandelion:

Unlocking recipe when picking up dandelion

Also, this is for game 1.18.2. Thank you in advance!

I have not yet used the Recipes class. I have been trying to follow along with this, which is the most recent version of the tutorial author's, but this also does not mention Recipes while it includes the class.

\$\endgroup\$
2
  • \$\begingroup\$ I'm not an expert on Minecraft modding, but it almost looks like you're overwriting the Recipe class completely, no? I can see you have public class Recipes, but where are you doing new Recipes("recipe")? \$\endgroup\$ Commented Nov 25, 2022 at 1:55
  • \$\begingroup\$ @dockeryZ @user253751 I have edited the question to include why I do not have Recipes \$\endgroup\$ Commented Nov 25, 2022 at 21:28

1 Answer 1

0
\$\begingroup\$

I realized I missed adding new Recipes() in the class DataGenerators

@Mod.EventBusSubscriber(modid = glow.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class DataGenerators { @SubscribeEvent public static void gatherData(GatherDataEvent event) { DataGenerator generator = event.getGenerator(); if (event.includeServer()) { generator.addProvider(new Recipes(generator)); // this was previously commented out // generator.addProvider(new LootTables(generator)); BlockTags blockTags = new BlockTags(generator, event.getExistingFileHelper()); generator.addProvider(blockTags); generator.addProvider(new ItemTags(generator, blockTags, event.getExistingFileHelper())); } if (event.includeClient()) { generator.addProvider(new BlockStates(generator, event.getExistingFileHelper())); generator.addProvider(new ItemModels(generator, event.getExistingFileHelper())); generator.addProvider(new LanguageProvider(generator, "en_us")); } } } ``` 
\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.