Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I've started to learn how to make mods for 1.12 recently and I'm doing my best to learn, discover by myself and use the Forge's best practices as much as I can. Currently I'm learning how to make potions and I have two questions that I seem unable to find the answers anywhere on the internet.

 

  • Is there any event to register brewing recipes? AFAIK the current approach is to call BrewingRecipeRegistry.addRecipe() on preinit. This works fine but the Forge docs strongly recommends to use events to register stuff in Minecraft.

 

For creating new brewing recipes I've run into a problem where the brewing stand could accept any potion bottle type (even filled with water or another potion) using the BrewingRecipe class. AFAIK since Minecraft 1.9 potion bottles no longer store its effects in the Damage property (metadata) but instead they store it in a NBT tag. I realized that BrewingRecipe compares the input items by instance and its Damage value but not with NBT tags, so to solve my problem I extended BrewingRecipe class to override isInput() with the following code:

@Override
public boolean isInput(@Nonnull ItemStack stack) {
	return ItemStack.areItemStacksEqualUsingNBTShareTag(stack, getInput());
}

And that seems to work fine. Now the question is:

 

  • Is there any class that does the same thing as I do? I've checked all implementations of IBrewingRecipe but none of them do what I want.
4 hours ago, diesieben07 said:

This is vanilla behavior, Forge does not change this. Changing it would not really make sense anyways, some potions require multiple brewings, so the input must accept other potions.

I think I did not clarify well, sorry. I have created a "madness" potion and I want to be able to brew a madness splash potion from an awkward splash potion using a tomato as an ingredient. The implementation with BrewingRecipe is as follows:

...

@Override
public void registerBrewingRecipes() {
  ItemStack input = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), PotionTypeTesting.REGISTRY.getObject(new ResourceLocation("awkward")));
  ItemStack ingredient = new ItemStack(Items.TOMATO);
  ItemStack output = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), PotionTypeMadness.INSTANCE);

  BrewingRecipeRegistry.addRecipe(new BrewingRecipe(input, ingredient, output));
}

...

Now in a brewing stand if we put the tomato, an awkward potion, a potion of leaping and a potion of fire resistance it will convert every potion into a madness splash potion. And it also keeps brewing until the ingredient is ran out.

 59b2dc11732c6_brewingwithBrewingRecipe.png.95f52b7083031652346e42aea1c2cf13.png

 

 

Now using my custom class:

...

@Override
public void registerBrewingRecipes() {
  ItemStack input = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), PotionTypeTesting.REGISTRY.getObject(new ResourceLocation("awkward")));
  ItemStack ingredient = new ItemStack(Items.TOMATO);
  ItemStack output = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), PotionTypeMadness.INSTANCE);

  BrewingRecipeRegistry.addRecipe(new CustomBrewingRecipe(input, ingredient, output));
}

class CustomBrewingRecipe extends BrewingRecipe {

    public CustomBrewingRecipe(@Nonnull ItemStack input, @Nonnull ItemStack ingredient, @Nonnull ItemStack output) {
        super(input, ingredient, output);
    }

    @Override
    public boolean isInput(@Nonnull ItemStack stack) {
        return ItemStack.areItemStacksEqualUsingNBTShareTag(stack, getInput());
    }
}

...

With the same case as before now it only converts the awkward splash potion into the correct potion I want, it doesn't touch any other potion and it stops brewing when appropriate.

59b2dcf4c8f17_brewingwithCustomBrewingRecipe.png.f44a6f82ee749dfd8284075c71f67f01.png

 

Am I doing something wrong with the first case?

Thank you very much :))

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.