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



×
×
  • Create New...

Important Information

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