Let’s add a custom Advanced item to Minecraft Minecraft modding courses with close to 100 topics ranging from Custom tools and armor to custom block entities all the way to custom mobs Linked In the description below oh right we finish those back into children once more and in this tutorial we’re going to be Adding a custom Advanced item to Minecraft meaning basically that this item is going to have its own custom item class allowing us to do all sorts of crazy things now for this in the item package we will make a new package called custom this is not strictly Necessary I just like to well basically make this for organization purposes and inside of there we’ll make a new Java class and we’ll call this the metal detector item over here one convention to follow is you want to enter the class name with item so you know that this is An item to start we will extend this from the item class right here and we’ll hover over this create Constructor matching super and in theory we now already have a custom item class but it doesn’t do anything interesting at all for more more information on what you Can do is you can start typing in override and you can see these are all the methods that you can override and if you overwrite them well they basically get executed when certain things happen you can also take a look at the item class itself when you middle Mouse by Click on this and then just scroll through and you can see oh man there are a lot of things in here that are very interesting indeed one thing that might be interesting is the use on method this is called when you use this item on a Block or the use method when you right click without looking at a block in our case what I want to do is I’m going to right click with this item and I want this to basically look all the way down all the way going through it until Bedrock and if it finds an or block then it should output that or block into the chat that’s all we want to do and for this of course we need to use the use on method right here this one so we select this press the Tab Key to autocomplete And it will import the method no issues whatsoever the first thing we want to do is we want to return the interaction result success this will just make it so that the right clicking also has the animation associated with it and that just looks a little bit nicer we then Wanted to say if key contacts dot get level dot is client-side and then this is extremely important we want to put in an exclamation mark here at the front negating the is client side meaning that when we’re inside of this if statement we’re only on the server very important Then we’re going to get the blog post this is going to be the position that we’ve clicked we’re going to get this by saying pcontacts dot get click position or click get click pause here in this case we will then get the player making sure we choose net Minecraft world Entity player over here and that’s going to be the player equal to the context.getplayer awesome we also want to make a Boolean called found block we’re going to set this to false we need this in just a moment and what we’re going to do is we’re going to make a for Loop and the for Loop looks like this basically we will just go through from the Block that we’ve clicked all the way until y level zero and then 64 beyond that because well of course the world now extends to -64. to do that we’re going to get the block state that we’ve Clicked this is going to be the state and this is going to be pcontext dot get level dot get Block State at the particular position that we’ve clicked but we’re gonna extend below whatever the I over here is so as this for Loop Loops through we’re basically going to Go one block down each time and we’re going to have to evaluate that particular block so we’re going to say is valuable block passing in the state over here and you will see that well wait a second the is valuable block method that doesn’t exist exactly because that you have to create Ourselves so we just hover over this create that method over here and let’s see so it returns a Boolean so what we just want to check is hey is this state over here is this a certain thing for the sake of government we say is blocks.iron over here for example and There we go now if I right click on a block and any block below that is iron ore the first Iron Ore that we find for this it would be true and then we could do something and you couldn’t of course expand this by saying an or here or State is blocks dot Diamond orb and you can continue this however much you like but in a future tutorial in the tags one we’ll actually see how we can make this much easier and much more expandable but for now when a valuable is found I literally just want to Output valuable Coordinates what do I need for that I’m going to need the position that we’ve clicked position click that below with the I over here I will also need the player and I will also need the state and we’re just going to get the block from that I also want to make sure that Found block is equal to true and then I want to immediately break out of the for Loop over here because well we’re done we don’t need to do anything else except of course create the output valuable core coordinates method over here once again it’s just a method and it already Creates for us the method signature that we want that is awesome we’re just going to rename this to block pause over here and then I’m going to copy over the contents of this and I’m going to explain well we’re basically going to send a system message for this particular player that literally just Means that we’re outputting something into the chat and what we’re outputting is a literal component and that is going to be found and then we translate the name of the block over here so this is going to be if we find iron ore then it’s going to say iron space or at and Then here we’re just writing out the position in a nice way basically that is awesome then outside of the for loop I just want to say hey if we have not found any block right so if we say pound block Isn’t false over here then I also Want to output something just so that the player has some feedback always quite important that the player gets feedback so you once again want to send a sister message and here for example we can say component literal and we can say something like no valuables found and That is pretty awesome one last thing we also want to damage this items so that it can break so to do this we’re going to say p context dot get item in hand dot hurt and break we’re going to hurt this by the amount of one we’re gonna pass in pcontext.getplayer then after The first closing parenthesis we’re going to start typing player and you can see it suggests to us the consumer of player over here and we’re just going to hit the Tab Key to autocomplete and we’ll say player.broadcast break event passing in player dot get used item hand and this Is going to also damage the item stack in our hand that we’re basically using here and that is one example of a custom item class I highly recommend if you are interested in taking a look at some vanilla stuff you can also click on the Item over here and press Ctrl H to have access to all of the different of vanilla item classes you can double click on them take a look at any one of them and how they work and what they do some of them might be complicated some of them might not be too complicated What you of course need is going to be Java knowledge that is always the case the thing I say until you listen to me and actually take a look at Java because for example maybe you’re like you know what I really want to create something thing that does exactly the same thing As a snowball here is a snowball item Congratulations by regardless of this let’s go to the mod items class and actually register our item because well we haven’t done anything with our custom class which you can see by the fact that it is gray over here meaning that the Constructor is not cold what does that mean well if we were to for example duplicate our raw Sapphire over here and we’re going to rename this to the metal underscore detector and of course changing the name here very important Metals metal underscore detector then what we’re going to do is you you might Be like oh now we’ve created this no no no look at this new item and here it’s still gray when you make a custom item class you want to make sure that you also call this so this needs to be a new metal detector item double check once Again in the custom item class if this is yellow there we go it’s called if this is white this is called you can also middle Mouse button click on this and it should bring you straight to the mod items class if you’ve actually created one of those items and then for The item properties here in this case we want to give it some durability because in this case well I want this to be able to break so let’s give it 100 durability so we can right click with this a hundred times until the item is going to break the translation should be very Self-explanatory similar to adding it to the creative mode tab there we go in the island model JS file also no worries at all let’s add the texture as well there we go the middle underscore detector and those are going to be all the things that we’re going to need for the metal Detector to work so let’s go into the game and see working alright finds us back in Minecraft and we can see the metal detector has been added and let’s just see if we can find ourselves some valuables sometimes you need quite a while until you actually find something But usually at some point you should be able to find something and there we go there’s some iron ore right here where where is it there it is so it’s at 89 32 and 18 so absolutely spectacular and if we continue to search we will also be Able to find at some point some diamond ore that is of course vastly rarer so it’s going to take a while but there we go though I actually found some Diamond over here right here there you go that is absolutely amazing and of course if we keep right clicking at some point our Item is is going to break so that is a custom Advanced item for you right that’s already it for this tutorial right here next time in this video we’ll talk about a custom Advanced block hope to see you there so yeah Video Information
This video, titled ‘Forge Modding Tutorial – Minecraft 1.20: Advanced Items | #6’, was uploaded by Modding by Kaupenjoe on 2023-07-19 14:59:56. It has garnered 2471 views and 81 likes. The duration of the video is 00:08:42 or 522 seconds.
In this Minecraft Modding Tutorial for Forge, we are adding a custom Advanced Item which is an Item with its own Item Class allowing for all sorts of awesome functionality 😀
== MODDING COURSES == FORGE ▶️ https://url.kaupenjoe.net/CourseForge120X FABRIC ▶️ https://url.kaupenjoe.net/CourseFabric120X
== COMPATIBILITY == ▶️ Compatible with 1.20 & 1.20.1
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.20.X/tree/6-advancedItem Assets: https://url.kaupenjoe.net/mbkj56/assets
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== 25% OFF FOR GAMING SERVERS == ▶️ https://www.bisecthosting.com/Kaupenjoe
== TAKE A LOOK AT MY COURSES WITH COUPON CODES == ▶️ NEW Forge Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseForge120X ▶️ NEW Fabric Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseFabric120X ▶️ Complete and Roblox Lua Game Development: https://url.kaupenjoe.net/RobloxCoupon * ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 *
== 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.
== 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