Events let’s talk about them all right we find ourselves back in intel once more and in this tutorial we’re going to be talking about events so events are a well very extensive topic which we won’t cover in like seven to ten minutes let’s say however i want To introduce to you the idea of events where you can look up every event where you can basically find out how it works and then also how you can basically well use events and and add stuff to minecraft with those events so what you can do is you can press the shift key Twice and just search for let’s say the living herd event that this you know i usually look for a particular event because where we want to get to the event class but the issue is if we do this there’s uh there’s a lot of event Classes um so this is why i usually go to something like the living herd event and then just go through the super classes here so middle mouse one click middle mouse button click middle mouse button click and finally when i’m at the event class i can press ctrl h And then get the complete hierarchy over here we can then expand this hierarchy like this and can then go through well every single event that has been added by port basically and as you can see there are a lot of them i have i don’t even know like obviously like i i don’t Think anyone knows every one of them basically but as you can clearly see there are tons of events over here and the general idea is that you can use any one of these events to have certain things happen when these events fire so for example the baby entity spawn event Just picked randomly over here well probably this is going to be called right this particular event will fire when a baby entity is about to spawn okay now you can usually events have very very detailed java blocks over here they can see is fired just before a baby Entity is about to be spawned parents will have disengaged their relationship and it is cancelable this means that in theory you can cancel the spawning of a baby entity in this case or you can change it to be like hey you know maybe a mob needs to be xyz maybe they need to Have a certain age or whatever you can do all sorts of craziness and in theory you can do this with almost any event now we’ve seen the you know we’ve seen some events already in our mod events over here the villager trades event we’ve already seen attached capabilities the clone event for the Player register capabilities the player tick event entity join level event the entity attribute creation event but we’ve seen a few events already but as you can see you know there’s like quite a few more you can even you even have something like difficulty change event right like from what difficulty you Change like it’s pretty crazy like there’s a lot of events and usually you will find what you need in these events now why do you even need events why would you want to use events well what we’re going to do is we’re basically going to make it so that if you hurt a Cheap right we’re going to get a output inside of the chat that’s all i want to do now this might not seem like the craziest thing to do but it hopefully will illustrate certain ideas of events right and this is basically what i want to want you to take away from this Because you can then i mean almost do anything with events like it is insane what you can do usually you shouldn’t use events if you have access to your own block and item classes so that’s one thing and regardless of that it’s still a pretty cool idea and i mean let’s just let’s Just take a look so let’s just add a public static void we’ll just call this own living hurt over here and this is the living herd event old event there you go do not forget the add subscribe bus event right and also don’t forget to subscribe to the channel i’m just Kidding that is not necessary but the add subscribe event is definitely is necessary and then we just want to check event event.event.getentity right so this is the entity that was hurt is if that is an instance of sheep then we will continue and then we’re Just going to say okay we only want this to happen if the source so get source right and then get the entity from this is actually a player so if the player actually let’s say punch the sheep then we want to we’ll just send a system message over here component.literal And we’re just going to say dot get name dot get string heard a sheep that’s all we want to do but we just want to output this into the chat and that’s literally it so this will only happen if once again the a sheep was hit And if the player if the source of the damage is actually a player now you can continue this as much as you want right so for example you could say player dot and this is the thing get item in hat so for example you could say right let’s Say get the main hand item right now we have the get item over here and then we could say you know i only want this to happen if the player actually has what items that i mean whatever the case may be right count sword that get Right so just for the sake of argument so now we can also have something happen that only happens if the player has in its main hand a couple sword now you can of course also replace this with a vanilla item right so for example i mean beef yeah why not so you’re you’re Taking the beef and you’re hitting the sheet with it that’s kind of weird man but regardless you could then fire something here as well so this of course comes back to simple java knowledge once you have access to the events and you know all about java then you’re like oh i can I can do almost anything with this and the answer to that is absolutely so keep that in mind as well let’s just for the sake of argument here let’s just put this in here and let’s just put an else statement so that you know if we hit the Sheep with anything else but a beef then it’s just going to do hurt with the sheep and then here we’re going to say hurt uh hurt a sheep with beef and then we’re just going to say but why because that really is a good question right so just to illustrate this a Little bit further and that’s actually all that we need to do first of all very important the method itself has to be public and static right then it has to have only the event as a parameter here it has to have the add subscribe event annotation over here and also the class That the method is contained in has to also have this annotation as well right so this is going to be on the forge bus to check whether or not it’s on the modbus or the forge bus you go inside of the event and usually it says The event is fired on the forge bus you can see this is the forge bus if it says something like the mod bus then it would be then it would require this that’s pretty much all that there is to it so let’s go into the game and punch some Sheep all right he finds us back in minecraft again so let’s just spawn a sheep and let’s just hit it and there we go def heard a sheep exactly right and if i hit it with beef it’s gonna say death for the sheep with beef but why That’s the that’s the question here um and yeah i mean that’s that’s pretty good right so it does definitely work and and that was one example of how you can use an event but that’s gonna be it 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.2 Forge Modding Tutorial | EVENTS EXPLAINED | #31’, was uploaded by Modding by Kaupenjoe on 2022-09-22 13:59:47. It has garnered 9071 views and 160 likes. The duration of the video is 00:07:06 or 426 seconds.
In this Minecraft Modding Tutorial, we are looking into Forge Events and how you can use them. All in Forge and Minecraft 1.19.2.
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.19/tree/31-events Gist: https://url.kaupenjoe.net/yt431/gist
== TIMESTAMPS == N/A
== 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 ▶️ 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