Jump to content

[SOLVED][1.9.4] Using potions in brewing recipes


JimiIT92

Recommended Posts

I was trying adding a new brewing recipe for a potion i made. The idea is that adding coal in the brewing stand to a potion of poison will give the new potion. However the brewing process doesn't start (but it start if i remove the metadata value, so with a generic potion it works). The code i'm using is this

	BrewingRecipeRegistry.addRecipe(new ItemStack(Items.POTIONITEM, 1, PotionType.getID(PotionTypes.POISON)), new ItemStack(Items.COAL, 1, 0), new ItemStack(MWItems.wither_potion, 1));

But as i said it doesn't work :/ So how can i use the potion of poison in this recipe?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

Creating a new PotionType adds a new potion to the game (wich i used to add the wither and levitation potion). But in crafting i want that only if the poison potion with 45 seconds duration is in the brewing stand the process can start. If there is a poison 2 potion the brewing must give a different result. I've tried doing this

public static PotionType poison;
poison = new PotionType(new PotionEffect(MobEffects.POISON, 900)).setRegistryName("poison");
GameRegistry.register(poison);

 

but instead it adds a new poison 1 potion to the game with 45 second duration.

 

So i've tried doing this

BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), new PotionType(new PotionEffect(MobEffects.POISON, 900))), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither));

But i can still brew the wither potion using the poison 2 potion as base

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

Wich is what i've done. The fact is that the crafting recipe doesn't work. Here is a video explaining what happens now

 

And these are all the brewing recipes i add

package com.mineworld.crafting;

import com.mineworld.core.MWBlocks;
import com.mineworld.core.MWItems;
import com.mineworld.core.MWPotions;

import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class CraftingPotions {

public CraftingPotions() {

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), PotionTypes.POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), PotionTypes.LONG_POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), PotionTypes.STRONG_POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither2));

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), PotionTypes.POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), PotionTypes.LONG_POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), PotionTypes.STRONG_POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither2));

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), PotionTypes.POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), PotionTypes.LONG_POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.long_wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), PotionTypes.STRONG_POISON), new ItemStack(Items.COAL, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither2));

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither), new ItemStack(Items.REDSTONE, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither), new ItemStack(Items.REDSTONE, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither), new ItemStack(Items.REDSTONE, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.long_wither));

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither), new ItemStack(Items.GLOWSTONE_DUST, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither2));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_wither), new ItemStack(Items.GLOWSTONE_DUST, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither2));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither), new ItemStack(Items.GLOWSTONE_DUST, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither2));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_wither), new ItemStack(Items.GLOWSTONE_DUST, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither2));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither), new ItemStack(Items.GLOWSTONE_DUST, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither2));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.long_wither), new ItemStack(Items.GLOWSTONE_DUST, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither2));

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_wither), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither2), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither2));

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_wither), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.long_wither));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither2), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither2));


	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), PotionTypes.WATER), new ItemStack(Items.FEATHER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.levitation));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.levitation), new ItemStack(Items.REDSTONE, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_levitation));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.levitation), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.levitation));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_levitation), new ItemStack(Items.GUNPOWDER, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_levitation));

	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.levitation), new ItemStack(Items.DRAGON_BREATH, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.levitation));
	BrewingRecipeRegistry.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_levitation), new ItemStack(Items.DRAGON_BREATH, 1, 0), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.long_levitation));
}
}

 

Also these are the PotionTypes declared

public static PotionType wither;
public static PotionType long_wither;
public static PotionType wither2;

public static PotionType levitation;
public static PotionType long_levitation;

wither = new PotionType(new PotionEffect(MobEffects.WITHER, 900)).setRegistryName("wither");
	long_wither = new PotionType(new PotionEffect(MobEffects.WITHER, 1800)).setRegistryName("long_wither");
	wither2 = new PotionType(new PotionEffect(MobEffects.WITHER, 420, 1)).setRegistryName("wither2");

	levitation = new PotionType(new PotionEffect(MobEffects.LEVITATION, 900)).setRegistryName("levitation");
	long_levitation = new PotionType(new PotionEffect(MobEffects.LEVITATION, 1800)).setRegistryName("long_levitation");

GameRegistry.register(wither);
	GameRegistry.register(long_wither);
	GameRegistry.register(wither2);

	GameRegistry.register(levitation);
	GameRegistry.register(long_levitation);

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

Ok, so i've added a custom implementation for the brewing recipe

package com.mineworld.crafting;

import com.mineworld.core.MWItems;

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

public class PotionRecipes implements IBrewingRecipe{

private ItemStack input;
private ItemStack ingredient;
private ItemStack output;

public PotionRecipes(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 input2.getTagCompound().getString("Potion").equals(this.input.getTagCompound().getString("Potion"));
}

@Override
public boolean isIngredient(ItemStack ingredient2) {
	return ingredient2.getItem().equals(Items.REDSTONE)  || ingredient2.getItem().equals(Items.GLOWSTONE_DUST) || ingredient2.getItem().equals(Items.COAL) || ingredient2.getItem().equals(MWItems.shulker_bullet);
}

@Override
public ItemStack getOutput(ItemStack input2, ItemStack ingredient2) {
	if(ingredient2 != null && input2 != null && isInput(input2) && isIngredient(ingredient2) && ingredient2.getItem().equals(this.ingredient.getItem())) {
		return this.output;
	}
	else
		return null;
}

}

 

And this is how i add potion recipes now

package com.mineworld.crafting;

import com.mineworld.core.MWBlocks;
import com.mineworld.core.MWItems;
import com.mineworld.core.MWPotions;

import net.minecraft.block.Block;
import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionUtils;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.fml.common.registry.GameRegistry;

public class CraftingPotions {

public CraftingPotions() {

	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), PotionTypes.POISON), new ItemStack(Items.COAL, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither)));
	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither), new ItemStack(Items.REDSTONE, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_wither)));
	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither), new ItemStack(Items.GLOWSTONE_DUST, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.wither2)));

	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither), new ItemStack(Items.REDSTONE, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_wither)));
	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither), new ItemStack(Items.GLOWSTONE_DUST, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.wither2)));

	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither), new ItemStack(Items.REDSTONE, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.long_wither)));
	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither), new ItemStack(Items.GLOWSTONE_DUST, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.wither2)));

	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), PotionTypes.AWKWARD), new ItemStack(MWItems.shulker_bullet, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.levitation)));
	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.levitation), new ItemStack(Items.REDSTONE, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM, 1), MWPotions.long_levitation)));

	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.levitation), new ItemStack(Items.REDSTONE, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION, 1), MWPotions.long_levitation)));

	BrewingRecipeRegistry.addRecipe(new PotionRecipes(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.levitation), new ItemStack(Items.REDSTONE, 1), PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION, 1), MWPotions.long_levitation)));
}
}

 

But in result of the brewing, if i use 2 or 3 base potions, only 1 of them is "valid". Sometimes i get the 0-stack item, sometimes the stack looks like a potion but when i click on it it disappear

Mw6RKjC.png

What could be the cause of this?

Don't blame me if i always ask for your help. I just want to learn to be better :)

Link to comment
Share on other sites

The 2nd ingredient check was used because i was able to brew a longer levitation potion with the same item, but i guess there's a better way to avoid this. So basically i should return a copy of the output stack?

 

EDIT: returning the copy of the stack has solved that problem. Thank you for the help :D

Don't blame me if i always ask for your help. I just want to learn to be better :)

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.