Hey guys it’s thomas here with technovision and welcome to the next episode of our minecraft modding tutorial series for 1.15 in this episode we’re going to be covering custom food items as well as adding some custom effects to them when you eat them and i’m going to be moving a little bit Faster now because by this point i’m assuming that you’ve either mastered or memorized somewhat the process of creating an item and we’re just going to be repeating that process now but with a few extra steps so come over to your registry handler class in your util package And we’re going to make a new registry object just in our items category here um and we’re this is going to be just like a regular item so it’s going to be public static final registry object now this is where it starts to change a little bit so you could Just put item in here and then inline create the the item but because i want our my food item and you know possibly your food item to be a little bit more advanced than that i’m actually gonna make a custom class for our food item and you’re gonna Depending on you know what kind of food you want to make you might want to make a new class for every single food item that you have so uh this food item that i’m gonna make is gonna be a poison apple and we’ll get more in depth into that Later but i’m gonna make my class poison apple just the name of my item so poison apple and uh we’ll be creating this class later but uh just put here whatever the name of your your custom class is going to be you can name it literally anything you want but i would recommend Using um then just the name of your object so poison apple and then the name is going to be poison underscore apple and just like last time it’s going to equal items dot register and uh we’re gonna pass in the name which is gonna be again poison underscore apple uh comma And then again just like we did up here we’re just going to type poison apple again that’s the name of our custom class we’re going to make in a second two colons and then new just to create a new poison apple object all right so this is our item made but We need to make this class so come over to your tutorial folder your main folder go to items open that up and we can right click new java class and we can name this again exactly what we put here so poison apple and we can add that to the repository And uh let’s really quickly just hover over poison apple and import class now you’re gonna have some errors here that’s because we need to go to poison apple or whatever you named your your custom item class and we need to make sure it extends item and make sure you import item as well There we go import class and we also want to hover over it again and create constructor matching super now there’s a few things we need to do in here to customize our our food item i want to mention really quickly that this items folder is over time going to fill up with your Custom items so don’t be afraid to make a few classes for each food item it’s really up to you if you want to do them in line or if you want to make your own class but just thought i’d mention that so anyway back in your class Uh we want to get rid of this um uh this parameter here this argument and inside of super we can get rid of this as well uh first thing of course you want to do is set our properties so new item dot properties um and then let’s make a new space here We’re gonna we’re gonna give ourselves a bit of space because all this is gonna be where our custom stuff is gonna be added so um we want to do dot group first to set our tab so i’m going to set mine to my custom tab tutorial.tab But again if you wanted to do a vanilla tab you could do item group dots and you could set a vanilla creative tab but i’m going to set mine to my custom tab next thing i want to do is add a dot food now again if you don’t really know any of These methods you can always just type a dot and it’ll show you all the possible methods you can use for properties there’s a ton in here and i’ll go over them for food specifically but just know that there’s some more that you can mess around with so we want To do dot set food which makes it a food object dot food and this is going to pass in a food object and we’re going to build it ourselves so you can type new food dot builder in all capitals uh sorry just the first letter is capital actually And i’m gonna make a new space down here uh oh this is not cooperating with me a new space um dots there we go i want it to be sort of in line with uh this method here now we can actually customize our food object so Every time you want to add something new to your food object just make a new dot and then choose from this list of methods we can set the hunger amount so this is going to be how many hunger bars it feels when you eat it And i believe the number that you put in here is divided by two so if we were to put for example like eight in here um this would restore four hunger bars uh if you were to put just one in here for example that would be half of a hunger So i’m going to put let’s put 4 so this is going to restore 2 hunger bars we can also add a dot saturation as well and this is going to be the saturation value if you don’t know what saturation is essentially it’s how full you feel after you eat Something so like how long it takes for you to start losing um hunger again after you’ve reached max hunger or sorry max like hunger bars it’s kind of like a hidden hunger bar above the main one so i don’t want this to be super high But i guess we could set it to like i don’t know like 1.2 f or something or 1.3 f whatever you want really you can mess around with that yourself um now uh we could be done here if you want if you want your food object to be done here You can just type dot build and uh that will create uh that will finish the food objects um so whenever you’re done building your food objects just end it with the last statement being dot build but i want to add some effects so if you’d Like to add an effect to your food item what you can do is right before the build type dot effects and you need to pass in a new effect instance so new effect instance and this is going to take in your effect so what i want this poison apple to do when You eat it is have uh well it’s going to give you nausea and poison but i also want it to have a smallish chance to give you hunger as well so what we can do is set effects dot let’s do nausea first nausea comma so that’s the your effects and you Can choose again from this list of effects here any of them any potion effect really so i’m going to do nausea then the next value needs to be how long you’re going to have the effect in seconds or i guess it would be in text so The way you calculate in text every one second in my in minecraft is a single is 20 ticks so what you can do if you pull out your calculator uh take however many seconds you want um your uh your potion effect to last i want mine to last 15 seconds So i’m gonna do 15 seconds and then always just multiply it by 20 and that is the value you should pass in there so 300 another thing you could do if you don’t want to use your calculator is just type the amount of seconds you want 15 and then multiply it by 20 Just like that but i’m going to put 300 so 300 ticks and then the last one is the level so uh level would be like nausea 1 nausea 2 this it’s like how intense how amplified the potion effect is um similar to how you can have like speed one speed two Same sort of idea so i’m just going to put nausea one uh then after this uh effect distance we need to make a comma and pass in one more value which is the the chance for this effect to happen now this is like whether or not the Effect will actually occur when you eat the objects it’s like a rarity chance so if we were to put for example like 0.2 f what this would mean is that there is a 20 chance that when whenever you eat one of these poison apples that you would get this effect Um this is similar to what like rotten flesh does and uh i i think like uncooked chicken stuff that gives you hunger that’s what this does but i’m going to set it to one which will make it happen every single time one is essentially a 100 Chance but just know that you can set a probability if you’d like all right so uh probability of 100 now this is great but i want to add multiple effects so if you want to add a new effect and just copy this line paste it down below and you have a new Effect now we want to change this of course because i don’t want to just give nausea twice so our second effect i want it to be poison i’m going to keep it at 15 seconds just like the other effect this is i’m going to actually make this Poison 2 just so it’s a little bit more dangerous and i want this to also be a 100 chance to occur when you eat the object and i’m gonna add one more effect just so we can check out the probability factor uh this is going to be the hunger That i was talking about so there is a chance for you to get hunger and again 15 seconds of hunger i’m just gonna have it be level one but i do want it to be a 0.3 f chance so this is a 30 chance um for this effect to happen whenever You eat the uh the poison apple if you wanted to be single digit uh um what’s the word single digit um uh chance or probability you could just add a zero here and put three and that would be three percent but i want this to be 30 Chance all right so uh this is pretty much done for my object that i want i just know though that before build there’s a lot of other things you can add if you add a dot here you can see them so like for example we have Uh fast to eat if you were to add that what this would do is make your object a lot faster to eat in the game you could also if we come back here to this menu um you could also set dot meat if you added this what this would mean Is you could feed this object or this this item to wolves just like you can feed a meat object to a wolf and then i think there’s one other dot set always edible and this will allow us to actually eat the object the the food object even when we’re not hungry And this is sort of what um the golden apple does where you can eat a golden apple even if you have full hunger so i’m actually going to keep this because i think i want my poison apple to work similar to like a golden apple where you can always eat it Uh but other than that i don’t know if there’s any other interesting ones yeah i think those are the only really important ones to talk about uh but just know that you can set uh whatever you know whatever extra properties you’d like for your food builder and yeah so this Is the poison apple done just to run through it one more time we’ve got uh the item properties setting the group to our custom item tab and then we’re setting it to food so dot food in the properties uh makes this a food object and we’re passing in a food And we’re building with the builder and setting the hunger to four the saturation to 1.2 we’re having three different effects that can occur when you eat it and then we’re also making it edible even if you’re not hungry and then finally building the objects all right so now that we’re done with that We now need to do what we do with every object item object is create the json so go over to your resources folder assets your mod id models item and inside of your item folder uh what we can do is just copy ruby uh the ruby json that we made for our Regular object because this is just a regular object and we can just paste it into item and change the name to uh poison underscore apple refactor add the repository and again change the name here from ruby to poison underscore apple and i will include this uh as a pastebin in the description again Even though i’ve talked about it before but it is the exact same json as any other regular object so just keep that in mind um all right so now all we have to do is add uh oh we’ll actually we have to do the the language folder so go to lang ian Underscore us.json uh just copy the ruby object we have up here paste it below uh make sure there’s a comma there if it’s not the last one and then instead of ruby this is gonna be our poison underscore apple um and then last thing to do is add the Texture so if we come to our desktop here i have a poison underscore apple texture so what i can do and again this is 16×16 just a regular item texture and it does have to be the same name as you set in your registry handler here this name right here I’m just going to open up my textures items folder and just drag it into here drag it in and refactor add the repository and there we go poison enters for apple.png all right so we’re all done now we can launch the game and let’s go check it out One quick thing i forgot is i actually copied this line here for poison apple and didn’t actually change the real name of the game so instead of just setting this to ruby we do want this to say poison apple and then we can file save all and actually run the game this time All right so we’re inside of the game and if we come over to our creative inventory tab and we go to our poison apple here we can see that it is in the game and let’s go to gamemode survival so we can test it out And it should we should be able to eat it even if we’re not hungry because we did set that so yeah we can we can eat it and if we come down here let’s just try it out all right so we did get poison and nausea but you can see that We did not get the hunger and that’s because there was only a 20 chance to get that effect so actually this object is working perfectly and we can just try it a couple times and see if maybe we’ll get the hunger effects and there we go you can see the Third time we eat it we did get hunger that 20 chance uh and we can just um use milk to get rid of the effects but yeah so now you have a custom item a custom food item in the game with some custom effects one thing i should mention is that in Vanilla minecraft every effect instance starts out with a regular value of one for its level its amplifier and then this amplifier value is actually just going to increase it by another factor so by setting this to one you’re not actually getting nausea one you’re actually getting nausea two In the game and you might have saw that during my uh my demonstration a few seconds ago so if you want this to just be regular nausea one you would actually wanna set this to zero not one so i made that mistake earlier and i’m correcting it right now i would want These to be zero and actually i’d want poison b1 and what this would actually do is have nausea be nausea one poison would be poison two and hunger would be poi uh hunger one so hopefully that clears it up and i apologize for messing that up earlier All right that’s gonna do it for this video thanks guys so much for watching i hope you learned a lot about food and effects and i will see you in the next Episode You Video Information
This video, titled ‘Minecraft 1.15.2: Forge Modding Tutorial – Custom Food (#9)’, was uploaded by TechnoVision on 2020-07-11 02:12:32. It has garnered 11051 views and 447 likes. The duration of the video is 00:15:20 or 920 seconds.
Learn to code a Minecraft mod from scratch in this complete tutorial series! In this episode, we create a custom food item with some custom effects.
— Important Links —
● Item JSON: https://pastebin.com/zH6J3m8E ● Discord: https://discord.gg/ZsB3Eha ● GitHub Repository: https://github.com/TechnoVisionDev/Minecraft-1.15.2-Modding-Tutorial.git
— Music —
● Phil Smith – Lake.Side ● Xori – Dreamin ● Chill Out Media – Minute Mix
— My Channel —
● Subscribe: http://tinyurl.com/zbc7mwy ● Instagram: https://www.instagram.com/tomm.peters ● Twitter: https://twitter.com/TechnoVisionTV
#minecraft #modding #tutorial