Let’s create an advanced item in minecraft oh right we find it back intelligent once more and in this tutorial we’re going to be adding a custom advanced item to minecraft now what i call an advanced item is simply an item with its own java class this allows you to add a bunch of Functionality to it and let’s just see how this is going to work so in our item package we’re going to right click new package called custom and then inside of there we’re going to right click new java class and this is going to be the 8 Ball item what i always suggest you do is you end the item class name with the word item just so that it’s absolutely clear that this actually is indeed an item class and this will extends the item class over here from net minecraft world item if this turns red then what You can do is you can just press alt and enter to import it once again making sure that you choose the correct class and this error always appears you just hover over it create constructor matching super and then the constructor has been created if this p over here Annoys you that’s no worries at all this is because we don’t have the proper parchment mappings yet you can just click on it press shift f6 and then usually it suggests something you know proper to us so we can just click on it auto complete with tab and then it Actually all looks a lot nicer now how can we actually add functionality to this item well the first thing we can do is we can middle mouse button click on this particular item class over here and we can then see the implementation of the entire item class so you can see all Sorts of different methods that we can now override in its derivative class being the eight ball item over here and we can basically find all sorts of things so very interesting for us for example the use method the use on method those are two very interesting ones and There’s also a bunch more i highly suggest just going through this taking a look at all of those methods basically most of the time the names of the methods pretty much pretty well describe actually what the different method is and what it does and there even is an Interface over here that is the iceforge item i can also middle mouse button click on this and here are even more different methods that you can override that are important for certain things so for example here makes piglets neutral you even have some javadoc over here so Basically you can see everything here is overrideable and you can basically add a certain functionality to your item by overwriting those methods so what do we want to do well we want to overwrite the use method so we’re just going to type use and you can see it’s already Suggesting this to us so i can just hit the tab key and it will auto complete everything the first thing that we will do is because the parameters here are unmapped currently what we’ll do is we’ll click on it and then we’ll press the once again shift f6 and just change It to you know the proper name basically it’s going to take the name of whatever the class is here but that’s going to be fine here we’re actually going to choose hand and that is going to make this just look a lot nicer and you’re going to be Able to follow this along way easier so the question comes in what do we want to have happen when we right click with this particular item in hand well what we want is we want to just output a random number between 0 and 10. that is All i really want to do and the first thing that is very important that’s the first lesson so to speak is i actually want this to only happen on the server and when we have this particular item in the right hand now why is that the case You know why would this need to be the thing the reason is that usually if you want things to happen you want them to happen on the server and some things like just the rendering and certain way visuals those are just on the client so this is why that’s kind of important you Can also think of it like this if you were to have a minecraft server and you would just let anyone on there what would you not want them to be able to do without the server sort of verifying it obviously things like spawning items spawning entities spawning lightnings You know all sorts of those things should always happen on the server because that is what the server is responsible for so how do we do this well we’re just making an if statement here and then putting in the exclamation mark to say level is client so this this Of course simply means that we’re negating is client so we only want to be on the server and we also want the hand parameter to be equal to interaction hand main hand over here so that it only happens when we actually have this item In our main hand now what we want is we want to then output a random number let’s say and then also set a cooldown so i just added these comments over here just so that it’s a little more clear what we want to do because i actually Wanted to add two private methods over here this is just gonna be a little bit of a more clean way to code it yes we could also write all of this inside of the actual method here but it just makes a lot of sense to have this properly Done so first of all we want to make a private hint and that is the get random number method over here and here we’re just going to return random source that we’re going to do the create new thread local instance actually not next int and then we’re going to pass into it the Upper bound and that’s going to be 10 so this is going to make a number between 0 and nine and then we’re going to make another private method and that’s going to be the private void output random number over here it’s actually going to Take in a player over there as well as a parameter and then we’re going to have the player.send system message with component data literal over here and we’re just going to say your number is and then we’re going to say get random number and that is all we need to do so To output the number we download call the output random number and pass into the player and then to set the cooldown that actually works the following way we’re just going to say player.getcooldowns.addcooldown we’re going to pass in this as the first parameter and then the number of ticks That this cooldown should last in this case it’s going to be 20 ticks so it’s going to have a cooldown of one second and that is actually all of the things that we need to do in this class now very important please note the following this name is currently grayed out as you Can see meaning that this class has not been used because we have not registered any item so if you were to go into the game of course no item has been added because the item was not added in the mod items class so we need to do this as Well so let’s just duplicate the raw zircon and let’s just do the eight underscore ball over here and then the same right here right eight underscore ball for the name making sure that we change this and then this is incredibly important we want to change the new item Here over to new eight ball item so you can see once again i’m going to do this one more time this new item over here has to change to new eight ball item you can see suggesting us net countdown tutorial mod item custom and this is the One we want if we now change back to the eight ball item class you can see the name of the class turned white and the constructor turned yellow now you know that this is being used and this is exactly right because of course it has to be used otherwise we are not creating A new eight wall item we’re just we would just be creating a new item we also want this to be stacks to one so that you can only stack one of those items together now just like any other item we also need the translation and the item model file and all of that Craziness so we’re just gonna add this as well eight ball right here and then we’re just gonna call this the eight ball as well and then i will just copy over the item model json file nothing crazy going on here it just points to a texture and will of course also download The texture now all of this including the code and everything is of course going to be available to you in the description below get a repository an individual just as well but those are all the steps that we need to do to actually get a custom advanced item into Our game so let’s join minecraft and see if it works all right so we find ourselves in minecraft again and there we go the eight ball has been added and if i right click it you can see your number is five your number zero and i can keep right clicking and i’m gonna Keep getting a new number over here so you can see i’m just getting a random number but yeah that is pretty much how it works and you can see that the cooldown is also added so i can’t like keep spamming it i you know i can only Click it and then i have to wait a second until the cooldown is done and you can also see it’s not going to work in the off hand it only works in the main hand so that is how easy it can be to add a custom advanced item to Minecraft and that would already be for this tutorial right here i hope you found this useful and you’ll learn something new and i’ll see you all in the next tutorial so yeah Video Information
This video, titled ‘Minecraft 1.19 Forge Modding Tutorial | ADVANCED ITEMS | #5’, was uploaded by Modding by Kaupenjoe on 2022-06-23 13:59:53. It has garnered 20739 views and 347 likes. The duration of the video is 00:08:11 or 491 seconds.
In this Minecraft Modding Tutorial, we add a custom ADVANCED ITEM to Minecraft 1.19 with Forge!
== MINECRAFT COURSES == ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 *
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.19/tree/5-advancedItem Gist: https://url.kaupenjoe.net/yt339/gist Assets: https://url.kaupenjoe.net/yt339/assets
== TIMESTAMPS == 0:00 Intro 0:24 Creating the Custom Item Class 1:22 Looking at Minecraft Vanilla Code! 2:24 Overriding the use Method 5:42 If the Class is greyed out? Registering the Item! 7:26 Demonstration 8:01 Outro
== TAKE A LOOK AT MY COURSES WITH COUPON CODES == ▶️ NEW Forge Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseForge120X ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 * ▶️ Complete and Roblox Lua Game Development: https://url.kaupenjoe.net/RobloxCoupon *
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== SOCIALS == Discord: https://discord.com/invite/yqxykanpWf Personal Twitter: https://twitter.com/Kaupenjoe
Instagram: https://url.kaupenjoe.net/tutorials/instagram Facebook: https://url.kaupenjoe.net/tutorials/facebook Twitter: https://url.kaupenjoe.net/tutorials/twitter TikTok: https://url.kaupenjoe.net/tutorials/tiktok Written Tutorials: https://url.kaupenjoe.net/tutorials/blog
== LICENSE == Source Code is distributed under the MIT License. Additional Licenses for other assets can be seen below or in the accompanying CREDITS.txt on download.
== ADDITIONAL CREDITS == Outro Musik by Kevin MacLeod: “That’s a Wrap” Kevin MacLeod (incompetech.com) Licensed under Creative Commons: By Attribution 3.0 http://creativecommons.org/licenses/by/3.0
== AFFILIATE DISCLAIMER == * Some of the links and other products that appear in the video description are from companies which I will earn an affiliate commission or referral bonus from or are my own products. This means that if you click on one of the product links, I’ll receive a small commission or additional kickback without any additional cost for you. This helps support the channel and allows me to continue to make videos. Thank you for the support!
== HASHTAGS == #Minecraft #MinecraftModding #MinecraftTutorial #Kaupenjoe