[TUTORIAL] Custom brewing recipes (1.14/1.15)

Started by SomeoneElse on

Topic category: User side tutorials

Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] Custom brewing recipes (1.14/1.15)
Mon, 07/06/2020 - 18:56 (edited)

This tutorial will explain how to add brewing recipes, but it'll use custom code

In the images, you might see Object obj = and obj =, but they aren't necessary

Before we start...

If you made a custom potion element, make sure to enable the potion effect bottles, or you won't be able to brew them
 

Check if the bottles are enabled!

The actual tutorial

  1. Start by creating a custom code element. You can remove some parts, because they won't be neededA new custom code element

     

  2. Copy these lines of code inside the init method, then press ctrl+w:
    try {
        Class clazz = net.minecraft.potion.PotionBrewing.class;
        Method mth = ObfuscationReflectionHelper.findMethod(clazz, "func_193357_a", Potion.class, 
    Item.class, Potion.class);
        mth.invoke(null, basePotion, ingredient, resultPotion);
        // To add more recipes, you can copy the line above, for ex.
        // mth.invoke(null, potion2, item2, potion3);
    } catch (Throwable e) {
        System.err.println("ERROR: " + e); // You can change this part
    }

    The final result should look like this:
     

    Code after pasting

     

  3. To actually add a brewing recipe, you'll have to replace basePotion and resultPotion with the starting and resulting potions, and ingredient with an item:

    • To add a vanilla potion, type Potions , then press ctrl+w. Type . after Potions, and the editor should show you the vanilla potions. For example, Potions.AWKWARD is the awkward potion, while Potions.LONG_SWIFTNESS is the extended potion of speed

    • To add your custom potions, type the name of your potion element, followed by Potion.potionType, then press ctrl+w. For example, if you made a potion element named "Invincibility", you'll have to type InvincibilityPotion.potionType

    • To use vanilla items and blocks as an ingredient, type Items, then press ctrl+w. Add a . after Items, and the editor should now show you the vanilla items and blocks. For example, to use cobblestone, you'll have to type Items.COBBLESTONE, while for redstone dust it's Items.REDSTONE

    • To use modded items/foods, type the name of your element, followed by Item.block, then press ctrl+w. For example, if your item element is named MagicDust, you'll have to type MagicDustItem.block

    • Finally, to use modded blocks/plants, type Item.getItemFromBlock(); inside the (), type the name of your element, followed by Block.block, then press ctrl+w. For example, if your block element is named SeaGravel, you'll have to type Item.getItemFromBlock(SeaGravelBlock.block)

      This is what your element should look like after adding a brewing recipe

      After adding one recipe

       

  4. To add more brewing recipes, you don't have to create other custom elements. You can copy the line that starts with mth.invoke and change the potions and item. For example, here I added another recipe that turns potions of regeneration into thick potions

    Adding a second brewing recipe

     

 

Edited by SomeoneElse on Mon, 07/06/2020 - 18:56
Joined Jun 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you add Brewing Recipe…
Thu, 07/02/2020 - 13:54

Can you add Brewing Recipe with this, Klemen?

Joined Jun 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
this is super helpful  
Thu, 07/02/2020 - 23:16

