Hey what’s going on guys turkey rocky here and welcome back to another minecraft running tutorial for version 1.17 for forge in this tutorial i’m going to be covering how you can go ahead and do some ore generation so all generation is pretty pretty simple to be honest it’s a lot Simpler than it sounds um let’s just go ahead and get started shall we so the first thing i’m going to go ahead and do is go into our core package and i’m going to create a new package in here called dot world and inside of here i’m going to create a Class which is going to hold all of our or generation related things so i’m just generation okay get rid of that and i guess get rid of this too i don’t know why it’s generating those um okay now in here there’s three things we want to go ahead and create straight away and That is going to be three lists so let’s create public static final list and this is going to be of configured feature configured feature and this will take in two wild cards oh no wait never mind this will take in an or configuration not sure why autocomplete is not working here but uh Yep and then the second one is an all feature and this will be the overworld underscore and that will just be equal to a new arraylist okay let’s just import everything here so java.util.list of course okay now let’s copy this and i’m going to paste it twice and this one Here will be for endors this bottom one will be for never hoards here we go so if you only want over world doors of course obviously you only need this overworld one if you only want never ones you only need this never one same for end etc etc um i’m gonna add all Three but i’m not going to create an or for all three i’m just going to um yeah i’ll show you how you can add it for all three anyways so then we want to go ahead and create our method which will register the ors so that will be a public static void register Pause okay and in here we need to go ahead and construct a configured feature so what are configured features you may be wondering so they are basically just features with a configuration and a feature is um essentially a randomly generated structure i guess so also features uh trees are features Uh what else are featured there’s loads of features i mean you can just go into the feature class and make sure you’re going to the right course and you basically see a bunch of things so like fossils um mushrooms uh you know everything drip stone whatever they’re all features They are naturally generated things basically um and yeah it’s with a configuration so in our case it’s an or feature because we’re creating an ore and so it’s with the all configuration so what we need to go ahead and do is create our feature and this will be a configured feature And we will make these wild card and i’m going to be creating um well i just want to have glowstone ore so it will just be glowstone but it will generate as an ore obviously you can use your custom or block that you can create using the simple block tutorial um But i’m not going to be creating a special block for this because that would take a lot longer so i’m going to just call this glowstone i guess glowstone or sure um it is an ore so and that’ll be eat feature.or and then dots configured and that will take in a new or Configuration okay and in here this is where you can basically specify the target at which it should generate so i’m just going to use a list dot of obviously that is an immutable list because we don’t want the target to be able to change and this will take in an all configuration configuration Dot target and this just takes in a rule test so a rule test is basically a predicate for the blocks that can be accepted so i just want to have default stone here so i’m going to go or configuration dot predicates dot stone or replaceables you can see Right here there are a few default predicates so if you just want the normal ores basically you go stone or replaceables and then you want to go ahead and put the block that you want it to generate so for this predicate i want blocks dot stone dot default block state Now let’s say i wanted to generate my custom block instead we can change this to block init dot example block dot get dot default block state but obviously i’m going to use glowstone so it would not be like that okay okay click stop this it’s not letting me format it and i’m Not happy about that here we go no stop stop okay there we go and i can just change this back to glowstone so blocks dot glowstone not glow like a glowstone dot default block state there we go and obviously you can add to this list so you can have a bunch of Different uh essentially targets for this particular configuration so let’s say we also wanted a deep slate variant we can go ahead and do or configuration dot target and we could say all configuration dots predicates and there is obviously a deep slate one deep slate or replaceables And here i can just put a different block if it’s deep slate so for example blocks dots uh let’s see i don’t know a case you would default block state for example and then once you have come out of there you can see there is an integer that we that it needs And integer is basically the maximum count in a vein so i’m going to be putting that as 11 that means the maximum size of the vein is 11. and then you need to add some special configurations to this so we need to actually come out of this completely and then we can do In this order we can first do the range so this is basically the heights that it can generate at so there’s range triangle there is normal range and there is range uniform so i’m not exactly sure what the difference between all of these are but i just know Most always use uniform so that’s what i’m going to be using and here you basically can specify two anchors so two anchor points and the first one is going to be bottom since we want it to start at the bottom of the world and then from there we can give it a vertical Anchor dot above bottom and we can say that it will only spawn 20 blocks above this vertical anchor of the bottom obviously you could also do vertical anchor dots um top and that means i’m pretty sure that basically means actually i have no idea what that means This whole range stuff is very new to me i’m not entirely certain of what it means um but essentially for most doors you just want to do rescue anchor dot bottom and then you could say above bottom 20 blocks or you can also give it an absolute value which also works um Yeah if anyone does manage to figure out exactly what these different range things mean and all these different vertical anchors please do put it in the comments i will pin you if you manage to figure out what it means i have looked through the code i can’t Quite figure out exactly what it does um but yeah that’s pretty much what you want to do obviously you can go ahead and look at vanilla so let’s say i went to feature we can see the vanilla ones so okay this is the wrong class isn’t it let’s say where is or And we can see where that’s referenced which is uh features are of course yes the features are the actual features themselves are registered and made so we can look at here we go here’s the ores so you can just look at all the different ores here And if we go along we can see the vertical anchors right here um some use triangle i it seems that there is obviously a prototype of each of these ones which is probably what is going to come in 1.18 i assume and they’ve just left them in here and unused um It seems that the prototypes are using range triangle yeah i’m not sure exactly what all of these mean i don’t even know the difference between triangle and uniform i assume it’s just the way it generates um yeah so you can you can put it between two absolute positions As you can see here if you’re using range triangle you can say it will be between 24 and 56 so i assume this is just the lower bound and this is basically the upper bound that’s what i assume it is um but yeah then after that we need to go ahead and add Dot squared and then we need to add dot count which is basically how many there will be per chunk uh i’m going to put a hundred so there will be loads of them and basically everything will be lit up so what is happening here so You can see first we do the range and that obviously go ahead and does all the different uh y values so the maybe slightly confusing thing here is we actually start with the count then we square it then we go to the range so in the count right here we obviously set Uh the positions so this will create 100 positions in a chunk and with those 100 positions they will be squared and what that means is it will randomize the x and z coordinates so their x and z is between 0 and 15 in that chunk and then the ranges run and the y Positions are randomized between uh negative 64 and 256 or whatever whatever your range values here mean so yeah uh after that there is one thing we need to do and we need to actually register it uh i’m gonna leave that out for a second so The next thing we need to do is add it to these lists right here and it’s fairly simple so if i want it to be an overworld or we can do overworldors.add and we can just put in glo stone ore and you’ll see here that doesn’t work Because this is looking for a configured feature or configuration or feature so we can’t do that we can however i guess make these wild card i’m pretty sure that works too in fact that’s probably better yeah let’s do that let’s make these wild card that means we don’t have to do any Casting here so let’s say instead we wanted this to be an end-all we would simply just add it to the end ors if we wanted it to be another ore we added to the never always uh i want it to be an overworld or it’s the simplest to test Now as i was saying we need to go ahead and actually register this configured feature and that is so it doesn’t blow up when some mods uh try to access all the different configured features if it’s not registered it blows their mod up uh so it’s highly recommended to register it And we don’t use deferred registers for this because they don’t run at the right time and if i remember correctly it’s not thread safe or something uh i don’t know there was some reason uh other than that uh but yeah there isn’t a deferred register for it so we need to actually Use the vanilla registry so let’s create a private static and this will be uh we can just call this register oh and this obviously returns a configured feature but it is it doesn’t obviously return a configured feature but it does return a configured feature and this will need to take in the configuration And then the actual feature itself so the configuration here is just going to be config and then the feature will can be wildcard so this config here we need to specify this and we can use generics to do that so we can say config extends feature configuration okay And then we can go ahead and just do that have i done this wrong i have done this wrong because we need to put the name in the method so register there we go and let’s just import feature configuration there we go now this is going to take in The name of the feature and it’s also going to take in the actual feature itself so there’s a configured feature and obviously that is config and then wild card and that’s the feature uh i guess we could also just name it configured feature is probably a better more descriptive name Then in here we simply can return registry and make sure you use the net.minecraft.com.registry dot register and just like deferred registers this takes in the actual registry itself so because we’re using the vanilla ways we need to use built in registries and then dots configured feature And then this takes in the name which is a resource location so we can just do a new resource location okay and this will first take our mod id so we can go tutorial mod dot mod id and then just the name and finally we’re just passing the configured feature so config good Feature okay there we go this is uh yeah that’s fine and we just need to call that method before we add it to the list so actually i think we can okay what we actually can do i think because we are returning it right here Is we can just call register inside this add method and do register and then the name of our feature which i’m going to put glowstone underscore or and we’re basically just going to be adding that to the list that’s actually a lot better uh i think yeah that’s better And obviously if you want to create another or you can just copy paste this configuration right here and obviously change it to whatever so beans beans are good change this name right here of course that is very important to beans and we can go i don’t know we could go uh Acacia leaves as the default one and we could say Blue wall um actually yeah let’s let’s do this so let’s get rid of the second configuration and instead of stone or replaceables i want to make this never or replaceables and let’s make this blue wall sure why not let’s change the count so let’s say it’s only a count of three uh Let’s give it an absolute let’s do two absolute values here so let’s do an absolute of uh 10 no let’s do an absolute of i don’t how high did they never go i’m not sure let’s do an absolute of 50 and let’s do uh an absolute of 120 i think we can do that right i think so and actually let’s let’s sure let’s just go all out and make this a range triangle okay if i could type of course uh and let’s give it a count of actually i’m going to keep it as a count Of hundred it’s just easier to find and obviously beans or it’s not beans but i’m just gonna name it beans because because beans i mean you can’t disagree with beans uh yeah now obviously you can create your own targets so if you’re using the end for example instead obviously we actually Want to add this to the never not the overworld let’s say we want to create one for the end so you’re not let’s do that as well sure whatever and let’s call this um egg or uh because egg and let’s make this end almost and egg okay let’s make this um vertical anchor Dot top and then let’s say vertical anchor dot below top 10 i don’t know uh let’s make it a size of 14 i guess i you know let’s just go 15. um that’s not gonna work i don’t know why i did that um we’re gonna have to do Because the end islands are strange aren’t they i don’t know what levels they are specifically but we can do vertical anchor.20 vertical anchor dots uh 60 i guess and we’ll go back to a range uniform if i could type of course okay so obviously this won’t work exactly how we want it to Um because we don’t have a a right target for this so we need to create a predicate so if we go into this predicts class we can see here uh the different predicates so all it does is create a tag match test and tag match test you can see it Extends rule test so all we need is to create a rule test and if we open the implementation of rule test there are a bunch of different rule tests so the one i’m going to be using is block match test instead so let’s come into our class here And let’s go up to the top let’s create a public static uh final rule test and i’m going to call this end uh end underscore test is equal to a new block match test and this is simply just going to match blocks dot n stone there we go And that means we can just use end test in here also you can use tags with the tag test it’s better to use tags i highly recommend using tags it also means you can have multiple blocks so if i wanted to generate an obsidian pillars as well We couldn’t do that this way we would have to create a tag for that um yeah okay that is all of that the next thing you need to go ahead and do is actually add it to the world so this is a little more complicated so we need to Go ahead and create a sub class and this will be a public static class i’m going to call this the forge bask subscriber okay and then we need to annotate this class with at mod dot event bus subscriber this just takes in our mod id so tutorial mod dot mod id And then it takes in the bus which will be bus dot forge if bus wants to import fantastic then we can add a at subscribe event public static void now this is going to be the biome loading event so i’m going to call this method biome loading And then we pass in the biome loading event don’t worry about this too much um i haven’t covered events yet so this is probably going to be a little bit confusing i will be covering events soon but yeah just copy exactly what i have here and you should be fine Inside of this by unloading method you can just create a list of supplier of configured feature bigger feature and two wild cards we can just call this features is equal to event dot get generation dot get features and then that is decoration dot underground ores i will explain all this in a second Don’t worry and then we just want to create a switch of event.getcategory and let’s do first case uh let’s do case never okay and that’ll just be or generation dot never ors dot for each or features dot add supplier of or then let’s do case end or it’s actually the end We can do or generation dot endorse dot for each or features dot add supplier or and then finally default we can do or generation dot over world orders dot for each or features dot add supplier of all okay let’s explain exactly what’s happening here then shall we So this by unloading then this event will happen when all the biomes are loaded so more specifically when you click create new world it gives you the options all of there this is where this event is called and it will be called for each biome in the game Then what we’re doing is we are getting the generation settings for that biome and we are getting the list of underground oars from this decoration stage right here which is underground ores then we are switching on the biome category now essentially the biome category is how biomes are categorized Unfortunately we can’t actually get the biome itself from this event because biomes are done in json now so we can’t access the actual biome we can only access information about the biome so let’s say instead that you wanted it to be if event dot get category is equal biome category Let’s say you only wanted it to happen in the icy biomes you could simply do that and then you could go you could go features dot add supplier and you could add your specific or so this is where it gets a little more confusing because you have to actually Go ahead and get the ore itself um but you could you would have a list of like icy ores and you would go well you would actually probably just do a for loop like down here so you know you would copy this and instead of never always you would simply just do I see ors for example there is other information you can do stuff about so you have like the climate the depth of the volume special effects uh the name which is great if you want a specific biome uh you could do it based on spawns i don’t know why you would do That you could do it based on the scale of the biome so how large it is uh you can go into generation and see the other sort of things in here so you could do it based on structures based on surface builder uh based on all these different things Uh just not you can’t know the exact biome you can’t know the dimension which is really unfortunate um but yeah we we’re relying on people putting their biomes in the correct category it’s not great but that’s just that’s all we can do so basically we have the never here so If the category is never then it will add it to the nether oars it’s the end it adds it to the end oars and if it’s not the never or the end then it adds it to the overworld ores uh we can’t filter out custom dimensions here unfortunately uh it’s possible there’s Maybe a way to do it i’m not sure how i guess you could also check for the minecraft namespace so since you do have you have event docket name if you want to check that it’s from the minecraft namespace you can go get namespace and obviously then dot equals minecraft And obviously if it’s that namespace you could do essentially you would be doing if if this and event dot get category um does not equal biome category never and event dot get category does not equal biome category dot the end you could do something like that and Then do over world orders if you wanted and that would guarantee that it’s only going to be in the overworld but um it’s it yeah it’s it’s up to you if you want to do that that’s perfectly fine at that point i wouldn’t bother with the switch statement just make it an if But switch this statement is a bit nicer here because we can use the switch expressions so it’s only five lines uh but yeah now there’s one more thing we need to actually go ahead and do and we need to make sure that this register ors method is called So let’s go into our core and in event we created this common mod events class a few episodes back in the entity tutorial and in here we can add another subscribe event and that can be a public static void now this will be the common no did we Create the common setup somewhere else uh no we didn’t we didn’t okay so common setup and that is the fml common fml common setup event there we go and in here we can just do event dots nq work since we want this to be able to run Later we don’t want it to run at the exact time this method or this event runs and in here we just want to register our oars so since this one’s a supplier or a runnable we can just do or generation and we just need to import that And fantastic so that should be it for always let’s go ahead let’s run the game and let’s see if it works okay so as you can see i am now in the game and if i go into spectator we can go down a little bit here and we should be able to see If we go down to the correct y levels that our glowstone starts generating that is fantastic and it fills up the caves a lot of course because we went ahead and put it to a fairly high number i think it actually looks quite nice um we can also see our acacia logs which Are replacing the should be deep slate here but i guess maybe it replaces tough as well this is tough right uh i think yeah maybe it replaces tough too unless there is deep plate here which actually no there’s not that’s interesting uh but i assume and we actually just set it to Triangle so yeah there’s deep slate down here so because it’s triangle i assume that basically means it sort of uh doesn’t all form in one clump i’m pretty sure is how that works okay well now let’s go to the nether beautiful and we’re in a fortress wow okay that’s uh interesting Pretty impressive i would say now how are we going to find this blue app yep there we go so that is some blue wall as you can see it’s very small veins because we only set the vane size two three any more blue wall i don’t think so okay let’s go to the End oh my god yes it it does uh wow yeah so now your end is covered in gold um so yeah i mean that’s pretty as you can see it does work with the y levels i assume it’s too high of a level up here anyways uh yeah um That’s pretty much it so i hope you guys did enjoy this tutorial if you did please do be sure to smash your face into that like button and you know you might as well subscribe as well so that you do not miss my next videos So yeah i’ll see you guys in the next video good bye Video Information
This video, titled ‘1.17 Minecraft Forge Modding Tutorial – Ore Generation’, was uploaded by TurtyWurty on 2021-11-06 22:45:09. It has garnered 3602 views and 114 likes. The duration of the video is 00:36:53 or 2213 seconds.
In this video, I cover how to generate ores into all 3 dimensions (the overworld, nether and end).
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.17-Tutorial-Mod