Let’s add custom enchantments to minecraft fortune fabric courses with advanced topics such as entities custom structures and three armor models linked in the description below alright we find ourselves back in intellij once more and in this tutorial we’re going to be adding a custom enchantments to minecraft or rather one Custom enchantment and for that we’ll need a new custom package right here called the enchantment package make sure that we write this correctly it’s not necessary but you know i just have it written correctly instead of there we’re going to make two new java classes one of them Is the mod enchantments class and the other one is the actual enchantment class so this is going to be called the lightning striker enchantment there you go and they’re actually snuck in a little bit of a an arrow so what you can do is you can click on this if you write anything Incorrectly and then press shift f6 to then change this so this is the enchant meant there you go and that should be fine now this one this class will extend the enchantment class right here and then we’ll hover over this and create constructor matching super making sure that we change this constructor to Public and then we also change this from a an actual array here to dot dot dot this just means that we can basically pass in as many equipment slots that we want and it’s going to convert them automatically to a an array basically now in the enchantment class where i can Actually middle mouse one click and we can see a lot of stuff that we can override right here you can see there’s quite a bit of stuff in here highly recommend on your own time just checking a little bit of this out trying out a bunch of stuff and then also you can Always check the enchantments as well if i click on this control h then i can see all of the different vanilla enchantments that are available so you can basically take a look at those as well and we’ll just see and figure out how those work and model your Enchantment after those as well for our case we’re actually going to overwrite the get next level method because this is actually important because this will generate how many books there are going to be and for our purposes we’re going to make two levels so this is going to Be lightning striker 1 and lightning striker 2. and then for the functionality what we’re going to do is we’re going to overwrite the on target damage method so this is called when you damage a target with this enchantment on a certain item basically that’s the general idea what we’re going to do is We’re going to make the following so we’re going to check first of all if user.world that is a client and very important we have this exclamation mark here meaning that we’re negating whether or not we’re on the client meaning we want to be on the server this is very Important this is a an error i see all the time right people just forget the uh exclamation mark is actually very important in this case because we only want to be on the server because we’re going to be spawning a lightning bolt and a lightning bolt you only want to Spawn on the server so the first thing we’re going to do is we’re going to actually say server world called world equal to and then we’re just going to say user.world and then we’re going to actually cast this so the way that we’re going to cast this is We’re just going to add server world at the front here so server world you go making sure we write this correctly there you go and then it’s going to cast this world a variable into a server world now this of course once again only works because we’re checked Before if we’re on the server then we also want the block position of the actual target so this is just going to be position equal to target dot get block pass there you go and now we’re ready to implement this so we’re also getting passed in at the level here as a Parameter so this is the level of the enchantment what we can do is we can just say if level is equal to one then what we’re going to do is we’re going to spawn one enchantment so to the way to actually get this determined is to do entitytype.lightningbolt.spawn And then passing in the world then we’re going to pass a null null and null so three times null then the position and then we’re gonna have a spawn reason this is gonna be triggered in this case and then we’re gonna do true and true And then we have this spot and this way by the way you can spawn any type of entity that you want so in theory if i you know i can change this you can see there’s all types of entities in here so you could also for example add a Fireball you can even do a cheap so you could in theory do something like a sheepstriker enchantment or a pick striker enchantment so that you spawn pigs when you strike an enemy i mean wouldn’t really do anything other than spawn or pick but you know you could in Theory do this as well so that’s really funny so then let’s actually just copy this over so i just selected ctrl c and then ctrl v to paste it in i’m going to change this to level equal to and then what we’re gonna do is we’re just gonna Basically spawn two linings so that’s pretty much the entire class actually done this is all of the functionality like i said you can very easily click on here press ctrl h and see the functionality of the different vanilla enchantments here and hopefully there’s going to be something In there that is similar to the enchantment that you want that is basically it so then let’s go to the mod enchantments class and let’s actually register the enchantments for this what we’re going to need is first of all a public static void and this is going to Be the register mod in enchantments method right here and this is once again just going to do system out print line registering and months for and then we’re just going to do tutorial mod at mod id so that we actually register this class properly and then we’re going to do a Private static enchantment enchantment there you go and this is just the register method we write this correctly as well and that’s going to have a string parameter called name and of course an enchantment parameter called enchantment and this is going to return the registry.register registry.enchantment and then a new identifier We’ve seen this plenty of times now tutorial mod.mod id passing in the name and then after the first parentheses we want to write enchant so this is the register method done and now we can register our custom enchantment so we’re going to say public static enchantment called lightning Underscore striker which is equal to the register method that we’ve just created the first parameter lightning underscore striker and then the second parameter is a new lightning striker enchantment right here this is the class that we’ve just created then we pass in the enchantment rarity let’s say uncommon And then we’re going to say enchantment target is going to be a weapon and then the equipment slot is going to be main hand let’s just format this a little bit differently there you go so that we can see everything nicely and that is pretty much all that we need To do right here now we just need to call this register mode enchantments method in the in your main class in the uninitialized method so mod enchantment start register mod enchantment that’s very important and then last but not least we also want to add a translation in the ian underscore Usa json file and that’s going to look like this let’s just go at the very bottom here this is going to be enchantment dot mc course that’s not right tutorial mod there you go and then we have the under lightning underscore striker so this is then going to be the Name of the book and also what you’re going to have when you hover over a you know an item that has this enchantment you’re gonna see lightning striker and the one and two for the levels are going to be added automatically so you actually don’t need to even do anything here yeah that’s Pretty much all that we need to do and that is actually all of the steps that we need to take to add this custom enchantment to minecraft so let’s see if it works all right we found this back in minecraft and there you go the enchanted Books are here so i can actually search for them lightning striker and you can see over the books are there let’s just add the actual enchantment to a sword right here you go lightning striker one and a lightning striker two and then let’s just spawn in a bunch of well Let’s just want a bunch of sheep why not and we’ll see what we can do here so let’s just spawn the sheep and once i hit them you can see there you go a lightning is basically going to well spawn and let’s then add a sheep and Let’s see the lightning striker 2 and that’s gonna add two lightnings now it’s not going to be too noticeable but it is still pretty freaking cool so you can see the actual enchantment working perfectly fine and if you are on in survival mode then you know it might Actually hit you as well so you know be wary of that but you know it’s just a demonstration on how you can add enchantments basically it’s not necessarily you know the best enchantment but it is an enchantment that is pretty freaking cool nonetheless right that is how easy it is to add Custom enchantments to minecraft and that would already be for this tutorial right here i hope you found this useful and you learned something new if you did or very much appreciate a like don’t forget to subscribe for more tutorials just like this one i also want to thank All of my lovely patreon supporters for supporting me and this channel it is very much appreciated and i’ll see you in the next tutorial so yeah Video Information
This video, titled ‘Minecraft 1.18.2 Fabric Modding | CUSTOM ENCHANTMENT’, was uploaded by Modding by Kaupenjoe on 2022-05-04 13:59:51. It has garnered 3420 views and 90 likes. The duration of the video is 00:08:40 or 520 seconds.
In this Minecraft Modding Tutorial, we are adding a custom Enchantment to Minecraft using Fabric 1.18.2
== 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/Fabric-Tutorial-1.18.1/tree/51-enchantments Gist: https://url.kaupenjoe.net/yt284/gist
== TIMESTAMPS == 0:00 Intro 0:21 Creating the Custom Enchantment Class 4:49 Registering the Custom Enchantment 6:40 Adding the translation 7:16 Demonstration 8:16 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