Difference between revisions of "Potions"

From Forge Community Wiki
(Inital Import dokuwiki)
 
(Update to 1.17)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A <code>Potion</code> is simply a list of <code>Effect</code>s to be applied when used. Each <code>Potion</code> gets applied to every <code>Items#POTION</code>, <code>Items#SPLASH_POTION</code>, <code>Items#LINGERING_POTION</code>, and <code>Items#TIPPED_ARROW</code>. Like effects, potions need to be [[Registration|registered]].
+
A <code>Potion</code> is simply a list of <code>MobEffectInstance</code>s to be applied when used. Each <code>Potion</code> gets applied to every <code>Items#POTION</code>, <code>Items#SPLASH_POTION</code>, <code>Items#LINGERING_POTION</code>, and <code>Items#TIPPED_ARROW</code>. Like mob effects, potions need to be [[Registration|registered]].
  
 
== Creating a <code>Potion</code> ==
 
== Creating a <code>Potion</code> ==
  
A <code>Potion</code> requires a passed in list of <code>EffectInstance</code>s to apply to the player when the potion is "consumed". There is also a nullable parameter called <code>baseName</code> that can be set if you would like to use the same name for multiple potions (e.g. a <code>SWIFTNESS</code> and <code>LONG_SWIFTNESS</code> entry can be both <code>swiftness</code> potions).
+
A <code>Potion</code> requires a passed in list of <code>MobEffectInstance</code>s to apply to the player when the potion is "consumed". There is also a nullable parameter called <code>name</code> that can be set if you would like to use the same name for multiple potions (e.g. <code>SWIFTNESS</code> and <code>LONG_SWIFTNESS</code> can be both <code>swiftness</code> potions).
  
 
== Adding a Brewing Recipe ==
 
== Adding a Brewing Recipe ==
Line 9: Line 9:
 
Brewing Recipes can be added using <code>BrewingRecipeRegistry::addRecipe</code>. The most common constructor takes in an <code>Ingredient</code> input, an <code>Ingredient</code> reactant, and an <code>ItemStack</code> output. This can be registered during <code>FMLCommonSetupEvent</code>.
 
Brewing Recipes can be added using <code>BrewingRecipeRegistry::addRecipe</code>. The most common constructor takes in an <code>Ingredient</code> input, an <code>Ingredient</code> reactant, and an <code>ItemStack</code> output. This can be registered during <code>FMLCommonSetupEvent</code>.
  
{{Colored box|title=Important|content=If you want to use NBT information in your inputs (e.g. create a potion from another potion), you need to pass in an <code>NBTIngredient</code> instead.}}
+
{{Tip/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 <code>NBTIngredient</code> instead.}}
  
 
{{Colored box|title=Alert|content=<code>BrewingRecipeRegistry</code> is '''not''' thread-safe. It should be called within <code>enqueueWork</code> in the specified parallel dispatch event.}}
 
{{Colored box|title=Alert|content=<code>BrewingRecipeRegistry</code> is '''not''' thread-safe. It should be called within <code>enqueueWork</code> in the specified parallel dispatch event.}}
 +
 +
 +
[[Category:Game Effects]]

Latest revision as of 21:14, 2 August 2021

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.