Hey what’s going on guys teddyworthy here and welcome back to another minecraft running tutorial for version 1.18 in this tutorial i’m going to be covering natural entity spawning and so we can get our entity to spawn naturally i meant to cover this a while back but i Completely forgot about it so let’s just get started so the first thing i want to do is i kind of want to repurpose our or generation class or at very least this class right here is what i want to try and repurpose so i’m actually going to i’ll keep this actual or generation Class i’m just going to go ahead and take this out and put it in its own class so let’s come into our event package which we created a few episodes ago and let’s create a new class i’m just going to call this a forge a common forge events okay And i’m simply just going to copy paste this whole thing and make sure i also copy paste this top level annotation there we go and now i can just remove that from in there there we go much nicer okay so this should all work perfectly fine since we’ve just copy pasted it we Should have no issues there is one thing i do want to make sure i do and that is to set the priority To event priority.highest this is generally something you want to do with the biome loading event specifically just to make sure it does run you want to make sure it’s a high priority so that it runs correctly now what we want to do in here to get our Entity to generate is we need to go ahead and register a spawn for it and we can do this by going event dot get spawns and this will give you the mob spawn settings builder so this is a builder that you can add to And in here we just want to do add spawn here you can type the category of mob that you want to spawn so i’m going to spawn in my entity i’m just going to give it creature not sure exactly what this category does i don’t know if It does anything specific but i assume not well i actually assume it must otherwise it wouldn’t ask for it but yeah i’m not sure i don’t think it’s too big of a deal but i’m sure you can test out the different ones and see what it changes it must change something And then for the second parameter we need a spawner data so this is just the data of what we want to spawn and this is very simple so it’s just a new spawner data first we can provide the entity type so it’s just entity init dot example entity dot get Then it wants the weight so basically the higher the weight the more there will be i’m going to give it a weight of five and then is the minimum and the maximum spawn groups so i’m going to set a minimum of one and there will be a maximum of seven So that is basically how many will spawn per time let’s just import spawner data now let’s say you wanted your entity to only spawn in planes biomes right which is a fair enough thing to want now if you try to do if event they’ll get category is equal to Where is it biome category if it’s equal to buying categories of planes you’ll find that there are multiple planes bombs there’s not just one planes button so that’s not really gonna work the way i’m going to do this to get it to work in a specific one is to use the get name And we can essentially do dot equals or maybe compare two but i’m going to do dot equals and i’m going to say a new resource location minecraft colon planes and essentially what this will do is only if the biomes registry name is minecraft planes will this actually add the spawn okay So that’s how we can go ahead and do that but this alone won’t work because we need to tell it how it will spawn so by that we we need to give it a spawn rule and then register a spawn placement for it so this is also very simple to do Let’s come back into our entity class which we haven’t touched in a while and in here let’s just create a public static boolean and we’ll just call this can spawn now this is going to need to take in a few things for this to work so this is Going to take entity type and then this is our entity class inside of here so for me that’s example entity and we’ll call that entity then we need to give it a level accessor and i’m just going to call this level access then we need to pass in a mob spawn type And i’ll call that spawn type then we need to give it a block pause pause and finally a random random and there you go import all of those things so these are basically the in here we need to return the rules for how the entity should spawn Now since my entity is just an animal you could just return animal dot check animal spawn rules and pass in all those things and i’ll just simply do the default animal spawn checking which if you look at that it just checks for the animal spawnable on and it also Checks if it’s bright enough say if you’re using a monster okay a monster entity you could just say monster dot check monster spawn rules um i believe there’s also one for water creature so water creature water animal you can say water animal dog check surface water animal spawn rules Check mob spawners there’s a bunch of different default vanilla spawn rules that you can use i’m going to just use the animal spawn rules so animal we can actually just call that statically because this is an animal class and then i’m going to provide some other If checks as well so i’m also going to say and level access is instance of level and i’ll just call that level if that’s the case and then i’m going to check level that is raining that’s pause so what i’m doing here is i’m first checking the animal spawn rules now if They succeed it goes on to this check right here it checks if it’s an instance of a level which it should be and then it checks if it’s raining at the provided position this is just so that my animal will only spawn if it’s raining now the reason i’m doing this if check Right here is because this is raining at method simply does not exist in the level accessor class it only exists in level it’s a bit of a weird mojang thing there’s like 50 different layers of levels so if you like open implementation you can see there are a lot of different levels Different level types and yeah there’s a lot i don’t know why there’s so many i i could not tell you there are just a huge amount of them um but yeah so we’re just checking that it’s just a normal level which it should be we can assume that it would be So now we can close that and let’s come into our common mod event yes let’s let’s go into our mod events now inside of our common setup which we created a few tutorials ago quite a few tutorials ago we can do another event.nq work and this needs to be a runnable so We can do a lambda for spawn placements dot register so this is us registering the actual placement uh functionality so it knows what rules it needs to check and we first need to pass in the entity type that we’re registering this for so for us that’s entity inits and then For me that’s example entity and then we need to put dot get then we need to provide how it will look for a valid location so here that we need to pass in a type and i think this might be more helpful if we actually go ahead and say spawn placements Dot type since there are loads of type classes and we can check for in lava in water no restrictions and on ground so i’ll just quickly go through where each of these are used so in lava this is used for striders to check that they are spawning in the lava In water is used for things like squids fish um all those different water creatures no restrictions this is generally used for flying uh entities things like phantoms for example and i believe ghasts probably use those as well and then finally on ground is used for basically everything else so cows pigs sheep Zombies skeletons creepers um villagers images etc etc most things used on ground so to make it simple to find and since it’s in the plains biome only i’m going to say on ground finally we need to provide it the height map that it’s going to use So if we just type in height map or maybe it’s not called height map it is called height map okay so we can do height map dot types it’s just an enum and there are a few different types here i’m not sure why they’re not showing up eclipse is playing around Okay if we just type in types we should be able to see them so there is motion blocking motion blocking no leaves ocean floor is from floor wg world surface and world surface wg so let me quickly explain all of these so world surface is just checking for the Normal world surface pretty simple ocean floor this just checks for the normal ocean floor nothing too complicated motion blocking we’ll just check that there is no uh blocks in the way essentially and motion blocking no leaves will check um essentially that there’s not leaves either so it has to be A solid block so most just normal motion blocking will allow something like leaves it will allow um essentially all those not solid blocks per se so like glass leaves um i can’t think of anything else for some reason iron bars there’s a bunch of different things but motion blocking won’t check for those Motion blocking no leaves will check that they are not there now ocean floor wg and world surface wg i’m not entirely sure about i can’t entirely remember what those specific ones were four i’m going to be using world surface of course and i’m going to change this back to Height map dot types so that i can know for the future just put a semicolon on the end there we go and finally we need to give it the actual um spawn predicates for how it will spawn and this is really simple so it’s just example entity colon colon spawn And voila that works perfectly fine now you will notice we now have free nq works and we don’t need three we can just have one so let’s also alter this while we’re here let’s go event dot nq work let’s just do a simple lambda and give it a body And get rid of that bracket that trailed and let’s just call our methods in here so or generation dot prejudice.org packet handler dot in it and let’s take this out of here and plug that in there that way we can remove both of these ones and we will just have All of it inside this singular and q work that’s just going to make it a little bit cleaner for this method that’s actually it we can now go ahead and test this so let’s just run client and we’ll see if it works here we are in the game i have been Searching around for a while and i haven’t actually been able to find one but i know they’re spawning so if i do slash kill at e brackets type is equal to tutorial mod example entity it kills six of them right and i’m just gonna fly around a little bit To see if it’ll spawn a few more but i just can’t seem to find any and it’s so weird because i know they’re spawning i think it’s just because i’m absolutely mind boggled by the fact that this is all the planes biome and that’s really throwing me off Actually looking for what i’m trying to find but i i just can’t see any um because like seriously like bro we are at why 180 in a plane’s biome like bro come on now that is just that’s just illegal but yeah i mean i can’t find them even Though i know they’re spawning so i will admit i did change the code a little bit so instead of checking for it raining i checked if the y is greater than 70. um i think the raining did work as well but i’ve changed it to y70 just in case the raining wasn’t working Um and i didn’t find any either way but i know they’re existing i just can’t see them for some reason oh speaking of there we go wow i’ve literally been searching for what like 20 maybe half oh i forgot how loud they are um well There they are then let me just uh turn these down so i can actually go and see them i’ll just turn that off because they’re loud but yeah here they are i was just about to run a command someone sent me a discord and uh well here they are interesting For reference the command that i was gonna run let me just find it so i was going to run slash tp at s and then at e type is equal tutorial mode and then example underscore entity limit is equal one that’s the command i was going to write And yeah that would have brought me to this sexy guy down here hopefully i can find another one to prove the point that they are actually spawning um but they’re so hard to find i don’t know why i don’t know if maybe the weight is just i’m sorry this is just mind-boggling i Don’t know if the weight is maybe too low or too high maybe um yeah i mean at least they are spawning i guess there’s a village down here so i’m probably not gonna find one here okay but if i run that command again i bet it will find one a different one Yeah it did it found a different one so i they’re spawning that’s all i can say i guess so uh yeah that’s that’s it for this tutorial i hope you guys did find this useful if you did please do be sure to go ahead and shove some ice cream in your ears and Then press that like button and you also might as well subscribe as well if you really enjoyed or found it useful please do be sure to share it around and uh yeah i will see you guys in the next tutorial good bye also make sure to join my discord server Link in the description Video Information
This video, titled ‘1.18 Minecraft Forge Modding Tutorial – Natural Entity Spawns’, was uploaded by TurtyWurty on 2021-12-20 00:30:09. It has garnered 2602 views and 63 likes. The duration of the video is 00:21:14 or 1274 seconds.
In this video, I cover how to make our entity spawn naturally in the world.
Join my Discord Server, to receive support with your modding related questions: https://discord.gg/jCTnnhxc7J My CurseForge where you can find my released mods: https://www.curseforge.com/members/realturtywurty Github Repository: https://github.com/DaRealTurtyWurty/1.18-Tutorial-Mod Check out the trello: https://trello.com/b/6lLTY9js/118-modding-tutorials