Hello guys and welcome back to the minecraft mod tutorial in today’s episode we’re going to go over custom potions so let’s get started first thing we’re going to need to do as always we’re going to create an image for this thing so go into in it and create a new Class called potion in it inside of here we’re here to Percy there’s two things really create one creating potions that’s the potion effect and the potion type potion effect is what’s going to give you all the properties that the potion gives you and the potion type is To do with get your bottle that you drink to get the potion so style the potion effect public a static file potion and is your potion effect obviously you can change your potion effect to whatever name you want and that’s equal to a new custom potion control shift over to import potion and Then we’re going to create this class put it inside of tutorial dot this will be a new package the obviously extends potion and we’re going to need to get the constructor in Lipson shop so we’re going to have some parameters the name of the potion string name a boolean to Tell if it’s a bad potion or not so if it gives you negative effects or positive effects so boolean is bad potion return true if it’s make negative effects in color so a hexadecimal or binary color that you’re gonna pop for the color of your potion int icon index X and I think that’s why and we’re going to super off of this bad potion and color then we’re going to set the potion name set a potion name quotation marks effect dot and then plus name as we set their potion to the effect dot and your potion or effect or whatever Then set icon index I’ll explain what this is in a minute but just said I kind X X & Y and then set the registry name to a new resource location reference time on ID + : + name then we one function here has status icon if you put Any things to do with GUI you’ll understand that we need to bind the texture so use minecraft dots it gets minecraft dots of gets texture manager dots it binds a texture new resource location reference to my G+ and then it’s going to be inside of textures GUI Potion effects dot PNG this is a file that contains all the images for when you have the potion active and the little images on the side that represents the potion effects and I will open this file up for you now it’s a 256 pattern 46 file and starting down here At 197 and each icon is 18 by 18 and it will appear when you have the potion active so you can use all of this space down here for different potion icons and then we have to return true here so this icon index refers to how many different Icons along your icon that you want for the potion is so that what along is X so if it is 4 across and you’d put 4 for this value and then 2 down would be – I don’t know it’d be 1 because we start from zero you know program languages so This will be 3 as we won but since this is the first icon and go back into the main class name it your potion it’s not about potions or false you can choose any color I’ve shown this book I’ve had before hexadecimal colors and so you can scroll Along here choose your color and then copy it and paste it into this file you’re here then it’s me zero and zero for the icon index as we are at the first icon and that is your potion created next we’re going to do the things called potion types this refers To the different bottles that you can get so you can get the default one you can get the increased duration one you can get different levels of it and so on and so forth for each version of the potion need to create a new potion type so public static final potion type your Potion is equal to a new potion type your potion and a new potion effect array a new potion effect you’re gonna want your potion effects and your on something the duration of it as well this is a number of ticks two thousand five hundred is two minutes at 1200 for One minute and so on and so forth so for the default normally it’s two minutes of 2400 and then you just set the register name at the end to be the same thing your potion and that is the default potion created and copy this paste it again and create the long Version call it long your potion this stays the same as your potion still we still keep the same effects can be twice as long at 4800 and we’re also gonna have the register name belong to your potion now we need to actually register the potions so we’re gonna need a few Different functions here the main function public static void register potions but for that we’re going to need another function private static voyage register potion it’s gonna have some parameters it’s going to have potion type default potion we need the potion type long potion and we need the potion Effect then we’re going to use fault registries for registries potions dot register effect files registries dots potion types dot register default potion and Ford registries dot potion types dot register long potion – all three they were registered and we can then call register potions out of register potions And choose your potion long your potion and your potion effects where you need to call a register potions inside of our handle registry handle potion in it dots rate of stir potions then the next thing you want to do and is thinking about brewing your potion itself this is going To be a functional another quantum in a crate private static void register potion mixes so one of them is going to be the same for everyone it’s going to be potion helper dot add mix job potion items redstone and long your potion as redstone as the ingredient extending the Length of all potion you’re also going to be able to create your potion so potion helper dot add mix and to choose a random potion that’s already by default so you could use the awkward potion which is better than just water potion types dot and lots of different Potions here it’s the awkward potion is the default one that all potions come from then you add an ingredient and so an item so you could do item in it and choose one of your items if you want I can choose an oil minecraft item and She’s Mike offering got cuz why not and then return your potion and then we just call this register potion mixes function at the bottom of register potions and that will create everything so your potion is now in the game but currently it won’t cause any effects there’s two Ways to cause effects the first thing is inside this class dot register potion attribute modifier and this is to do with changing the way the player does things and it’s how most our potions work to do with changing speed or other things so you shared monster attributes dots and then you can Change all of these different values you can call math helper dot generate random UUID dot – strength and that will just dinner and unique ID amount how much and this increases the current value choose a random value here it has to be a double so 3.0 double and operation this Is a value I’m not sure all it is you can just mess around with this value I’m not sure what it does but I’m gonna use two for this instance the other way of doing it is to go into our world event class I don’t think I have to create This on screen I basically just move the thing from Enchantment into world events and anything to do with the SUBSCRIBE event it isn’t registering so at subscribe event public static void your potion active so whatever potion name they’re active and you take in a player tick event you declare a billion and is Active is equal to false and then do if event dot player dot is potion active and then do potion in it dot your potion effect its active is equal to true then if is active then you can change any values in here you put in your code to Do things to the player when your potion is active so you can do so many different things you cannot live up to your imagination if you need help with anything that you’re coding you can just ask in my discard and I’m sure someone will try and help you with it I’m not gonna go over and specific in this video but there we are we have created our default potions resource is next going to source my resources the only thing you need to do for potions it’s the line which there’s five different things there got your potion potion defects that your Potion is the normal potion splash potion lingering potion and tipped arrow all those things you just label a name inside of en-us lung and then in textures GUI you put this potion effects dot PNG thing that I showed you earlier I’ll leave a template for you down below So you can also be available in my github for you to use so you can create your own different icons so now run the game so open creative inventory and go into the brewing section and but the bottom here you’ll find your potion of your potion the longer one and scroll Down a bit you’ll find the splash potions and the lingering potions and you’ll also find the arrow math happens to be the same color as your generation sorry about that but you obviously can choose a different color and if you take one out drink it And now as you can see we have a potion active and we have a little icon up in the top right and when you open it you get your potion with the icon and the time ticking down I don’t know how I’m gonna have to demonstrate what I’ve got Here and but your potion effect should also be working thanks for watching guys if you have enjoyed this video please hit like button down below and subscribe for more videos thanks for watching mine has been hairy and goodbye Video Information
This video, titled ‘Potions – Minecraft Modding Tutorial 1.12/1.13 – Episode 40’, was uploaded by Harry Talks on 2018-12-02 18:28:34. It has garnered 8654 views and 120 likes. The duration of the video is 00:12:13 or 733 seconds.
Custom Potions!
Links GitHub: https://github.com/HarryTechRevs/Minecraft-Modding-1.12 Discord: https://discordapp.com/invite/xwg8zQJ Playlist: https://www.youtube.com/playlist?list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR Subscribe: http://tiny.cc/sub2harrytech Twitter: https://twitter.com/harrystechrevs