Jump to content

Issue with creating a brewing recipe


ScootMcShoot

Recommended Posts

I'm new to modding and I'm trying to make a brewing recipe that takes an "essence of undeath" and awkward potions to make "ink of innervation" items, but when I try this in-game I can't even place the essence in the brewing stand. What am I doing wrong?
 

public class ModRecipes
{
	public static void Init() {
		BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(ModItems.ESSENCE_OF_UNDEATH), new ItemStack(ModItems.INK_OF_INNERVATION));
	}
}

 

Link to comment
Share on other sites

Where do you call that method?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Oh, whoops. I forgot to initialize ModRecipes in main.java.... thanks for reminding me:

@EventHandler
	public static void init(FMLInitializationEvent  event)
	{
		ModRecipes.Init();
	}

Now everything ALMOST works perfectly; except now when I brew the recipe in-game, every single type of potion will work in the recipe, not just awkward potions. Any ideas how to fix this?

Link to comment
Share on other sites

Ok so I found a previous thread about this same issue, except the person didn't explicitly state in code how to remedy this issue.

He said he "extended AbstractBrewingRecipe and overrode isInput so the stack comparison is nbt and meta data sensitive".

 

@Override
    public boolean isInput(@Nonnull ItemStack stack)
    {
        return OreDictionary.itemMatches(this.getInput(), stack, false);
    }

This is the code in question. How would I manipulate this to allow nbt/meta data?

Link to comment
Share on other sites

Alright, so I added some code to isInput to account for nbt data... except it didn't change anything. In fact, randomly switching around the boolean values for isIngredient and isInput doesn't cause any changes whatsoever for the recipe in-game. Maybe I'm just a clueless noob, but i feel thoroughly stumped right now. Does anyone know what I'm doing wrong? 

package com.ScootMcShoot.scootsnecromancymod.init;

import javax.annotation.Nonnull;

import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.AbstractBrewingRecipe;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.oredict.OreDictionary;

public class ModRecipes extends AbstractBrewingRecipe
{
	protected ModRecipes(ItemStack input, Object ingredient, ItemStack output) {
		super(input, ingredient, output);
	}
	
	public static void Init() {
		BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(ModItems.ESSENCE_OF_UNDEATH), new ItemStack(ModItems.INK_OF_INNERVATION));
	}

	@Override
	public boolean isIngredient(ItemStack ingredient) {
		return false;
	}
	
	@Override
    public boolean isInput(@Nonnull ItemStack stack)
    {
		if (stack.getTagCompound() == (PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD)).getTagCompound())
			return OreDictionary.itemMatches(this.getInput(), stack, false);
		else
			return false;
    }
}

 

Link to comment
Share on other sites

Ok then, I made a new class for my recipe. Although the code is essentially the same, and nothing new happened, so I don't see what the point of that was.

 

package com.ScootMcShoot.scootsnecromancymod.init;

import javax.annotation.Nonnull;

import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.AbstractBrewingRecipe;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.oredict.OreDictionary;

public class BrewingRecipeInk extends AbstractBrewingRecipe
{

	protected BrewingRecipeInk(ItemStack input, Object ingredient, ItemStack output) {
		super(input, ingredient, output);
	}

	public static void init() 
	{
		BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(ModItems.ESSENCE_OF_UNDEATH), new ItemStack(ModItems.INK_OF_INNERVATION));
	}

	@Override
	public boolean isIngredient(ItemStack ingredient) {
		return false;
	}
	
	@Override
    public boolean isInput(@Nonnull ItemStack stack)
    {
		if (stack.getTagCompound() == (PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD)).getTagCompound())
			return OreDictionary.itemMatches(this.getInput(), stack, false);
		else
			return false;
    }
}

 

If you could be as specific as possible with what I need to do that would be greatly appreciated.

Link to comment
Share on other sites

All you did was rename ModRecipes to BrewingRecipeInk(efectively). That does nothing.

You still have the same issue. You can have a million and one classes all extending AbstractBrewingRecipe but if the recipe being registered is not an instance of any of them then they do nothing.

The recipe you register needs to be the one that extends AbstractBrewingRecipe, not some random irrelevant class.

Link to comment
Share on other sites

How am I supposed to extend 

public static void init() 
	{
		BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(ModItems.ESSENCE_OF_UNDEATH), new ItemStack(ModItems.INK_OF_INNERVATION));
	}

with AbstractBrewingRecipe? All I have is that statement, but it's not a class, and I can't extend it if it's not a class. Therefore I assumed you meant I needed to make a new class for my recipe, but like both of us said, that changes nothing. Please don't repeat what you said again for the third time, that doesn't help me. Thank you for your patience.

Link to comment
Share on other sites

What you need to do, is create a new Class, let's say you call it MyCustomRecipe. That class then needs to extend AbstractBrewingRecipe, and override the isIngredient (and in your case, the isInput) methods. Then, instead of doing this:

BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), new ItemStack(ModItems.ESSENCE_OF_UNDEATH), new ItemStack(ModItems.INK_OF_INNERVATION));

you do the following:

BrewingRecipeRegistry.addRecipe(MyCustomRecipe);

 

Edited by Messiah_Of_Doom
Formatting
Link to comment
Share on other sites

Doesn't work. There's an error at 

BrewingRecipeRegistry.addRecipe(MyCustomRecipe);

 that says "MyCustomRecipe cannot be resolved to a variable" and it doesn't give me the option to import it.

package com.ScootMcShoot.scootsnecromancymod.init.recipes;

