Oh yeah let’s add a custom mob to Minecraft new topics added to the fortune fabric courses such as table and writable entities projectiles throwable projectiles and boats as well as first steps to biomes and dimensions courses Linked In the description below oh oh right we found yourself back Intelligence more and in this tutorial we’re gonna be adding a custom mob to Minecraft and this is going to be including custom animations so let’s take a look at the mob over here so this is of course going to be our cute little porcupine right here and the porcupine It’s gonna be vanilla only so no need for gecko lib if you want to make your own custom entity of course you will need blockbench I do have a guide on blockbench I think it is for gecko lip but the same idea applies basically you Want to create a custom mob right here a custom entity and what’s very important is you want two plugins and those plugins are going to be the following it’s the animated Java plugin as well as the animation to Java converter and I believe for fabric you should also get The fabric modded entity and with all three of those then you should be good to go and what you then have is you have an animated Tab and you can see that we have a walking animation another walking like the animations I made those myself they are not listen okay they are Workable right they look they look fine they’re okay a but they’re not the best the model was done by someone else and then we have an attack animation which is this I actually think this is really cool right so it like sort of extends and then you know the the quills just Like you know extend it’s pretty cool there’s also a sitting animation which we’re not actually going to use but it is there and available and of course the blockbench file as well as all of the other files and the code and everything Linked In the description below Available to you for download now when we have a blockbench file what can we do with it well we need to export quite a few things namely three of them so we want to go to file export and then export Java entity if this does not Appear then you want to make sure that your project right under the convert project basically that the current format is modded entity that’s quite important so do keep that in mind for the blockbench files that I will provide that should be the case so we want to Export the Java entity this is going to export a Java file so we’re just going to do that exporting the porcupine model right here we then want to go to file export again to export animations to Java in this case we wanted to select the your mapping is very important for Fabric of course I’m just going to call them the porcupine animal over here and save that as well and then lastly on the texture we want to right click save as and porcupine PNG is exactly right so there you go so those are going to be the three things that we’re going to Need to export from blockbench and now we can proceed back to IntelliJ and actually calling the entity so entities are they’re interesting let’s just say that so let’s start in the tutorial mode package and we’re going to right click and make a new package called entity Inside of there we’ll need a couple of other packages number one is going to be the client one then we need another package in the entity package that’s going to be the custom I just like to put that basically all of the custom entities in there and then the last one Is going to be the animation package there you go so we can start by actually adding a class in the entity package itself that’s going to be the mod entities this is where we will actually register all of our entities and there’s a couple more things that we’re going to Need let’s just create all of the different classes that we need in the custom package we wanted the poor coupon entity see there you go then in the client one we can create the poor coupon renderer and in the animation in the client we can also create the mod model Layers and then in the animation we can create the mod animations there you go I believe that that should be all of them what we can then do is we can take the porcupine model Java file that we have exported from blockbench and we can Actually insert it or you know add it to our client package you will be met with this mess which once again first of all calm down there’s a lot of red but it is not as bad as it might seem because you can see right here the class name does Not match the name of the file which of course we have to fix immediately so this is going to be poor Q Pi in a model and you can see you know things start getting way better I think a similar thing here poor coupon model this is Just going to be the Constructor we can delete the model layer right here and then basically the only thing we want to do now all of the red marked words we just want import so you click on this and press alt and enter and be sure to import the correct class over here Netminecraft entity entity model import that as well and then you basically just go through each of the different classes over here so you can see that the layer definition right here is not actually available now why would this be the case this is the case because for some reason It even though it detected that this is a fabric Model it did not properly do it because you can see that the export version it’s very strange that why it’s very strange that why it does that but basically you want to go to file project And you want to make sure on the export version you select the you select fabric 117 plus confirm and now we need to re-export the Java entity because otherwise it’s going to use the wrong mappings for some reason so what we can do is we can just delete the porcupine Model again re-import it and then we should actually be able to see that this is so there you go look at this we even have the correct name over here and now we have all of those different parts I suggest what you do is you you just delete them you just basically delete All of them except for the porcupine itself because they are just not necessary and now we do the same Spiel basically just importing the correct classes over here and now look at this this one is available and now this one is available and now all of them are Available just like we would expect and there’s another one over here no dilation is also in there so that is totally fine entity model also import that and then at the very bottom you can see there’s a lot of things going on right basically the model part data Right these are all the individual pieces of the model that are basically represented as code in this case and there we go if we import these set angles and the render method over here then everything is fine and no more errors should be present but we’re not Quite done just yet because we actually wanted to change just a couple of things and that is that the actual porcupine model right here should actually first of all be of a type T extends porcupine entity and then the entity model should not be an entity model but what it Actually should be is a single Port entity model of type T the reason why we’re doing this is so that it it’s easier for us to do the animations we’re going to fix the error in just a second we also just want another private final model part right here and that’s going To be the head and the head we’re going to do the following way we’re going to say occupying dot get trial we’re going to get the body then we’ll get the child of that which is going to be dot get child poor so and then we’re going to Get the child of that which is going to be called head there we go now you might ask yourself how do you know that that is the way to the Head well if we go back to blockbench for a second you can see porcupine is the root then we have The body then we have the trial torso and then here we have the trial somewhere right here the head and if I were to for example rotate the head around you can see that is exactly the headle that was that was a neck breaking speed over here we don’t want that but Yeah you can see that is basically the head how you can basically find the specific model part like that and to fix the arrow right here we basically just want to go down all the way here here instead of an entity this could be now a porcupine entity and all of a sudden Everything is saved and that should be at that which one is the issue oh they get part of course so here we have the get part this is the root part basically you just want to return the porcupine that we already have and that is basically everything that we are going To need here of course all of the code is available to you as well so no worries at all the reason for this era is going to be fixed in a moment because right now the porcupine entity you know it’s an empty class so it doesn’t do Anything once that is changed then this error also goes away and there you go so no worries at all and that is actually for now everything we need to do in the model class in a bit we also need to set up the animations there but let’s first Of all continue to go to the actual entity itself so that’s going to be the porcupine entity this will extends the animal entity class and we shall hover over this implement the Creator trial method hover over this again create Constructor matching super and there we Go making sure that this is going to be set to public here the Constructor very important and there we have it now when it comes to entities they can be well I mean quite complicated and there is a lot of them but what you have at the at Your disposal is basically all of the different classes from vanilla so if you go into the animal entity class for example you can middle Mouse one click and you can go in here if you have the blue line right here what you can do is if you haven’t done this already you can Open the terminal dot slash Gradle w gen sources and you just let that run through and once that is done we can actually get the proper like sources for Minecraft is always highly recommended to do this I did I believe also show this in the first tutorial about you Know sometimes people forget about that or something like that but you know let’s just let this run through and then we can actually see the proper one instead of looking at compile decompiled stuff all right so we are done here built successful in about two minutes And what we can now do is we can choose the sources and we have this Dash sources jaw right here if we say okay all of a sudden we now have the proper sources there are only tiny differences usually there aren’t great but it’s still better to have that because now we Can basically just go through all the different entities that you see mob entity and I keep just middle Mouse by clicking on this and you can see it is a crazy tree until we reach entity right here and once we reach that we can press Ctrl H and now we can see and expand every single entity class that exists in vanilla and I cannot recommend enough to basically just be like I want an entity that basic kind of works like a guest bam you go into the gas you take a look At it they’re like oh something doesn’t add up here well you go to the Flying entity maybe there’s something in there that’s interesting like I just cannot recommend enough to basically just take a look at all of the different classes that are available all the different entities if you have a specific entity That you want to make they are probably the best resource that you can have of course this means that you need some Java knowledge to understand that everything that’s happening but that is just how it’s going to be I mean I’m going to just keep saying that it is What it is now with this done the create trial method is going to get a deliberate error right here because for now I just want to get the two most important things in here and that is going to be number one the attributes as well as the goals so we’re gonna make a An entity without any animations for now we’re just gonna add it this it’s gonna be fine it’s going to be like it’s going it’s going to work and then we’re going to after that as the animations as well so this is going to be two things the Goals as well as the attributes let’s do the attributes first this is going to be a public static default attribute container data Builder this is going to be the create poor coupon attributes and it’s going to return mob entity mob entity dot create mob attributes and then we just add different attributes so For example entity attributes dot for example Max Health right we want some Max health over here maybe 25 is a little bit much maybe 15 is a little bit better and then we can add another one so entity attributes dot for example the movement speed where is the movement Speed right here so movement speed is 0.2 for example there you go and then we can add another one entity attributes that maybe armor maybe just armor or something like that right maybe at a I don’t know 0.5 or something like that something and then we can also add Attack damage entity attributes dot attack damage there you go and the attack damage may be A2 here as well there you go so as you can see the attributes basically you know it’s Health it’s it’s movement speed things like that they are quite important to well basically to have otherwise you Will run into some issues and we need to also register those now you need to register those we can’t do that just yet because we first need to register the entity but you know one step at a time because the other thing that’s quite important are go balls for this you want To override the init goals method right here and what we wanted to do is we basically wanted to add goals to a goal selector so we can say this starter goalselector.add then we have a priority so priority the lower the priority right so zero would get executed before 1 Before 2 and so on and so forth so the lower the priority quote unquote the the sooner it gets executed basically and basically the the number one priority that you always have is going to be the swim goal because otherwise your your mob if it is in water it’s just going to Sink and uh yeah and it’s going to drown so that’s usually not something you want so highly recommend it to basically always put the swim goal at the very top over here with priority zero and then we can basically proceed so we can add a couple of other priorities and goals Right here so those are going to be for example the and the new anime animal mate goal so this is going to basically have when when given the proper food they are going to mate over here and then we have have the another goal for example maybe a priority three attempt Goal this is going to be this and maybe a a 0.25 increase and then we have an ingredient of what exactly of items maybe it’s going to be um maybe it’s going to be item start I don’t know what they eat beetroot something like that maybe something yeah Beetroot why not and then this is going to be false they cannot be scared and you can see that there are a lot of gold and a lot of different things that you can do once again with the same idea you can middle Mouse one click on a goal and You can then click on the goal control h and you have every single AI like every single goal available in vanilla over here that you can take a look at right the the calm down goal shoot Fireball go from The Blaze we have a move goal from The Slime that there are so many different goals as you can see so many different examples if you’re like oh I want really want to have a custom entity with like a custom AI you have it all there it’s impossible to show every single type of idea or something that You want so I cannot recommend enough go through the goal class take a look at how it works take a look at some examples and that that is the best way that you can basically do this and implement the entity of your dream so to speak I’m just going to implement a few More goals over here we’re gonna have the follow parent goal this is going to be fine yep and we have a couple of more just random ones there’s going to be the Wonder around Fargo that’s going to be fine but it’s going to be a normal Speedier 1D and then maybe two more and that’s gonna be five and six this is going to be the look at entity goal with which is going to have a another second parameter which is actually the player so basically you can select which and that is going to be 4D a 4f actually Or a range so you can actually see you can actually select which which type of entity this should look at which I find really cool actually and then there’s also the look around goal which is just going to make the entity look around a little bit more and there you go so Those are some example goals over here once again you can try this out take a look at what goals are available try to you know use them and you should be able to see and really customize your own custom entity there but those are the basically the two big things and now we Can actually register the entity in the mod entities class now for this it’s actually as simple as saying public static final entity type of type porcupine entity this is the poor coupon equal to registry making sure we choose net Minecraft registry extremely important that register Registries dot Entity type and then a new identifier and then a new identifier of tutorial mod.mod ID or poor coupon fabric entity type Builder dot create with a spawn group of creature and then porcupine entity colon colon new after the first closing parenthesis dot dimensions and this is going to be entity Dimensions dot fixed And we’re going to do a 1 and a one it’s going to have a hitbox of basically one block by one block and then after the second closing parenthesis dot build and ending it all with a semicolon and there you go that is everything we need and Now we can actually also fix a few issues so the child over here mod entities that porcupine that create passing in the world and there we go now we have a baby porcupine here as well awesome and of course vital are the attributes very important here you can See that they are grayed out which means they are not used that means we want to go to the tutorial or class and call the fabric default attribute registry.register mod entities dot porcupine and then we can say porcupine T that create porcupine attributes and Bam there we go we have our custom Attributes also registered and now the entity should be basically almost good to go right so we still have the render as well as the mod model layers let’s do the mod modulators first because that is a little bit easier so this is going to be the public static final entity model Layer called poor coupon equal to a new entity model layer with a new identifier tutorial mod.mod ID and this is the poor coupon and after the first closing parenthesis we then have another string called Main and then no more errors should basically be present and this has to be connected with the With the model so this happens in the tutorial mode client class so this is going to be the entity model layer registry dot register model layers modulators.porcupine and then you get the porcupine model dot a colon colon get textured model data so what does this really do well basically it just Says okay whatever the data in here is there are the textured model data this is going to be our model represented in code right that is going to be registered more or less under the model layer of the porcupine that’s pretty much all we’re doing and now onto the Renderer which is actually one of the more easier classes the only thing that’s crazy is the extension over here this extends mob entity render of type poor occupied entity of type porcupine model of type porcupine entity so that is absolutely ridiculous but we’re going to implement the get texture method we Will then create Constructor matching super and here only a few things that need to be changed firstly in the Constructor you want to delete the last two parameters you only want to have the entity the context right here and then say New porcupine model entity context dot get part mod model layers Dot porcupine after the second closing parenthesis we then have a this this F is the size of the shadow that the entity casts 0.6 is going to be fine you can of course also change that however you see fit we’re going to have a private static final identifier called Texture this is the texture of the entity this is a new identifier to tutorial mod.mod ID textures slash entity slash poor coupon dot PNG and we can actually also add this this texture of course has been exported a couple of minutes ago from blockbench so we’re Just going to take that and we’re going to add it here in the entity folder and there we freaking go so now we have the porcupine PNG over here as well and we can basically just return that in the get texture method and then there’s Another thing that we can do and that is overwrite the render method right here and that one actually allows us to do some pretty funny things so for example we can say if the mob entity is a baby then what I want to say is I want to say Matrix stack dot scale and maybe I want to make this like half the size that it usually is there you go and if it’s else then I’m just going to copy this over and then it’s going to be not 15 times the size because that would be very very Big I don’t think that that’s a good idea but maybe one times the size so there you go so this basically will also scale down the baby by basically half make sure that all the XYZ coordinates are the same like the scaling Works in all the all the same directions because Otherwise it’s going to look very strange and now lastly we just need to connect the renderer to our actual entity that is once again done in the tutorial model client class so we’ll just so here we’re just going to say entity render our registry that register mod entities dot porcupine and then Porcupine renderer colon called new no errors should be present and we now have a custom entity it’s not going to have any animations but what you already would be able to do is you would already be able to lower it with beetroot and and it could mate but right now it would Mate with I believe we I believe that’s the default item but we can override that by saying is a breeding item and let’s just say for example stack dot is is of items dot beat root if right click two of them with beetroot then they’re gonna mate and they’re gonna have a Little tiny uh porcupine baby so with this first pass through let’s go into the game and see if it works alright friends was back in Minecraft and let’s just see and summon our porcupine right here and there we freaking go we got a porcupine now of course as you can Clearly see it has no animations it’s uh you know it’s very very interesting but what we can do is we can get ourselves some beetroot and look at this now they’re following me and I can right click them and we’re gonna get a tiny little porcupine baby right there look At him look at him go let’s go that’s awesome so that is going to be basically the first step for porcupines right and now let’s add not only the animations but a couple of other things as well and the couple of other things I mean of course Sounds because that is a question I get very often actually and you know sometimes it does amaze me because the literally only thing that you need to do is well if you go through some of the actual other classes you should be able to find this but if you just type in Sound inside of your custom entity you can see you can override the parts the death sound hurts on Ambient sound all of that you can override you can see how many different methods there are to override so let’s just over the Ambient sound right here let’s also override the Hurt sound so the get hurt sound and the get death sound here as well and let’s just do some crazy stuff so let’s how about for the Ambient sound we’re gonna do sound events dot maybe the fox ambient I feel like that makes a lot of Sense the hurt sound we’re going to do sound event start let’s do the entity underscore cat underscore hurt why not we could also do his but that would be kind of funny but let’s just do that and then the sound events here is going to be the dolphin def sound because I just I don’t know why but I really like to just use one of the dolphin sounds every time so there you go but and of course you can use your own custom sound events as long as they’re registered properly then you can also add those right here In the ambient hurt or death sounds as well that’s basically how easy it is to do sounds but now it goes on to animations and animations are a little more complicated but you know overall they’re not too bad what I highly recommend you do for the animations as a Reference I mean of course you can look at the code I’m writing over here but you can also take a look at the camel so this would be the camel entity if I recall correctly there you go so the camel entity so you can see that it has Some animation States and basically but it has some other things like the app that animations method and the update limbs method and stuff like that so there’s a few things that are quite interesting now the first thing we can actually do is literally just copy over the update limbs method because that is Is exactly the thing that we’re going to need so let me just actually go to the very top over here yeah let’s do it at the very top of it why not so we don’t have a dashing animation that’s fine but we do have an entity pose over here so We can actually just literally copy this and that that is going to be already pretty nice and pretty fine now we are going to need some animation States and a animation timeout that is going to be a public final animation State called idle animation State equal to a new Animation State there we go we’re also going to have a private int Port idle animation timeout equal to zero right here and then we will need a two methods actually number one is we need to overwrite the ticker method so that’s going to be the Tick method and here we want to say if this dot get World dot is a client then we want to do something and the thing we want to do is a custom method and that is the private void setup animation states there you go in the camel entity That method is actually called update animations either one works fine right I mean the name of this method doesn’t really matter it only matters that we call it right here setup animation states there we go and then what happens in here well funnily enough literally What you could do is you could just copy over this these the lines over here right Bam Bam and that’s it now we just need to change this this is going to be the idle animation timeout there you go so it’s not called cooldown but time out Here and this is not the idling animation State I call it the idle animation but as you can see apart from the names here the this is exactly the same because because in this case we I just basically took it from The Entity of the camel because it’s the easiest Way to well use it there’s a there’s a very apt example and that is basically the idle animation now it still doesn’t know what animations to play and what to do and stuff like that for this we of course need to populate the mod animations right here and how do we do That well we have the text file that we’ve exported like half an hour ago and what you can literally just do is copy all of this over and then just paste it in here and you just need to then import all of the different classes again and Once you’ve done that you can basically see and I need to go to the animation here as well there you go no more errors should be present and we now have all of our animations sort of also imported into our code and the animations are set Up in the model file so we can go to the model file over here the porcupine model and we can go down and in the setup angles this is where this all happens now this is extremely important the first thing in the set angles method yeah that you want to call is always This is that get part that Traverse dot for each model part Poland colon reset transform do not forget calling this if you don’t call this then every time your animation plays it’s going to get added onto each other until you know ridiculous things happen you have to Call this at the very beginning don’t forget it we’ll also have a little bit of a helper method right here that’s going to be the set head angles method and it’s going to take in a float head yaw and a float head and there we go and I’m just going to Copy the contents of this this is once again actually pretty much taken from the camel just so that the head rotates properly so this is going to be cold here head angles net head yaw net and then the head hitch right here and that’s it this is going to rotate the Head when it looks to the words the player as well as when it just looks around randomly so that is for what the head angles is for and now the animation the first one is the animate animate movement this is going to be mod animations that porcupine walk a limb Swing the limb swing amount then a 2 for the scale and a 2.5 here for the distance I just once again install those numbers from the camel you can of course change those numbers as well and see what happens and then the other one is the update animations where you actually Want to say entity dot idle animation State mod animations dot porcupine idle then agent ticks and then a one here for the speed multiplier and you can basically see we have now sort of fused the idle animation state from The Entity with the actual animation from our mod Animations and now it knows to basically play that animation when the Island animation state is called for start right so you can see that the island I should say that sort of happens here and if that happens then what is being basically displayed is the porcupine idle animation funnily enough that is Actually everything that we need to do so now the animations should be in game and everything should be set up but we’re not quite done just yet because just for the sake of argument I also want to add a a spawn egg because it you know we want to be complete over here Okay that that’s just going to be a good thing to do so this is going to be a public this is going to be a public static final item right here I’m gonna quote these poor coupon underscore spawn underscore egg equal to a to register item or coupon underscore spawn Underscore egg and this is a new spawn egg item mod entities dot porcupine and then the colors I don’t think the color is actually quite matched but I’m just going to take the ones that I have already basically created over here because why not and then after this one Is a new fabric settings and there you go now we of course still need to do a very important thing and that is actually add that to the data gen because the porcupine item has a specific item model that we want to do I’m just going to copy it over because It’s going to be the same thing for every one of your spawn eggs because you basically want to have a new model of item slash template spawn egg that is the way that the colors are basically going to be generated and then let’s just run the data gen right here and Then while that happens I can also add the translation for the spawn egg that is once again one of those things that’s not too important but you know it’s like you know while we’re while we’re at it why not also add that as well apparently 14 things were written I I don’t even Know which ones but it should be fine it should be okay and just to close this up we can also then add the porcupine sponeck to the item group and now we can go into the game and actually look at the beautiful anime nations of our Custom entity so let’s take a look and here we are in the game and look at this look at this look at him look at him go so this is absolutely amazing and this it already breathes so much more life into them when you know they turn their Head and they walk around a little bit and there’s just a tiny bit of movement over here now the animations I will admit they you know I made those myself they are not the greatest they’re not the best but they do work and they are well animations so that is really Freaking awesome and you can also hear the sounds right so that’s the cat hurt sound and all of that so everything working we got a custom mob with custom animations without any type of API right all done in vanilla absolutely freaking fantastic and next time in this video we’ll Continue with our report coupon by adding a custom attack animation hope to see you there so yeah Video Information
This video, titled ‘Fabric Modding Tutorial – Minecraft 1.20.X: Custom Mobs | #28’, was uploaded by Modding by Kaupenjoe on 2023-10-05 14:59:51. It has garnered 1700 views and 85 likes. The duration of the video is 00:29:58 or 1798 seconds.
In this Minecraft Modding Tutorial, we are adding a Custom Mob to Minecraft 1.20.2 – this is basically a Custom Entity with Animations all done in Vanilla Minecraft with Fabric. The custom entity is made with the help of Blockbench!
== MODDING COURSES == FORGE ▶️ https://url.kaupenjoe.net/CourseForge120X FABRIC ▶️ https://url.kaupenjoe.net/CourseFabric120X
== COMPATIBILITY == ✅ Compatible with 1.20.2 ❗Somewhat Compatible with 1.20.1 ( https://url.kaupenjoe.net/mbkj101/changes )
== SUPPORT ME ON PATREON == ▶️ https://url.kaupenjoe.net/patreon
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Fabric-Tutorial-1.20.X/tree/28-entity Zipped Assets: https://url.kaupenjoe.net/mbkj101/assets
== 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 ▶️ NEW Fabric Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseFabric120X ▶️ 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://url.kaupenjoe.net/patreon
== 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 ==
== 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