tutorial:potions
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
tutorial:potions [2023/05/06 02:12] – created pandoricavi | tutorial:potions [2023/09/10 07:08] (current) – [Introduction] drakonkinst | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Adding Potions | + | ====== Adding Potions ====== |
==== Introduction ==== | ==== Introduction ==== | ||
- | Adding a custom potion is | + | Adding |
+ | |||
+ | Minecraft automatically creates splash and lingering potions of any potion you register, so you only need to make the base potion. Minecraft also automatically creates textures for your potion, so you don't need to worry about that either. | ||
+ | |||
+ | === The BrewingRecipeRegistryMixin === | ||
+ | |||
+ | As of 1.20.1, Fabric API makes the methods for registering custom brewing recipes public. Therefore you can call `BrewingRecipeRegistry.registerPotionRecipe` directly, and do not need this mixin. | ||
+ | |||
+ | For older versions, this is a mixin you will need to add to your mod in order for your custom potion recipes to register correctly. | ||
+ | |||
+ | <code java [enable_line_numbers=" | ||
+ | @Mixin(BrewingRecipeRegistry.class) | ||
+ | public interface BrewingRecipeRegistryMixin { | ||
+ | |||
+ | @Invoker(" | ||
+ | static void invokeRegisterPotionRecipe(Potion input, Item item, Potion output){ | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Creating and Registering a Potion ==== | ||
+ | |||
+ | Here is an example of a custom potion class, called '' | ||
+ | |||
+ | <code java [enable_line_numbers=" | ||
+ | public class ModPotions { | ||
+ | |||
+ | public static final Potion EXAMPLE_POTION = | ||
+ | Registry.register(Registry.POTION, | ||
+ | new Potion(new StatusEffectInstance(StatusEffects.WITHER, | ||
+ | |||
+ | public static void registerPotions(){ | ||
+ | |||
+ | } | ||
+ | |||
+ | public static void registerPotionsRecipes(){ | ||
+ | BrewingRecipeRegistryMixin.invokeRegisterPotionRecipe(Potions.AWKWARD, | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | " | ||
+ | |||
+ | " | ||
+ | |||
+ | " | ||
+ | |||
+ | Once you have created your custom potion instance, you can call the potion and its recipe is '' | ||
+ | |||
+ | <code java [enable_line_numbers=" | ||
+ | public class ExampleMod implements ModInitializer { | ||
+ | |||
+ | @Override | ||
+ | public void onInitialize() { | ||
+ | ModPotions.registerPotions(); | ||
+ | ModPotions.registerPotionRecipes(); | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Creating a Custom Extended Potion ==== | ||
+ | |||
+ | Let's say you want to create an extended version of your custom potion. The process is very similar, with a few important changes. | ||
+ | |||
+ | <code java [enable_line_numbers=" | ||
+ | public class ModPotions { | ||
+ | |||
+ | public static final Potion LONG_EXAMPLE_POTION = | ||
+ | Registry.register(Registry.POTION, | ||
+ | new Potion(new StatusEffectInstance(StatusEffects.WITHER, | ||
+ | |||
+ | public static void registerPotions(){ | ||
+ | |||
+ | } | ||
+ | |||
+ | public static void registerPotionsRecipes(){ | ||
+ | BrewingRecipeRegistryMixin.invokeRegisterPotionRecipe(ModPotions.EXAMPLE_POTION, | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | In this example, I changed the duration of the potion to 9600 ticks, which is 8 minutes. This is the standard length of extended potions. Our recipe has also changed. The input potion is now the first custom potion we created. The input item of redstone is the typical item used to brew extended potions. The output potion is the extended custom potion. | ||
+ | |||
+ | ==== Creating a Potion with Custom Effects ==== | ||
+ | |||
+ | Creating | ||
+ | |||
+ | <code java [enable_line_numbers=" | ||
+ | public class ModPotions { | ||
+ | |||
+ | public static final Potion CUSTOM_POTION = | ||
+ | Registry.register(Registry.POTION, | ||
+ | new Potion(new StatusEffectInstance(ModEffects." | ||
+ | |||
+ | public static void registerPotions(){ | ||
+ | |||
+ | } | ||
+ | |||
+ | public static void registerPotionsRecipes(){ | ||
+ | BrewingRecipeRegistryMixin.invokeRegisterPotionRecipe(Potions.AWKWARD, | ||
+ | } | ||
+ | } | ||
+ | </ |
tutorial/potions.1683339130.txt.gz · Last modified: 2023/05/06 02:12 by pandoricavi