this is super helpful

 

Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
not work :(
Sat, 07/25/2020 - 17:15

not work :(

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Check for typos. I spend…
Thu, 08/13/2020 - 18:18

Check for typos. I spend half an hour freaking out and attempting to debug mine when it didn't work, only to discover I had spelt "AWKWARD" as "AKWARD"

Joined Feb 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The item I had as the…
Fri, 08/14/2020 - 04:21

The item I had as the ingredient wouldn't go in the brewing stand.

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The items brewed need to…
Sat, 08/15/2020 - 04:43

The items brewed need to potions? Can I brew food or drinks, maybe something else?

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I followed the instructions…
Tue, 09/22/2020 - 04:40

I followed the instructions exactly to try and create a recipe for my flight potion, but when i try to run the game it gives me a cannot find symbol error with an arrow pointing towards the f in flight. Maybe it has to do with the fact that when i type in the fli in flight it automatically fills it in to FlintAndSteelItem. Can anyone help?

Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Are you sure you're in 1.14…
Tue, 09/22/2020 - 08:44

Are you sure you're in 1.14.4 or 1.15.2? And have you tried to do ctrl+w or command+w in the editor for it to automatically get the imports? And if your answers are yes, plz send a picture of your code.

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm in 1.15.2 and yes, i…
Tue, 09/22/2020 - 15:30

I'm in 1.15.2 and yes, i tried ctrl+w. It didn't work. Here's my code:

/**
 * This mod element is always locked. Enter your code in the methods below.
 * If you don't need some of these methods, you can remove them as they
 * are overrides of the base class AdvancedBrewingModElements.ModElement.
 *
 * You can register new events in this class too.
 *
 * As this class is loaded into mod element list, it NEEDS to extend
 * ModElement class. If you remove this extend statement or remove the
 * constructor, the compilation will fail.
 *
 * If you want to make a plain independent class, create it using
 * Project Browser - New... and make sure to make the class
 * outside net.mcreator.advancedbrewing as this package is managed by MCreator.
 *
 * If you change workspace package, modid or prefix, you will need
 * to manually adapt this file to these changes or remake it.
*/
package net.mcreator.advancedbrewing;

import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;

import net.minecraft.potion.Potions;
import net.minecraft.potion.Potion;
import net.minecraft.item.Items;
import net.minecraft.item.Item;

import net.mcreator.advancedbrewing.potion.FlightPotion;

import java.lang.reflect.Method;

@AdvancedBrewingModElements.ModElement.Tag
public class BrewingRecipes extends AdvancedBrewingModElements.ModElement {
	/**
	 * Do not remove this constructor
	 */
	public BrewingRecipes(AdvancedBrewingModElements instance) {
		super(instance, 3);
	}

	@Override
	public void init(FMLCommonSetupEvent event) {
		try {
			Class clazz = net.minecraft.potion.PotionBrewing.class;
			Method mth = ObfuscationReflectionHelper.findMethod(clazz, "func_193357_a", Potion.class, Item.class, Potion.class);
			mth.invoke(null, Potions.AWKWARD, Items.FEATHER, FlightPotion.potiontype);
			// To add more recipes, you can copy the line above, for ex.
			// mth.invoke(null, potion2, item2, potion3);
		} catch (Throwable e) {
			System.err.println("ERROR: " + e); // You can change this part
		}
	}
}

 

Joined Jun 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You may need to replace …
Tue, 09/22/2020 - 17:36

You may need to replace "FlightPotion.potiontype" by "FlightPotionPotion.potionType"
The Java code is cap sensitive that's why it has to be "potionType" instead of "potiontype" and then, don't forget to do ctrl+w before saving the code to make sure you have all the imports.

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That worked. Thanks!
Wed, 09/23/2020 - 03:38

That worked. Thanks!

Joined Feb 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi! I'm having trouble…
Thu, 10/15/2020 - 05:55

Hi! I'm having trouble adding in my brewing recipe. I've actually put it in, the code throws no errors or anything, but the problem arises when I try to test it out in-game. I can't use the items I would like inside the brewing stand; it won't let me put them into the slots.

Inside the potion slot, I'm just hoping to have a glass bottle. Not a water bottle, an empty glass. I've tried "Potions.EMPTY" and "Items.GLASS_BOTTLE," and neither are accepted into the potion slot. How would I alter the glass bottle item (or the brewing stand GUI, if necessary) to allow me to do this?

Inside the ingredient slot, I'm hoping to put a modded item called Bismuth Chunk. I've put in "BismuthChunkItem.block" and it throws no errors, but I can't actually put the item into the slot for whatever reason. Does it have to do with it not being inside the Potions tab inside the creative inventory? Is it an item tag or something I need to change within the GUI of the brewing stand?

I really appreciate any help you can provide.

Joined Apr 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think that the brewing…
Thu, 12/31/2020 - 00:00

I think that the brewing stand GUI isn't programmed to be able to hold glass bottles in the potion slots. Sorry I can't help.