Jump to content

Recommended Posts

Posted

I've run into a blockage when adding a new potion that is brewable. I know you have to use PotionBrewEvent, but I don't know the method name to use. I'm also a little confused by the comment lines in the PotionBrewEvent source file; how would I go about (for example) creating a potion that is brewed the same way as other potions except with <item> as the second stage ingredient?

 

To further the example, Water Bottle + Nether Wart = Awkward Potion --> Awkward Potion + <item> = Custom Potion --> Custom Potion + Redstone Dust = Custom Potion (extended duration). And of course, Custom Potion + Gunpowder = Splash Custom Potion.

Posted

It looks like you need to subscribe to PotionBrewEvent.Pre, check the input items with PotionBrewEvent#getItem, modify the output with PotionBrewEvent#setItem and then cancel the event. For the vanilla brewing stand, indexes 0-2 are the three input items (the potions to be converted) and index 3 is the ingredient item.

 

It may be easier to use Forge's brewing recipe system. You can use BrewingRecipeRegistry#addRecipe to add a brewing recipe for an input, ingredient and output or add an instance of IBrewingRecipe.

 

If you update to 1.10.2+, you can register PotionType conversions with the vanilla PotionHelper class.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted (edited)

Oh, I didn't know that BrewingRecipeRegistry existed. That does seem easier.

 

Though... how would I get the field of the custom potion if it's automatically created when I initialize the custom potion's class? Or do I have to create a field in ModItems, then somehow link it to the potion class?

 

EDIT: If I run setupDecompWorkspace from Forge 2228 gradle, will it corrupt or otherwise render my 1.8.9 workspace unusable? I'm gonna try to update to 1.11.2.

Edited by blahblahbal
Posted
38 minutes ago, blahblahbal said:

Though... how would I get the field of the custom potion if it's automatically created when I initialize the custom potion's class? Or do I have to create a field in ModItems, then somehow link it to the potion class?

 

In 1.8.9, create an ItemStack of Items.potionitem and set the "CustomPotionEffects" key of the stack compound tag to a list tag that contains a compound tag for each PotionEffect applied by the potion. You can use PotionEffect#writeCustomPotionEffectToNBT to write a PotionEffect to a compound tag. Set the metadata to 0x4000 (or any number that returns a non-zero result when bitwise AND-ed with 0x4000) to make it a splash potion.

 

In 1.11.2, create an ItemStack of Items.POTIONITEM, Items.SPLASH_POTION or Items.LINGERING_POTION and use PotionUtils.addPotionToItemStack to set the stack's PotionType.

 

 

38 minutes ago, blahblahbal said:

EDIT: If I run setupDecompWorkspace from Forge 2228 gradle, will it corrupt or otherwise render my 1.8.9 workspace unusable? I'm gonna try to update to 1.11.2.

 

No, you can have as many ForgeGradle workspaces as you want. I have a separate TestMod3 workspace for each Minecraft version, each of which is its own branch of the TestMod3 Git repository.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

So.. wait a minute, I have to have a PotionEffect extension as well? Or is that created with the custom potion class?

 

I'm just really confused by all this stuff. I want to add a Spelunker Potion (basically reveals ores), but now that I get into it it seems really complex in 1.8.9. No wonder there aren't any tutorials.

Posted (edited)
42 minutes ago, blahblahbal said:

So.. wait a minute, I have to have a PotionEffect extension as well? Or is that created with the custom potion class?

 

You don't need to extend PotionEffect, it works with any Potion (like ItemStack works with any Item). Just create an instance.

 

 

42 minutes ago, blahblahbal said:

I'm just really confused by all this stuff. I want to add a Spelunker Potion (basically reveals ores), but now that I get into it it seems really complex in 1.8.9. No wonder there aren't any tutorials.

 

The system became a lot simpler with the move from metadata bit-shifting in 1.8.9 and earlier to PotionTypes in 1.9.

Edited by Choonster

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

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.