Posted September 8, 20178 yr 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.
September 8, 20178 yr 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. 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. Am I doing something wrong with the first case?
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.