Hello everyone I know it’s been a while I’m currently in college not doing too hot at some classes right now I’ve got two exams to speak but I am really fed up with studying and I feel like I just need to take a good break so taking a Good walk and you know my roommates out right now so I feel like it’s a perfect time to just try to crank out video you know I’m just trying to fit this into my schedule but I have no clue when new videos will be coming out just because College comes first but I miss kind of doing these videos and I know you guys want more videos to come out so I’m see how this goes it’s been a little while since I’ve sat down and recorded a video but without other way I’m gonna be going Over how to create the backbone of an event system I want to put a disclaimer before we start this code that I’m going to write this video is heavily based and modified off of Dark Magician 6 is Java API I will put his event API in the Description if you would like to check out the original code but I will be modifying it slightly in this video for specifically minecraft client so I guess let’s start let’s go into our client package let’s create a new package and we are just let’s just call this a bit Good enough of a name yeah okay let’s make a new class and we are going to call this class event priorities or even PR then priority and this class is going to just hold some byte constants that will be used in other classes this will kind of determine the order that events Are called so we’re going to say public first for just first zero second equals one third of two four five oh yeah four five notes fo you fourth equals 3/5 equals five or four sorry and then we’re going to make it a rave that’s when you say public static final fight array We’re just in colors like value array new array with inside of it first second Wow okay family all right basically that’s that’s this class done so let’s make a new class and this class is going to be an annotation that basically tells the event manager what functions are event functions and what functions are just normal front of mental functions in your class so we’re Going to call this we’ll just name it event target and we are going to change this to an interface oh boy close I just got everything installed on this computer it’s a new computer so I’ve had to like migrate everything over so I’ll try to edit this part off I remember too But I probably won’t so if I did edit out you’ll see this part so we’re going to say at Target type dot tension policy of runtime and in this we are want to have a value so we can fight when you see value and this is gonna determine the priority basically Of it and so we’re gonna just say the default value of that is gonna be event priority dollar so it’s like right in the middle yeah and that’s this done that’s pretty simple class we’re going to make a new class and this one’s can we call the Vent event and this class is basically just going to be one function right you call event in every lost my train of thought in fact this is basically going to be what every event its oh you know actually lets you know I’m gonna do this a little bit of a different way we’re Gonna need we’re gonna do event do that first that’s gonna be more better as you load a scatterbrain today I’m sorry guys I’ll gonna say public this class is basically just going to pass random groups of data to the classes for an event public public AC public finally by priority I got an import method and now we’re going to target by priority start source or source this target equals target is priority equals priority okay now we can move on to actually making the event that’ll just make a little bit more sense I do it this way really should write all this Down okay note the actual event class we are going to do public event call so so it’s going to return an event ID you call it so you can figure out if it needs to be canceled uh we’ll get into that a little bit but just go along with me we’re gonna say Final ArrayList data data is people’s event manager get this class that manager doesn’t exist yet we will make it in a minute but want to get this done if table if it’s not equal no hello go through all the event data in data list so we are going to say for event data Data all the events in there and we’re going to be try/catch doctors for now and we’re going to save data target thought invoke data source this all right now I am going to make something called we’re gonna call Ivan cancelable sword and say event came CA See the LAV oh my god I can’t spell C ance I’ll be I’m canceled bull gonna extend vent vent and we’re just going to add a few functions it’s private boolean K equals false trust face is canceled control space set canceled that’s just so we don’t have to keep Adding these we can if we want to cancel a little vent we just extend with them cancel both I feel like the juice makes it a little easier to understand when making new events but now this is going to be the hard part it is going to be the event manager Class I will I’ve been debating on this for a little bit but I am going to type this all out in the video so you guys can understand what it does but I will most likely give this out as a download on github so you can under so basically If you mistyped something everything doesn’t break because this is the most complicated class potentially in this tutorial that we will be writing like as a whole this whole client tutorial it’s just very complicated yeah was that away I’m gonna try to write this all in one Take and hopefully get it right you guys all I see the right version of Excel I did not forget it wrong but it might be here from sorry the first start out with private from a class of a wild card the defense event and data I’m gonna call This registry equals new of a class of a wild card that extends event okay we’re gonna make this fullscreen okay then extends event event data oh oh to import everything perfect so we’re gonna write a method that sorts everything’s ready to be public or private private static void for list Value passed final class and we’re going to say we want to link out for a bit there we’re going to say for finals I eat be called event horizon for every event priority in the value or a we are gonna have another nested for loop so For event in your registry map get of the class we’re gonna say if yeah that’s a data dot priority equals equals equals it equals the thing value ray and we add it too right and then we want to put that all the classroom say Events Manager registry nap dot put blacks Award All right we’re going to say we’re going to just return to return method get framer types not link does not equal one or not is imitation present event target so we’re going to make another is method by which in some private we’re gonna pass a final method a final class a Wildcard that extends of those claws we’re going to return is nothing bad Peter isn’t it bad passing the method or this is Pat parameter types of zero dot equals all right then we want to get her so he was a public array data that’s when we final wild-card extends event or return Registry manner dot catch we also want team map function sort when public static out what’s possible north dot entry wildcard extends ArrayList of events data a iterator increase at iterator hopefully got that type 3 and we’re going to say while iterator if courier if not only enjoys or iterator next pop Next dog my cat value dot is empty iterator okay now we want unregister method so we’re going to say oh boy this is going to take a final Oh at a final class of a wild card that extends event in frame okay all right so we’re going to say if Registry map doc contains key for data Registry match if that big data source equals Oh registry man down registry man doc get data we can’t forget at the end of this stay clean okay we want another unregister function and this was just unregister an object public void unregister object oh we’re going to say for for ray list Event data flexible call it event bird no not confident calling the registry mal use and we’re gonna go backward city eraser for int I equals over a bull ring I afterward all right and there we got three methods to rate and then we can share this link all works so we’re going To say public void register Oh Berta we actually want to do first where’s my final and when you say final class a wild-card class equals left there get parameter tight of zero when you say beta equals zero and theta of Oh method method annotation this wears just get in a teaching of Venture target class value and we’re going to say if noted data not target it’s not accessible we’re going to make it accessible so we’re gonna say method data target but set that’s a little true then we want to say if write your stream contains key and if it has a registry Key we are going to ready screen there dot get of class dot contains method data so it doesn’t contain method data right for you map dot class add sort list value we’re going to just cast this to a class of push word extends of is close All right this oh if it’s not method so if it’s not a bad method register oh I don’t want a public would register we’re going to say or final final method my food in Oh doc its class kids if it’s not a bad method register method okay Now let’s see what did I forget to do oh I forgot to return this ah ok ok so this should work now in event not fullscreen so yes now that we’ve done that let’s create a first event we’re gonna do the tick event which basically is like every Client tick which is in the game loop so what I’m gonna do is in a bit we’re gonna make a new package we’re just gonna call it impl blips and let’s make a new event called client tick event and this event is going to extend event and We’re gonna import of it make sure to not import the Java 1 import your client name done event and we’re not actually gonna put anything in it it’s gonna be an empty event so now we actually have to call this so what we’re gonna do is We are going to go into it minecraft client minecraft Java and now what I am going to search for under your control f and I’m going to type pending next yeah I want to find this right here right above this end right here so I’m going to say New client to prevent to import that now that should call our tickets but now we got to actually make a test class this works for so what I’m gonna do is in our client package I’m just going to make a new class called test class really named in hurry So we’re going to say event for it public avoid and is the void can be a name I’m just gonna call it on tick makes the most sense to me we have to pass in the client tick event that’s the this is the event that we want to have Happen I could call this who bla 3001 if I really cared to and you know I’ll keep it like that or not I mean call this a better name right you know you know I want to be confusing what your code does and here what I’m Just gonna do is system dot out dot print line and let’s print it can be really anything just I just want to make sure this is working and so then what we want to do is in an it we’re going to call a mulch manager dot register we say new test class Theoretically now if you’re able to start our cleanup and it should just spam plane ticket look at that eight of spamming so now our event is happening oh I forgot to say called let’s see no it’s just old but you get the point it’s working now in future tutorials we Will make more events and we’ll make it really easy to make modules now based off the forge mods when we can replace forges event system with our own events that’s about it guys thanks for watching and I will try to get more tutorials out I’m gonna see how long this like takes Me to edit and then I really should go study for my two exams this week but if I can balance out a schedule with reporting I’m gonna release new videos so yeah great see you soon guys Video Information
This video, titled ‘How to code a Minecraft PVP Client: Episode 6 – Event Basics’, was uploaded by Eric Golde on 2019-10-22 22:40:40. It has garnered 39465 views and 505 likes. The duration of the video is 00:31:29 or 1889 seconds.
How to code a Minecraft PVP Client Series – Episode #6.
This tutorial’s code is heavily based and modified from DarkMagician6’s java event api. You can check out his repo here: https://bitbucket.org/DarkMagician6/eventapi/src/master/
——— [ Links Used In The Video ] ——— EventManager.java : https://github.com/egold555/Minecraft-1.8.8-PVP-Client-Series/blob/master/Episode%20%236/EventManager.java ———————————————–
——— [ This Series ] ——— Playlist: https://www.youtube.com/playlist?list=PLxbv-Ej1VQMQS9M2qnmEQtp-qL3xcA4ua Discord Support Server: https://discord.gg/M3PAyyy ———————————–
——— [ My Social Media ] ——— Youtube ➝ https://www.youtube.com/egold555 Instagram ➝ https://www.instagram.com/eric_golde/ Twitter ➝ https://twitter.com/eric_golde/ ————————————— Another Song: https://soundcloud.com/xmittens/winter-is-here