import javax.annotation.Nonnull;

import com.ScootMcShoot.scootsnecromancymod.init.ModItems;

import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.AbstractBrewingRecipe;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.common.brewing.IBrewingRecipe;
import net.minecraftforge.oredict.OreDictionary;

public class MyCustomRecipe extends AbstractBrewingRecipe 
{

	public MyCustomRecipe (ItemStack input, ItemStack ingredient, ItemStack output) {
		super(input = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), ingredient = new ItemStack(ModItems.ESSENCE_OF_UNDEATH), output = new ItemStack(ModItems.INK_OF_INNERVATION));
	}
    
	@Override
	public boolean isIngredient(ItemStack ingredient) {
		return false;
	}
	
	@Override
    public boolean isInput(@Nonnull ItemStack stack)
    {
		if (stack.getTagCompound() == (PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD)).getTagCompound())
			return OreDictionary.itemMatches(this.getInput(), stack, false);
		else
			return false;
    }
}
package com.ScootMcShoot.scootsnecromancymod.init;

import javax.annotation.Nonnull;

import com.ScootMcShoot.scootsnecromancymod.init.recipes.MyCustomRecipe;

import net.minecraft.item.ItemStack;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;

public class ModRecipes
{
	public static void init()
	{
		BrewingRecipeRegistry.addRecipe(MyCustomRecipe);
	}
}

 

Link to comment
Share on other sites

4 hours ago, ScootMcShoot said:

public MyCustomRecipe (ItemStack input, ItemStack ingredient, ItemStack output) 

 

4 hours ago, ScootMcShoot said:

BrewingRecipeRegistry.addRecipe(MyCustomRecipe);

You need to create a new custom recipe to register...

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Yeah, sorry about that, I realize i shouldn't try to answer coding questions when I haven't slept in over 48 hours ^^. Anyways, you need to do what Cadiboo said, instead of my originally proposed 

BrewingRecipeRegistry.addRecipe(MyCustomRecipe);

you need to do

BrewingRecipeRegistry.addRecipe(new MyCustomRecipe(stack1, stack2, stack3));

where stack1-3 are your desired Inputs / Outputs. Again, sorry for any confusion I may have caused

Edited by Messiah_Of_Doom
Formatting (again), also word choice
Link to comment
Share on other sites

You know, if they write code like that

6 hours ago, ScootMcShoot said:

BrewingRecipeRegistry.addRecipe(MyCustomRecipe);

 and complain about basic syntax errors they should be probably told to go and learn java. Not to be arrogant or anything but if you just throw ready-to-use solutions at them they won't learn and will come back here with a similar problem in a day or so. The purpose of the forums is not to give people code they can just copy-paste without thinking about it.

Link to comment
Share on other sites

Oh my god it finally works and I'm so happy. So for some reason the comparison in isInput using the .getCompoundTag() method didn't work, but luckily I found another method .areItemStackTagsEqual() that solves my issue perfectly. Posting my updated code in case anyone else has the same problem.

 

package com.ScootMcShoot.scootsnecromancymod.init.recipes;

import javax.annotation.Nonnull;

import com.ScootMcShoot.scootsnecromancymod.init.ModItems;

import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.AbstractBrewingRecipe;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.common.brewing.IBrewingRecipe;
import net.minecraftforge.oredict.OreDictionary;

/* This class allows BrewingRecipeRegistry to accept NBT data assuming the input and ingredient are added to this class,
 * which fixes a bug that allowed any potion type (including water bottles), regardless of what was set in the recipe, 
 * to be brewed into the resulting potion. */

public class FixedAbstractBrewingRecipe extends AbstractBrewingRecipe 
{
	public FixedAbstractBrewingRecipe (ItemStack input, ItemStack ingredient, ItemStack output) {
		super(input, ingredient, output);
	}
    
	@Override
	public boolean isIngredient(ItemStack ingredient) {
		if (ingredient.getItem() == ModItems.ESSENCE_OF_UNDEATH)
			return true;
		else
		    return false;
	}
	
	@Override
    public boolean isInput(@Nonnull ItemStack stack) {	
		if (stack.areItemStackTagsEqual(stack, (PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD))))
			return OreDictionary.itemMatches(this.getInput(), stack, false);
		else
			return false;
    }
}

 

package com.ScootMcShoot.scootsnecromancymod.init;

import javax.annotation.Nonnull;

import com.ScootMcShoot.scootsnecromancymod.init.recipes.FixedAbstractBrewingRecipe;

import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;

public class ModRecipes
{
	public static void init()
	{
		// Brewing Recipes
		
		// Ink of Innervation
		ItemStack input = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD);
		ItemStack ingredient = new ItemStack(ModItems.ESSENCE_OF_UNDEATH);
		ItemStack output = new ItemStack(ModItems.INK_OF_INNERVATION);
		
		BrewingRecipeRegistry.addRecipe(new FixedAbstractBrewingRecipe(input, ingredient, output));
		
	}
}

 

Thank you so much for your help everyone, I feel like I learned a lot.

Link to comment
Share on other sites

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Kocok303 adalah bocoran slot rekomendasi gacor dari Kocok303 yang bisa anda temukan di SLOT Kocok303. Situs SLOT Kocok303 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Kocok303 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Kocok303 merupakan SLOT Kocok303 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Kocok303. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Kocok303 hari ini yang telah disediakan SLOT Kocok303. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Kocok303 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Kocok303 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Kocok303 di link SLOT Kocok303.
  • Topics

×
×
  • Create New...

Important Information

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