Jump to content

Recommended Posts

Posted

Hello,

 

Does anyone find how to implement a brewing reciepe in 1.13.2 yet ? It doesn't seem to be in datapack, the fonction "addmix" in PotionBrewing class is now private, and IForgeRegistry doesn't work for this class (as it's neither Potion class, neither PotionType class)

 

Thank

Posted

ok ty :) i'll probably try to see if i can rewitre entirely the brewing_stand by now ^^ it's a lot of work for a tiny potion, but as long as it works as final ...

Posted (edited)
On 7/25/2019 at 3:17 PM, sunsigne said:

ok ty :) i'll probably try to see if i can rewitre entirely the brewing_stand by now ^^ it's a lot of work for a tiny potion, but as long as it works as final ...

Even if there is no way of adding a brewing recipe, there is reflection.

It would be better than copying & pasting an entire vanilla class and screwing all mods with custom brewing stands...

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Posted

Perfect ! I finally found out how to register potion recipes ! (thank to reflection)

 

for curious people, here is the solution :

Spoiler

In MAIN class :

 

public YourMainClass () {

FMLJavaModLoadingContext.get().getModEventBus().addListener(this::RegisterPlus);

}

 

private void RegisterPlus(final FMLCommonSetupEvent event)
        {
             
         try { RegisterPlus.addMix(PotionTypes.AWKWARD, Items.REDSTONE, ModPotionType.your_potion);
            } catch (Exception e) {    e.printStackTrace();}
       
        }

 

 

In a classe you called RegisterPlus :

 

public class RegisterPlus {

    
    public static void addMix(PotionType p_193357_0_, Item p_193357_1_, PotionType p_193357_2_) throws Exception {
        
        Method method = PotionBrewing.class.getDeclaredMethod("addMix", PotionType.class, Item.class, PotionType.class);
        method.setAccessible(true);
        method.invoke(null, p_193357_0_, p_193357_1_, p_193357_2_);
        }

}

Hope it will help someone ^^

  • sunsigne changed the title to 1.13.2 Alternative to PotionBrewing.addmix ? [SOLVED]
Posted

If you only need to use addMix there is also a non-reflection alternative that uses a brewing recipe via BrewingRecipeRegistry.addRecipe(...). Note there is a bug (1.14.3) in the Forge default BrewingRecipe so you should roll your own fixing the following in the isInput method like:

public class ModBrewingRecipe extends BrewingRecipe {
  public ModBrewingRecipe(ItemStack input, Ingredient ingredient, ItemStack output) {
    super(input,ingredient,output);
  }
  @Override
  public boolean isInput(ItemStack stack) {
    return ItemStack.areItemsEqual(super.getInput(),stack); //THIS IS BROKEN in super 1.14.3
  }
}

Pass in filled in potion itemstacks (see PotionUtils.addPotionToItemStack) for the input and outputs (eg Awkward potion -> Your potion)

Posted
9 hours ago, sunsigne said:

public static void addMix(PotionType p_193357_0_, Item p_193357_1_, PotionType p_193357_2_) throws Exception {
        
        Method method = PotionBrewing.class.getDeclaredMethod("addMix", PotionType.class, Item.class, PotionType.class);
        method.setAccessible(true);
        method.invoke(null, p_193357_0_, p_193357_1_, p_193357_2_);
        }

Reflection is expensive. Use it once and store the method in a static field.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

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.