It’s alive it’s alive let’s see how to add custom entities to minecraft all right we found this back in intellij once more and in this hotly awaited tutorial we’re finally going to add custom entities to the game i think no topic has been rivaled with having been Suggested so many times how do you add custom mobs and we’re finally here we’re gonna go through all of it how to make the custom mob how to spawn it in the world how to add custom spawn egg items as well all of that right here the one Limitation we’re going to have though is i’m not going to show how to make the actual model inside of blockbench the models i’m using here actually have been provided by me by ferro thank you very much for providing those to me a link to his twitch channel is in the description Below you know leave him some love that would be great right so let’s start with the first thing and that would be a new a package in our tutorial mod package and we’re going to call that the entity package right here and inside of that we’re also going to make a new package Called custom so we’re going to stick to the way that we’ve done basically the item package and the block package as well and instead of the entity package then a new class called mod entity types and this class is going to look very similar to a lot of other classes We’ve been using before which is going to have a public static deferred register right here this guy and this is of type entity type and then of type question mark this is the entity underscore types which is equal to a deferred register that create or registries.entities tutorialmod.mod id and how often have You heard it now where there is a deferred register there is a public static void register method with an i eventbus called eventbus which then of course calls entitytypes.register with the eventbus let’s not forget to immediately add this to the tutorialmod constructor here so this is going to be the mod Entitytypes.register with the eventbus there you go i think the smartest thing is to register the two entities that we’re going to make and then basically build all of the classes and all of the files up one by one this is going to be a public static final registry object of Type entity type and then of type buff zombie entity this is the first entity we’re going to create which is going to be called buff zombie and this is equal to the entity types dot register called buff underscore zombie and then a supplier of entity type dot builder dot Create and then we put in the buff zombie zombie entity colon colon new all these arrows are of course completely normal here because we’ve not yet created those classes this in this case would get an entity classification of monster down here this guy because of course the zombie would be a monster and Then after the closing parentheses here we’re going to put in dot size now this controls the size of the actual bounding box so basically the hitbox of this particular entity and this is gonna be one f and three f or the buffer zombie let’s make this a little bit nicer to Read and then after that closing parenthesis we’re gonna put in build and here we need a new resource location which we’re gonna take in a tutorial mod that mod id and then the buff underscore zombie and then we’re gonna say to string and i’m gonna format this a Little bit nicer in just a moment something like this there you go and then we also need a last closing parenthesis right here so this is the general gist here we have a registry object of entity type and then of our entity that we’re going to create this Is the entity class of our custom entity and that is once in here and then once in here and the rest is basically sort of boilerplate entity classification of course changes depending on what type of entity you want to create and then the size of course also changes depending on How big your actual entity is we’re simply going to copy over the registry object that we’ve made and then we’re going to say this is the pigeon entity because that’s the second entity we’re going to create and this is the pigeon and then here of course also pigeon Entity we can simply copy this over and then we will hold this one here pigeon as well then last but not least pigeon here as well and then also make it a little bit smaller so the classification here for the pigeon of course is in this well some people would say that it’s Still monster but let’s not go that far this is a creature in this case and then the size here is going to be 0.4 so 0.4 and the height is 0.3 right so with that the mod entity types class is actually done and now we can actually move on to Making the entity classes here so we don’t get any more errors in there so in the custom package in the entity package right click java class and this is going to be the buff zombie entity this is going to extends the zombie entity right here we can simply hover over here Create constructor matching super very easy and then of course we’re going to get a few errors no issue there whatsoever we’ll deal with those in just a moment now i’m going to copy over some of the stuff this is of course all available in the description below Either in the github repository or in individual gists what i’m going to do is i’m going to copy over the basically the contents of the entire class and then we’re going to go through from the top to the bottom the first thing that you’re going to see is you’re going to Have this set of custom attributes entities basically have different attributes as you can see of course max health we have movement speed attack damage a follow range and this in the zombie entity which is very important is the zombie spawn reinforcements this is actually critical that you add this if You extend the zombie entity you have to add this attribute you don’t add that attribute then it’s not going to work so this is very important wanted to mention that so that’s important here you basically set certain attributes for this particular entity and of course There’s quite a few so if i middle mouse button click on the attributes you can see those are basically all of the attributes that you can use you could in theory also register your own however that is something that we’re definitely not going to get into at the moment Because that’s very much more complicated then we have the register goals method which is super important this basically registers the goals so this is sort of the brain of the actual entity what does it do and there are a bunch of goals right here for example we have nearest attackable target goal Which simply says hey if there’s a player you know we’re gonna attack that one with priority one and then if there’s a and a villager then we’re gonna attack that one and so on and so forth so there’s different priorities for different goals and this is a rabbit Hole that you can go down and basically after a month of digging through this you can still you’re still probably not going to be done let’s just go into the nearest attackable target goal which you’re going to see this is a target goal and i can middle mouse button click On that one and that finally is the goal and if i click on this and then press ctrl h you’re gonna see all goals that are actually defined in vanilla and we can click this button to expand all but then we’re also gonna see all of the Subclasses and if i just scroll down a little bit you can see that there are an insane amount of gold as you can clearly tell like i said to go through all of those is pretty insane but usually they are either inside of the actual entity That uses them so that can be really useful that you can find a lot of other stuff as well so if you want to make your own you know custom goals in there you have to go through this there’s generally so much in here that i mean it’s basically it’s almost endless and Then you could in theory also make your own goals as well simply by extending the goal class yeah so for the goals i would definitely recommend first of all sticking with the vanilla goals that are already in there and trying to you know you use a few of those instead of making Your own immediately but that’s just a suggestion right next we have the get experience points method should be fairly self-explanatory it simply gets the amount of experience that is dropped when this enemy or this entity actually dies ambient sound simply is the sound that is played you know sort of around The mob and then we have a death sound as well as a herd sound in this case pharaoh has picked the oglin ambient and the hogland death and the herd sound is actually the iron golem herd sound and then there’s also a step sound so those Are sort of the things that you can expect here and last but not least there’s an attack entity as mob method which is basically called every time this entity attacks as you can see here what is basically happening is that this entity is being attacked right now and If that entity actually is a living entity then we’re just gonna add like these three potion effects so when the above zombie entity hits something you know it’s gonna add the slowness the weakness and nausea to that entity so those guys are actually pretty beefy right so that’s the basic idea of the Entity class those are going to be fairly similar like for all entities basically some of the main points are going to be there so the register goal method of course is going to be one of the most important ones because those are basically the goals this is the Behavior of the mob and if we now switch back to the mod entity types class we can now import this so simply go on here and then press alt and enter and then import this class and then all of our arrows will go away and then the next Thing that we can actually do is we can get the pigeon entity class i’m actually going to copy over the entire class here just one time and we’re going to add that and we will actually get one error up here this is the pigeon flying movement controller which is actually Also a custom class we’re also going to copy that one over like always everything is available in the description below get up repository or in individual gists as well and the pigeon flying controller basically is almost the same as the normal flying controller there are just a few Different changes i won’t go into too much detail here usually the normal flying movement controller should be enough however if you do want something that is more custom you can always extend those classes override the methods and just change a bunch of stuff right and then as you can see the error Goes away and here once again we have the attributes normally the goals and then we have some of the sounds the last thing that we have is here the get leash start position that is something that is a little bit different but apart from that most of the stuff is pretty much Exactly the same as with the buff zombie entity at least the types of methods that are in there and if we now go to the mod entity types we can import the pigeon entity as well and now we can go into the interesting stuff and that Would be the models but the models are going to go into a new package in the entity package and that is going to be called the model package and then let’s immediately also create another package in here called render because then we have it so in the model package we’re Actually going to create two models but we don’t really need to create those that’s where blockbench comes in so in theory when you’re in blockbench and yes i know this is a absolute masterwork um if you’re in blockbench what you can do when you have created your entity you Can go to file and then you can go to export and say export java entity and this is going to actually export a java class now this currently looks like this for me at least as you can see this was exported with mcp mapping so that’s very important when you’re creating your Custom entity you’re gonna basically say hey is this mcp or is this mojang mapping so the official mappings that’s very important that this is of course correct because if you choose the wrong ones then that’s not going to work and you can basically take this and copy This over and make a new class out of it i of course now have the two classes the two model classes for both the pigeon and the buff zombie already so we’re gonna copy those over right so here we have the buff zombie model as you can See a lot of different well cubes that were added and a bunch of stuff most of this is already generated from blockbench the only thing that is not generated from blockbench so if you were to actually recreate this model this is the only thing that is not generated This would be empty the set rotation angles method and there i can just say that what you have to do there is basically go through the other models and see what you really need so the head rotation angles simply make it so that the head can only rotate around for 180 Degrees and the rotation angles for the legs basically just are the swings that happen when you walk this is um also something that is barely boiler plate in this case because all models that are bipedal actually have those same things this is basically just a bunch of math Right you might see this and you’re going absolutely crazy no worries there i can tell you just go to the entity model and then you can press ctrl h and you can see all of the different models so in the ageable models for example there’s an insane amount of models biped Model for example is the model where where you have two legs so this is the pipe biped model and if i go down here you can see that the set rotation angles has a bunch of stuff in there down here basically the rotation for the right and The left leg this is basically exactly what we have taken as well there’s pretty much no way around it just try out a bunch of stuff that is pretty much the smartest thing that you can do and taking a look at the pigeon model it is fairly similar as well the only Difference here is that we have a right wing and a left wing which basically rotate around and those rotate around in a little bit of a different way so those actually have a little bit more of a swing to them however once again you have to just play around with the Numbers a little bit until you find something that you actually like once more just because maybe some people have skipped over it the rest of this class is generated by the blockbench export so only the set rotation angles really have to be changed right and then last but Not least we also need the two renderers and i’m going to copy those over as well once again everything available of course but they are actually fairly straightforward as well and as you can see the renderer in itself is actually fairly straightforward it simply points to the texture of this particular mob And also basically has the shadow size so this is the round shadow that is below a certain mob literally all it does same with the pigeon it pretty much is exactly the same it simply points okay this is point two for the shadow size and it points to a different Texture so those are basically the three classes you need for a particular mob you’re going to need a entity class you’re going to need a model class and you’re going to need a render class of course also need the mod entity types class and register your mob but that is Of course fairly straightforward another thing which of course is very important for mobs is going to be the spawn eggs but that’s the thing that we’re going to do next we need to create a new class this is going to be in the custom item Package and this is going to be the mod spawn egg item class this is going to extends the spawn egg item class right here i once again will copy everything over at this point things have gotten very complicated that you know just me typing everything out just doesn’t Really make sense a lot of this stuff is actually not too complicated it’s just a lot of typing basically we’re going to copy that over everything of course available in the description below and the two things that are interesting is first of all we’re going to have this Entity type supplier and then we’re going to have this field which is the unadded x this is basically a list of mod spawn x to which we’re basically adding our eggs that we are registering every time we register a new egg and then down here we simply create a Dispense item behavior so that the actual item knows okay if i’m in a dispenser and the dispenser fires what is happening we’re simply spawning a new entity here very easy and up here we’re basically using reflection to get the actual list of eggs so if i go into the Spawn egg item class by a middle mouse button clicking you can see that this is actually the list of all spawn eggs that are in vanilla and we somehow have to get this we’re going to get this via the obfuscation reflection helper which simply is going to get this private Value for us this has to be the unmapped name here by the way very important otherwise it will not work once you build the actual jar file and we simply go through register the actual dispense behavior with this and then we’re gonna clear all of them so the init spawn act Methods is something we’re gonna call in just a little bit but first of all let’s create the two eggs those are the simple and normal items of course but simply in our items class let’s just take the oil bucket and let’s call this the buff underscore zombie underscore spawn Underscore egg and let’s not forget to add that here as well buff zombie underscore spawn underscore egg and this of course is going to be a mod spawn egg item now this actually takes in a few other parameters the first parameter is going to be the mod entity types dot Above zombie without a get in this case because we actually want to pass in the registry object and then the second thing and the third thing is going to be basically uh two colors we’re gonna do a zero x four four f56 and then the last one is 0x1d 6336 comma there you go so this is the idea that it takes so those are colors in hexadecimal very important so you simply have to get the rgb values in hexadecimal and then if you put in a 0x in front of it then this is being interpreted as hexadecimal and those are Then converted later and then let’s also add the spawn egg for the pigeon so this is the pigeon spawn egg and down here also have the pigeon spawn egg and the colors are different so this is zero x eight seven nine nine nine five and this is zero x Five seven six abc those are of course customizable this simply changes the actual color of the spawn egg you can of course play around with those as well or you know just get a rgb picker online and that is basically all you need of course let’s remove the max stack size Here of course you can have 64 of those we don’t actually want registry objects of item we actually want the registry objects to be of type mod spawn egg item right and then let’s change this to the pigeon of course so that the pigeons won’t expose the pigeon as well right Now somehow we actually need to initialize those eggs how will be doing that well for that we need a new events class this is very interesting so in our events package right click new java class which is going to be the mod event bus events this is something i’m going To explain so the mod events here has an event bus subscriber and what we’re doing here is basically this defaults to the following so this is buzz equals and then we can actually say bus dot as you can see we have a mod right here and then we also have the Forge bus so this defaults to the forge bus but that’s not what we want because the events we’re actually going to use in here are actually fired on the mod event bus if that seems a little weird to you you can basically you can think about it as the following some mods are Fired with forge some mods are fired with mod that’s pretty much all you really need to think about there and this is why we need a second method because we need to actually define this so i’m going to copy over the add one at eventbus here and then we need two Methods which i’m also going to copy over quickly and those are of course once again everything is available in the description below i really highly recommend to get this because most of this stuff does not need to be typed out necessarily so the first method is the add entity attributes method which Simply uses the entity attribution creation event and then adds the actual attributes that we have defined in our well in our entity classes and adds them to the particular entities so this is very important this is an important step if you don’t do this then the actual Game will not start and then we also have this method right here which is actually the register entity event so this is fired when the entities are registered and inside of there we actually initialize the spawn eggs if we initialize them anywhere else then the second swan egg will not have the color That was a an issue i have that i’ve been dealing with for a long time and this actually has been solved by pharaoh as well so this is the pollution pharaoh has found that i don’t know how but i’m just gonna be a happy camper and say That this is basically what we need right we also need item models for the actual eggs so i’m simply going to copy them over and i’m going to show you them they simply point to the item template spawn egg that’s all you really need to Put in there and those of course have to have the same name once again as your mod items here so as this one and this one that is of course fairly straightforward right and while we’re down here we basically have to add the textures as well so those both go into The entity folder here this is once again the buffer zombie and the pigeon kind of looks like this this is for example the pigeon and then let’s also add the translation to the items right just like this so that the spawn eggs actually have names right and then In our tutorial mod class we want in the do client stuff outside of the unq work runnable actually we want to call the following and that is going to be the render registry and then register these two and we simply have to import both of those here and then that’s fine so this Simply puts the renderer to the actual entity yeah that’s that’s pretty much it right and those are actually all of the things that we need to do to add the mobs and the spawn eggs so let’s first of all see if it works and see if our Mobs are actually in game all right we find ourselves in minecraft once more and let’s see so the actual spawn acts have been added now it’s very important is that we’re actually on difficulty easy so that the buff zombies even spawn so let’s set it down and there it is it Actually works and of course they’re gonna burn immediately let’s try to give them some shade and there they are so that’s pretty cool and let’s see if the pigeons also work they also work completely fine and they’re gonna be flying around so they shoot up into the Sky really fast so the actual goals um could be maybe change a little bit the actual fly uh controller there as you can see they they zip around quite crazily but that is something that can of course always be changed and then so the mobs are actually in Game so now let’s see how we can make them spawn in the world by the actual classes that we need we actually only need one class in our world agenda package which is of course going to be the mod entity generation and this will have a public static avoid on entity a Spawn with a final a biome loading event called event and in this one we’re basically going to spawn our entities now what i will do is i will actually copy over the three methods that are in this class once again everything of course available and then i’ll explain Quickly what is happening here so this is basically a creation of my own and the idea is that you have either the add entity to all biomes which well simply adds the entity to all biomes then we have the add entity to specific biomes where you can basically put in different Registry keys for biomes you can basically say okay the entity should only spawn in those biomes and then what you can also do is you can say add entity to all biomes except these so you can actually make it so that the entity spawns in every biome except the ones That are passed in so this is really a fairly cool thing to do and the way that we can then use this in the on empty spawn method we say for example add entity to all biomes then what we want to pass in is the event.getspawns And the second parameter is going to be a mod entity types uh for example the above zombie.get and then we have to pass in the weight the minimum count of entities that are going to spawn in a group and then the maximum count let’s say for example weight is going to be 40 Two and four so there’s minimum going to be two zombies and the maximum gonna be four zombies and those are actually going to spawn in every biome so this is going to be to all biomes and then for example we could then say something like add entity to all binds except these Right the first parameter is actually only going to be the event not the spawns this time and then we have the mod entitytypes.pigeon.get and then we get once again a weight let’s do 50 and the minimum count is going to be four maximum count is going to be 10. if we Were to do this then actually the region would also spawn in every biome but now we can actually specify some biomes so let’s for example say biomes dot let’s say planes sure and then let’s also same biomes dot beach and then let’s take one more biomes dot let’s just say for Example something like the birch forest so now the pigeon will spawn in every biome except for those three and the same way the add entities to specific biomes works where you can basically pass in as many biomes at the end there as you would like and it is simply going To work how does that actually do it well i have made a little comment here so it goes through each entry in the biomes and sees if it matches the current biome we are loading because of course the biome loading event is called for each biome that is loaded and we’re Simply going to say okay we have multiple biomes here that we’re going to pass in we’re simply going to make a stream out of it and then we’re going to say okay get the location get location basically if i middle mouse one click on this gets the location which is actually The resource location of this so this is simply going to be the resource location minecraft colon and then whatever the name of the actual biome is and then we simply go going to say okay if there is any match with the actual location inside of this event so this event here Let’s just say that we’re currently loading the planes event then event dot get named to string is going to return minecraft colon planes and if we have the biomes planes in here then one of those is going to match so this is why i took in any match if the biome is Actually the case then we’re going to say okay in the accept these we’re not going to spawn it when we actually find it and down here we are going to spawn it when we find it that’s the general gist here once again incredibly useful to have some intermediate java knowledge So this is definitely some intermediate java stuff right here if you don’t quite understand it that’s totally fine that’s not the worst thing ever but once again this is another appeal to basically learning some java so that you can completely understand this and then of Course this has to be called in our mod world events right down here so we’re simply going to call this at the very end this is going to be the mod entity generation that on entity spawn with the event right here and that is actually All that we’re gonna need to do so now let’s see if it works right let’s not forget to make a new world for this just in case usually the entity spawn should also work even if you don’t have a new world but that’s just gonna make sure That everything works fine all right we found ourselves in minecraft so let’s see first of all if we can find some pigeons somewhere around here at the moment we’re not finding anything but i’m sure there it is so there are some pigeons right they are in the water but this would be the Tiger biome and we can for example in theory go to a plane’s biome just in case so let’s go to a plane’s biome and in theory if we’re in the plains biome we should not find any pigeons in here however we could of course find them you Know sort of at the edges so in river biomes they would still spawn and stuff like that in the plains biome itself they should not spawn now let’s also make it a night so time set knight and let’s see if some of our buff zombies spawn making of course sure that we’re At least on difficulty easy otherwise the actual monsters don’t spawn of course and there are some of them already there there you go so that’s actually the mod mob generation also completely done right and now i hear you say wait that can’t be it that’s that’s All that there is to it so this is basically it to summarize one more time for an entity you need three things you need the model you need the actual entity class and you need a renderer then the mod entity has to be registered in the mod entity types method you will Also need a mod borne egg item class and also a mod eventboss events class right here which adds the entity attribute to the entity attribute creation event and then also calls the mod spawn egg item in the actual registry method right here for the egg items you need the item Models as well as translation in the en underscore us.json file and then once again for the entities you simply need to add the actual textures in here as well and those are of course defined in the renderer but usually they should always be on the same under the same Location basically textures entity and then the name of the actual mob png apart from that most of the other stuff is something that you will just need to play around with basically adding a few different goals trying to make it so that the actual mob behaves in a way That you want and once again thank you very much for pharaoh link of his twitch is in the description below so maybe leave a follow there and write some nice words or something like that when he’s live next time otherwise that would be it for this tutorial right here i Genuinely hope you found this useful if there are any questions don’t hesitate to ask in the comments below the entire code is of course once again also available in the github repository as well as in individual gists as well i hope you learned something new if you Did i would first appreciate like but then don’t forget to subscribe for more tutorials just like this one so yeah Video Information
This video, titled ‘Add CUSTOM ENTITIES to Minecraft 1.16.5 | Forge 1.16.5 Modding #38’, was uploaded by Modding by Kaupenjoe on 2021-10-18 14:00:02. It has garnered 18913 views and 392 likes. The duration of the video is 00:27:38 or 1658 seconds.
In this highly awaited Minecraft Forge Modding Tutorial, will add CUSTOM ENTITIES to Minecraft 1.16.5 using Forge. This includes SpawnEggs AND custom Entity World Generation! Let’s GOO!
== MAPPINGS USED THIS TUTORIAL == mappings channel: ‘snapshot’, version: ‘20210309-1.16.5’
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Minecraft-1.16.5/tree/37-customEntities Gist: https://url.kaupenjoe.net/yt78/gist Mob Textures: https://url.kaupenjoe.net/yt78/textures SPECIAL THANKS TO FEROOV: https://www.twitch.tv/feroov
== TIMESTAMPS == 0:00 Intro 0:32 Credit where credit is due! 0:50 Registering the Mod Entities 4:17 Creating the Custom Entity Classes 9:45 Creating the Custom Entity Models 11:01 Something about the setRotationAngles method 12:34 Creating the Custom Entity Renderer 13:23 Making the Spawn Eggs for our custom Entities 15:02 Registering the Spawn Eggs 16:55 Adding another Event Class 18:03 Using the EntityAttributeCreationEvent to add the Attributes 18:51 The JSON Files + Textures 19:30 Registering the Renderers for the custom Entities 20:03 Demonstration #1 20:49 Making our custom Entities Spawn in the World 24:50 Demonstration #2 26:02 Summary 27:14 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 *
== 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
== 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