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:
The player should also unlock the recipe when picking up the 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.
public class Recipes
, but where are you doingnew Recipes("recipe")
? \$\endgroup\$GameRegistry.registerShapelessRecipe
in your mod's init function. \$\endgroup\$Recipes
class get used? \$\endgroup\$Recipes
\$\endgroup\$