Jump to content

Brewing Recipe Help [1.10.2]


minh2908

Recommended Posts

My system works fine but i can brew a resistance potion with a resistance potion. Any help?

Here is the class that extends IBrewingRecipe:

 

public class PotionRecipe implements IBrewingRecipe{

 

private ItemStack input;

private ItemStack ingredient;

private ItemStack output;

 

public PotionRecipe(ItemStack input, ItemStack ingredient, ItemStack output) {

this.input = input;

this.ingredient = ingredient;

this.output = output;

}

 

@Override

public boolean isInput(ItemStack input2) {

if(!input2.hasTagCompound())

return false;

return PotionUtils.getPotionFromItem(input2)==PotionUtils.getPotionFromItem(this.input);

}

 

@Override

public boolean isIngredient(ItemStack ingredient2) {

return ingredient2.getItem()==Items.REDSTONE  || ingredient2.getItem()==Items.GLOWSTONE_DUST || ingredient2.getItem()==Items.IRON_INGOT||ingredient2.getItem()==Items.FERMENTED_SPIDER_EYE;

}

 

@Override

public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) {

 

if(ingredient2 != null && input2 != null && isIngredient(ingredient2))  {

ItemStack output2 = this.output.copy();

if (input2 != output2)

{

return output2;

}

return null;

}

else

return null;

}

 

}

 

How I register the recipes:

 

public void postInit(FMLPostInitializationEvent event)

  {BrewingRecipeRegistry.addRecipe(new PotionRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), CustomPotionTypes.resistance), new ItemStack(Items.FERMENTED_SPIDER_EYE,1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), CustomPotionTypes.weakening)));

    BrewingRecipeRegistry.addRecipe(new PotionRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), PotionTypes.AWKWARD), new ItemStack(Items.IRON_INGOT,1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM,1), CustomPotionTypes.resistance)));

 

    }

 

Link to comment
Share on other sites

In get output you never check if input2 is input. And honestly forge why would you just check to see if the item is the same when you should be comparing ItemStacks.....

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Note these edits work for me.

 

           // This
   @Override
   public boolean isInput(ItemStack input2) {
      if(!input2.hasTagCompound())
         return false;
      return PotionType.getPotionTypeForName(input2.getTagCompound().getString("Potion")) == PotionType.getPotionTypeForName(input.getTagCompound().getString("Potion"));
   }
           // And this
   @Override
   public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) {
	   if(ingredient2 != null && input2 != null && isIngredient(ingredient2))  {
		   ItemStack output2 = this.output.copy();
		   if (input2 != output2 && isInput(input2)) {
			   return output2;
		   } return null;
	   }  else
		   return null;
   }

 

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

That doesn't seems to solve the problem. I'm pretty sure that the check that you edit didn't change anything.The isInput was my fault ,though ;D. The problem with the system is that even though iron ingot brew the resistance one and fermented spider eye brews the resistance potion to the weakening one, the iron ingot still brew the resistance potion to itself.

Link to comment
Share on other sites

I assume you mean the potiontypes:

 

public class CustomPotionTypes {

public static PotionType resistance;

public static PotionType weakening;

public static void init(){

resistance= GameRegistry.register(new PotionType(new PotionEffect(MobEffects.RESISTANCE, 1800)).setRegistryName("resistance"));

weakening= GameRegistry.register(new PotionType(new PotionEffect(CustomPotion.weakening, 1800)).setRegistryName("weakening"));

}}

 

In the Mod file:

public void preInit(FMLPreInitializationEvent event)

    {

    CustomPotionTypes.init();

   

            }

 

 

Link to comment
Share on other sites

 

package minh2908.ores.init.potion;

 

import net.minecraft.init.Items;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.PotionType;

import net.minecraftforge.common.brewing.IBrewingRecipe;

 

public class PotionRecipe implements IBrewingRecipe{

 

private ItemStack input;

private ItemStack ingredient;

private ItemStack output;

 

public PotionRecipe(ItemStack input, ItemStack ingredient, ItemStack output) {

this.input = input;

this.ingredient = ingredient;

this.output = output;

}

 

@Override

public boolean isInput(ItemStack input2) {

if(!input2.hasTagCompound())

return false;

return PotionType.getPotionTypeForName(input2.getTagCompound().getString("Potion")) == PotionType.getPotionTypeForName(input.getTagCompound().getString("Potion"));

  }

 

@Override

public boolean isIngredient(ItemStack ingredient2) {

return ingredient2.getItem()==Items.REDSTONE  || ingredient2.getItem()==Items.GLOWSTONE_DUST || ingredient2.getItem()==Items.IRON_INGOT||ingredient2.getItem()==Items.FERMENTED_SPIDER_EYE;

}

 

@Override

public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) {

 

if(ingredient2 != null && input2 != null && isIngredient(ingredient2))  {

ItemStack output2 = this.output.copy();

if (input2 != output2 && isInput(input2))

{

return output2;

}

return null;

}

else

return null;

}

 

}

 

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.