Let’s set some mobs on fire and let’s take a look at events all right we find ourselves back at intellij once more and in this tutorial we’re going to be looking at events now overall events are a very versatile tools so to speak in your toolkit However they are i would say sort of medium level to understand and very hard to master because sometimes there are first of all there are a lot of events so that’s number one and number two they can be used in very particular circumstances but we’re just gonna see so in our Tutorial mode package right click new package called events and then instead of there we’re going to create a new java class called mod events now this is going to be very interesting because actually above the class we’re going to write add mod dot and then it doesn’t Have anything because we have to import the mod here right import mod class there you go and then we can do dot event bus subscriber as you can see and then inside of the parentheses mod id and it will auto complete it to an equals and then we’re gonna just write Tutorial mod dot mod id now no more errors should be present and now this is you know marked as an eventbus subscriber what does that mean well it means that every method we put in here which has an ed subscribe event above it is going to get well basically Called when something happens so let’s just put this in so we’re gonna have a public static very important void and we’re gonna call this the set entity on fire when hit with let’s say another brick something like this okay so first of all that’s an insane name yeah but that no Worries at all i mean it definitely describes what it does right so that’s pretty good we’re gonna use the living damage event right and this is called event and you can see that now we have this event as a parameter so this basically signifies hey this method Should be called when this event is fired somewhere in the code we don’t know where it’s fired and we actually don’t really care we only know this event is fired this method then gets called as long as we add the add subscribe event above the method that’s Also very important so those are sort of the few things that you need to keep in mind the add event bus subscriber above here the add subscribe event and then those events are called and now we can go into the event so middle mouse by clicking on it and you can see that Usually the events have a very good javadoc description above it that’s actually very important as well so you should be able to find out okay what is all of that it’s actually pretty good there is also the living event so this extends from the living event we’re Going to middle mouse button click on this and then there’s the entity event and then finally we have reached the end of the iraqi tree with the event i click on this and then press ctrl h and now i can see all events that forge or yeah Forge basically adds and there’s a lot of them and now i’m also going to expand everything and now there’s even more because of course there’s a lot of events here and once again number one the most important thing is you don’t have to know all of them that’s ridiculous Actually you just have to sometimes think about okay maybe there’s an event for this and the great thing is that when you’re in this hierarchy view you can even search so for example someone said i want to kind of render something it’s like okay render let’s go right we Have render world last event we have render item in item frame event craziness render block overlay event we have something here entity renderers we can add layers we have we can register layers interesting okay we have rendered tooltips so what happens when you render a tooltip there’s an event and you can Sort of hijack that and and do something with it render game overlay event so this would be something that is used to overlay something on the on the screen basically as you can see there is a lot of things in here render player event like this insane amount of Stuff in here we can also say wait maybe we want to register something sure register register commands event oh interesting okay that’s we can sort of save that in the back of our mind there’s even capabilities events so custom capabilities we have shaders so as you can see insane amount of events Do you know need to know all of them absolutely not just you need to know that okay there are you know events there maybe i can take a look at them and maybe there’s something in here which works so there’s of course also things like the you know some right clicking Events or something like that right right right click block right click item those can be used to great effect if you have custom item classes or custom block classes and you of course don’t need that if you want to sort of add a certain functionality to a vanilla item Or a vanilla block then those could be used very well so that’s something to also keep in mind so we’re going to see one example here and that is when i hit an entity with another brick the entity is going to be set on fire and the The nether brick so the stack is going to be reduced by one so how does that look well first of all we need to make sure that we are on the server so once again the exclamation mark and then we’re going to say event dot get entity dot level that is client side And then with the exclamation mark we’re of course negating this meaning that this only happens when we are on the server then we’re gonna see whether or not the source so where the damage came from is a player we’re gonna say event dot get entity actually not we’re gonna Say get source get source and then we’re gonna say get direct entity so this is the direct entity that is responsible for the for the damage because there’s also as you can see there’s also the get entity so they get entity if we were to fire an arrow the arrow would actually Be returned here but the direct entity of course is the player that’s responsible for the damage and then we’ll say instance of layer this one right here there you go and if that’s the case then we can without a doubt just cast the direct entity to a player here so we can say Event dot get source dot get direct entity and then we can simply does this already work no we can say dot cast though there you go and then usually it already auto-completes it to the player that’s nice and now we can say okay if the player has a certain item in the Hand how can we do this well actually very easy as long as we have access to the player variable it’s very easy we can just say player dot get main hand item and then as you can see we get the item stack that the player has in the Hand we can then say hey get item so we actually get the item and then we can say items.netherbrick for the sake of argument here like i said we’re just gonna use the nether brick you could do use any item really here and then we’re just gonna say that the item stack is Going to shrink meaning that the stack that the player has in the main hand so get main hand item dot shrink once again by one meaning that whatever stack the player has in the hand meaning the nether bricks is just going to be reduced by one okay and then How do we set a an entity on fire that’s probably going to be really really freaking hard right get entity living okay we’re now having the entity how can we set it on fire set fire uh six seconds on fire that’s that’s that literally one call here so it’s not that complicated That’s of course not always going to be the case where you know sometimes the things where you might say well those are probably going to be really complicated actually fairly straightforward with one method call others might be not so much but overall that is pretty much the method that we Really need here and that’s also all that we need for this to work now overall the events in and of themselves you know can sometimes be a little bit confusing a little bit complicated like i said it’s all about knowing when to actually use them right you shouldn’t just be like okay i Definitely want to use an event right now oh my god we have to use it and also something to keep in mind we actually have seen events before in our data folder data generators look at this look at this one we have actually used the gather data event already here now What is very important or interesting here is that you can see this has a bus equals to the modbus here what does that mean well in general if i just go into here you can see that there’s the bus.forge and there’s also the modbus now just to give the broadest overview possible There are some events that which are fired by forge and some events which are fired by mod that’s pretty much all that you need to know for the time being there are some differences usually and we should be able to see this actually yes i mod was event so usually there should Be some indication in the events class and which bus this is fired from so that might happen to you and i actually think that we will see an example of this in a future tutorial as well but for the time being i think this is uh enough said let’s actually see if The event here works all right we finished this in minecraft and as you can see i’ve already got the nether bricks in my hand and let’s just see let’s just hit the sheep and there he goes so first of all another brick has been subtracted and also the sheep Has just well been set on fire and i can basically hit it as you know until it basically just dies and then i actually get let’s go there you go so that’s actually how easy it is this is of course once again just one example of how this might work Um and yeah that’s pretty much the idea here right here at the end i can just say the best thing is to really just try out a bunch of stuff take a look at some events try to see if you can maybe you know change a bit around and Overall that would be it for this tutorial right here i hope you found this useful and you learned something new if you did i would very much appreciate a like and don’t forget to subscribe for more tutorials just like this one so yeah you Video Information
This video, titled ‘Forge 1.17.1 Modding Tutorial | EVENTS BASICS | Forge Modding 1.17.1 #22’, was uploaded by Modding by Kaupenjoe on 2021-12-16 15:00:20. It has garnered 3498 views and 86 likes. The duration of the video is 00:09:52 or 592 seconds.
In this Minecraft Forge Modding Tutorial, we are talking about the Basics of Events in Forge Minecraft!
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.17.1/tree/22-events Gist: https://url.kaupenjoe.net/yt145/gist
== TIMESTAMPS == 0:00 Intro 0:33 Creating the ModEvents class 2:20 Looking at the Existing Events 4:45 Coding the Example Event 7:50 Mod Bus and Forge Bus 8:51 Demonstration 9:36 Outro
== TAKE A LOOK AT MY COURSES WITH COUPON CODES == ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 * ▶️ Unity 2D Game Development: Beginner Unity C# in Unity 2020.3: https://url.kaupenjoe.net/UnityENCoupon * ▶️ Minecraft Modding for beginners (1.16): https://url.kaupenjoe.net/MCCoupon * ▶️ Complete and Roblox Lua Game Development: https://url.kaupenjoe.net/RobloxCoupon *
== 1 MONTH SKILLSHARE FOR FREE == ▶️ https://www.skillshare.com/r/user/kaupenjoe *
== SOCIALS == Discord: https://url.kaupenjoe.net/discord 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
== AMAZON AFFILIATE LINKS == Amazon Referral [US]: https://url.kaupenjoe.net/amazonref/us * Amazon Referral [UK]: https://url.kaupenjoe.net/amazonref/uk * Amazon Referral [DE]: https://url.kaupenjoe.net/amazonref/de *
== 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