Potions/1.17

From Forge Community Wiki
Revision as of 05:51, 6 December 2021 by ShrimpBot (talk | contribs) (Copy Potions to MC1.17 archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

A Potion is simply a list of MobEffectInstances to be applied when used. Each Potion gets applied to every Items#POTION, Items#SPLASH_POTION, Items#LINGERING_POTION, and Items#TIPPED_ARROW. Like mob effects, potions need to be registered.

Creating a Potion

A Potion requires a passed in list of MobEffectInstances to apply to the player when the potion is "consumed". There is also a nullable parameter called name that can be set if you would like to use the same name for multiple potions (e.g. SWIFTNESS and LONG_SWIFTNESS can be both swiftness potions).

Adding a Brewing Recipe

Brewing Recipes can be added using BrewingRecipeRegistry::addRecipe. The most common constructor takes in an Ingredient input, an Ingredient reactant, and an ItemStack output. This can be registered during FMLCommonSetupEvent.

Important

If you want to use NBT information in your inputs (e.g. create a potion from another potion), you need to pass in an NBTIngredient instead.

Alert

BrewingRecipeRegistry is not thread-safe. It should be called within enqueueWork in the specified parallel dispatch event.