Let’s generate some Json files with data generation and data generation to our project here for 119.3 for Forge and this is actually a quite interesting topic because this will allow us to generate the block stage Json files and the model Json files and even all of the crazy loot Table and recipe Json files all of this is basically going to be done in code and then they will be generated automatically this is also extremely important for World Generation because World Generation in 193 is basically Json file only and for that we need the data generation this is why we’ll do the Data generation now and then next two tutorials it’s going to be tree generation and or generation so let’s start with the data generation in the tutorial mod package we’re going to right click new package called datagen or whatever you prefer to call it but I Call it datagen and then we need a lot of classes we first of all need the data generators class and then we need to continue with some other classes the other one is the mod block State provider class there we go and then we’ll create the mod item model provider Class and then we’ll continue with the mod mod loot table provider and we have the motor recipe provider and then we also need the mod block loot tables there we go so those are all the classes that we need and we’ll start with the mod block State provider so as the name Suggests this will generate the block stays Json files and it will actually do a little bit more than that but that’s going to be really cool and this will extend the block State provider very important that we choose the correct one and that is the micro Forge client model Generators this is the one that we want to choose and we want to implement the register State and models method and we also want to create the Constructor matching super now this is going to be okay we can delete the mod ID over here because the mod ID we have under Tutorial mod so we don’t need to pass this into the Constructor and then inside of the register State and models here is where we basically register everything now I’m going to have one helper method now this is of course all available to you in the GitHub Repository and you can see this is the block with item where basically here we’re also creating a simple block item so this is a method that is already inside of the class over here that we’re overriding so you can see this creates a simple block and a simple block item This just makes it a little bit easier so we can say block with item and then we can just pass in mod blocks that for example black opal block there you go and then that’s it we can duplicate this and we can also add the or and then we Can duplicate this a couple more times to also add the Deep slate and we also add the N Stone and we can also add the Netherrack and there you go that is actually all that we need to do in our case to generate all of our block State Json fonts this will generate all of those exactly the way they are and it will also generate the block model files as well as the item model files right so that’s the first class done let’s continue to the mod item model provider over here that’s going to extend the Item model provider there you go once again we only add one class in this case implement the register models method and then hover over this again create Constructor matching super we can once again delete the mod ID over here and just use tutorial mod.mod ID and that’s Going to be totally fine now for the item model provider I actually have two helper methods in this case this is the simple item and also the handheld item so this can be pretty interesting for swords or any type of tool where you want the handheld look so the handheld Look is basically if you’re in a third person the way that you hold a sword is different than you hold a normal item and that is why you have two different methods over here but usually the simple item will suffice and the simple item is actually enough for both of our items so This is going to be the black opal as well as the raw black opal and once again that is it you just add all of your items over here with simple items now if it’s more complicated items then either you have to create your own custom helper methods and you can also Go to the item model provider to the model provider and here there are some methods that you could use so you can see this is a cube single texture with existing parents so there’s a couple of examples that we have here but usually in general the simple item for you know Every simple item is pretty much enough that is the more item model provider done as well let’s continue do we want to continue with the loot tables yes but for that we actually need to go to the mod block loot tables first because this is actually a class that we’re going to Use in the mod loot table provider in just a moment so let’s take a look at this first and that will extends the block loot sub provider there we go I’m going to hover over this Implement methods generate method absolutely we’ll hover over this again create Constructor matching super we actually get some Unmapped parameters but we don’t even need them because here we’re just going to put in set off and just an empty set and here we’ll say feature Flags very important this guy dot registry dot All Flags there we go we also want to make this public that’s also quite important Right we need to overwrite another method and that is the get known blocks method this is extremely important to get well basically correct so the general idea is that we want to know every block for which a block loot table can be created if we were to just you Know not pass it in anything and we were to generate loot tables for our blocks it would say trying to generate loot block loot tables for non-blocks and there’s of course now we Bond we want to basically tell it hey every block that I’ve registered and that would be in Modblocks.blogs right so this is the Deferred register and then we’re saying get all of those entries and then it gets a little complicated because now we’re doing some you know Insanity here with Java basically but we’re just creating a stream and then we’re mapping each individual element so basically Every one of our registry objects we’re saying okay what I want you to do for every one of those is just to call registry object get so this would be colon con get and then we want to make this in iterator because in this case we Want a iterable over here of type block and we get the blocks from our registry objects by calling get that is all that this basically does it’s basically just providing all of our custom blocks here in a iterable it basically just provides all of our blocks in a iterable form so That the class can continue using this so we need to generate a loot table for all of our blocks that we’ve registered over here that means that we will get an error if we don’t add all of our blocks now in our case case right if we go into Our blocks over here we only have a couple of them so we don’t have that many and that’s going to be okay so we can say for example this is going to be the easy one this is drop self and then we just say mod block start black opal Block dot get and that is literally all that we need to do for a block to drop itself now for the ores it’s a little more complicated because if you remember back in the loot tables right the or loot table I was a little more complicated but of course ores are Already a thing that exists so we can just say add and then we can say this is for modblock start let’s say the Black Op or black opal or dot get very important and this is a function of block and this will do the following it Will create and you can see all of the different builders that exist right we can see cheaters only drop mushroom block drop grass drop so there’s a bunch of stuff that you can take a look at here highly recommended but we want to choose the or block and the first one is Of course going to be the black opal or that get and the second one is the mod item start raw black opal.get and then we can close this and there you go so that is all we need for the orb drops now in this case we’re just gonna Duplicate this and we will say deep slate here and deep slate here and we will say Netherrack here and let’s say Netherrack here and then here we will say in stone and here we will say End Stone and now all four of our or loot tables will also generate completely Like we would expect them to and no errors will be present because we are generating a loot table for all of our known blocks I’ll show you what the error looks in a moment when we’re actually running this but for the time being we’re gonna be fine with this and Then we can proceed to continue with the mod loot table provider over here this is actually very simple this is just a public static loot table provider method called create and we will put in a pack output over here calling it output that’s going to be fine and then we’re Just returning a new loot table provider passing in the output and then a set set dot of nothing in this case and then a list that of new loot table loot table provider.sub provider entry exactly the first one and then let’s format this a little bit differently We want to pass into this sub provider entry mod block loot tables colon colon new comma loot context Paramus sets this guy right here param sets dot block and then we can close this with a semicolon and there you go that’s the mod loot table providers done and you can Probably guess that this list over here could be extended with other loot table providers right with chests or phishing or something like that that is indeed the case for our purposes we will just add the blocks but that is expandable definitely so that is done as well as Well as this one and now the model recipe provider here as the last provider that we need and this one is interesting as well this will extend the recipe provider there we go this one and it will also implement the eye condition Builder very important that we Implement Both the interface and also extend the class we want to override the build recipes method and then we want to hover over again create Constructor matching super the pack output we’ll just call this output over here and pass this in just like is a little a little bit nicer And this is actually the consumer that’s going to be fine there you go and then the build recipes here is where we build our recipes now how do we build the recipes we build the recipes with either a shapeless recipe Builder over here or a shaped recipe Builder so either one of Those work and we can actually take a look at if we middle Mouse button click we can see where it’s being used and it is being used in the recipe provider this is the one that we’re actually using as well so if we go in here and we Say for example door Builder we can literally just put in a item like the ingredient and then it’s going to create a door first so if we look at this right this is going to create a shaped recipe for a door and it just is immediately Going to work this is really really cool that this is there’s like I mean look at how many things there are right there’s buttons there’s chests planks from logs so there’s a lot of stuff that is already in here or cooking for example absolutely amazing so there’s a bunch of Things that we can get very very easily so we can for example say or smell melting we want to first of all pass in the consumer over here and then you can see there’s a bunch of stuff that we want to say this is in this case list of This is the item like so this is the item that we want to put in raw black opal or dot get then a recipe category I’m unsure where the recipe category over here goes in let’s put this under miscellaneous maybe something like that and then we get an item like this is Going to be the output so what items dot black opal.get then we get a float this should be the experience 0.7 F and then the integer is the length in ticks that is 200 and then the string is the group so that would be black opal and that Will create a an ore smelting recipe for this in this example what I highly recommend is going through the recipe provider and taking a look at the different types of well already created methods over here because my god there are an insane amount of things and they You know you just don’t need to do anything else so one extremely useful example is the nine block storage recipe over here which is immediately going to create exactly what we’ve done already and that is going to be the idea that you put a black opal Block in get nine Black opal out and also the reverse right putting nine black Opals in and getting an open block out so that is literally what this does it will create both of those recipes and we don’t need to do anything extra for this so we can literally just say no 9 storage block Recipe over here and we can say consumer press in the recipe category I’m unsure maybe you’re building blocks something like that the item like mod items dot like opal.get I’m pretty sure that the first one is the one that you will yeah the first one is the item basically and The second one is the block then we need another recipe category I’m pretty sure let’s just do miscellaneous again and then we need another mod items no actually mod blocks this time on blocks.black open block.get and there we go now we get the nine storage recipes As well if we wanted to make this like explicit without using this helper method I’m just going to copy over and then comment out the two ways that we can do this individually just so that we’ve seen this right so these are the two ideas and this is both the consumer Over here at the end there we go and I will comment this out just that you have this so this is basically a way of building a shapeless recipe and also building a shape recipe but like I said usually if you’re using things you know similar recipes to vanilla then you can Always use the helper methods just take a look at the recipe provider just middle Mouse button click on the recipe provider over here and you have everything you will ever need pretty much here and if not then you can also build your own recipes using either the shapeless recipe Builder or the shape Recipe Builder right in with that all the providers are actually done pretty cool now we just need the data generators class and this one is very interesting indeed so this gets an ad Mod Dot and then dot event bus subscriber mod ID equals to tutorial Mod Dot mod ID and then a bus equal to Mod Dot event bussubscriber.bus.mod very important that this is there otherwise this will not work very important double check this that you have this done correctly then we need a public static void gather data method and we need the gather data Event and we’re just going to call this the event and then this is also extremely important we need the add subscribe event annotation above this particular method otherwise this also will not work extremely important inside of here we need a data generator called generator and this is equal to event.getgenerated that’s fairly Straightforward we also need a pack output called pack output equal to event equal to generator dot get pack output okay also we’re still we’re still here this is all good existing file helper called existing file helper equal to event.getexisting file helper this is just you know basically to clear up the Clutter and not always having to write event.get whatever that’s the general idea here and that is all of the three things that we need then we want to say generator.ad provider we’re going to say true we’re going to say new mod recipe provider passing in the pack output So that one is pretty good let’s add another one true over here and this is going to be the mod loot table providers.create passing in the pack output and there we go generator.ad provider true a new mod block State provider and passing in the output as well as the existing file Helper and This one we can duplicate and we can say mod item model provider and this also takes in the pack output as well as the existing file Helper and with that we’ve done it that’s actually all that we need to do now it is quite an evolved process But now because we’ve done everything if you now want to add you know another item model right you add another item just literally duplicate them change the item here done and then you just have to run a specific task again and that is the interesting thing because for this We actually need to go to our Gradle tab over here and we want to run data this is extremely important so let’s double click this and let’s just see what happens so we might get an error that is absolutely fine don’t worry about it there’s I’m going to basically tell you Like what the different errors are that are well interesting for this so we’re just going to let this run through and you can see if this comes up in an existing you know was forcibly close and you get a failed over here that is totally fine the failed is not an issue What’s most important is that you get in all providers took X Ms right if you get this then you know this has actually worked right then you know this is fine you can even see that we have written 28 new files or 29 basically and you can go Into the generated over here so sources set generated and you can see assets block States look at this models we get the item models we got the block models we even got our data over here the loot tables we get the recipes now they are under Minecraft in this case that’s Which is kind of interesting why they would be under Minecraft it’s kind of interesting that they’re under Minecraft but uh yeah regardless they all generated and we can see the loaded tables over here for example this so for example the or loot table everything is in here absolutely amazing this is why We can’t have nice things of course if we’re using the already existing methods over here from the recipe provider everything is going to be put under Minecraft which is of course not correct but you don’t want it under Minecraft you want it on your own mod ID and to do That you need to do the very sensible thing instead of you know passing in a mod ID or something like that no no you want to you want to just copy over the method because that’s that makes sense right I you know it’s not like I’m annoyed by this or anything like that Absolutely not I mean this is completely sensible I guess it is what it is we’re just gonna copy those over and we’re gonna Rejoice that this is not crazy at all so everywhere where it says a resource location we just want to add the tutorial mode over here as well There you go so now we have the nine stored block done and then when it comes to the ore smelting then we can go or smelting and we can copy this over as well and believe we also need the ore cooking for this because otherwise it’s not going to work because this one Doesn’t have the correct one so we want to copy the aura cooking here as well delightfully makes a lot of sense over here I mean it just is incredibly sensible and then in the save so this calls the save method we want to as the second permanent instead of get name Over here we actually want to make a new resource location and then we want to put inside of this the tutorial mod that mod ID and then we want to say get get item name and pass this result there you go there’s a of course a comma here there you go and That should now also make this proper absolutely amazing so for the sake of army let’s delete all of the already generated files and let’s run this again with our copied methods over here the absolute Madness that is sometimes data gen this is why I continuously go back And forth if datogen is worth it or not because I mean this is ridiculous like why is there no way of doing it properly there might be by the way but because there’s no documentation there’s nothing and all of a sudden all of our recipes and loot tables are under tutorial mode So absolutely fine here but um yeah still kind of stupid at this point you know do we really need this I mean at that point you can also just use those and not even bother with with these methods you know I I thought that this Would be a nicer way of doing it but apparently it isn’t but now that all the Json files are correctly and properly generated we can now well let’s just run this again and then we we will see the first error that comes up which is not detrimental but it is one thing that Might come up if you have done this you can see we’re getting an entry XYZ is a duplicate because and this is very important we now have the Json files twice we have them in our generated folder and we also have them in our well basically manual folder over here what I Will do is I will just delete our manual one so I’ll delete the block States the models as well as the entire tutorial mod folder in the data folder now I would highly recommend you back them up so you make a backup of this and then instead of deleting them just you know Make sure that they are outside of our project over here so we no longer have them and then if we run this again then everything should be fine and there’s no more duplicates here so you can see once again this is an okay error we were okay With this as long as we get all providers took however many milliseconds we know everything worked out totally fine and the arrow is gone next point of order I also wanted to show you if you go into the modblock loot tables over here and let’s just comment out this Drop self over here then in this case one of our known blocks right because we’re passing through all of our blocks here with this iterator is not going to have a block load table which of course doesn’t work this and we can see this error if we just run data we’ll see that You know this particular board block does not have a loot table associated with it we’ll be able to see this in just a moment and you can see we get a invocation Target exception go to this one go to the forge run data over here And then if we move up you can see missing loot table 4 black opal block so you can see this basically points to exactly what is the issue and that is that we don’t have a loot table for our block because we need a loot table for every block that we’re registering over Here so let’s just do that and there you go now if there ever is a block that you don’t want this to happen what you can just do is you can go to the modblocks class and you can add a No Loot table property over here and in theory if I’m Understanding this correctly it should just jump over that one and not concern itself with it so basically if you really don’t want a certain block to have a loot table associated with it you can just call that and then you should be fine as well right and that is indeed The the generators done here so a pretty crazy thing if you have this run data over here you can just click on this drop down and change to run client again and then when you press the Run button then you’re going to run the client again and in theory everything should Work and indeed everything’s still working totally fine and that is it for this tutorial right here I hope you found this useful and you learned something new and I’ll see you all in the next tutorial so yeah Video Information
This video, titled ‘Minecraft 1.19.3 – Forge Modding Tutorial: Data Generation | #6’, was uploaded by Modding by Kaupenjoe on 2023-02-22 15:59:59. It has garnered 8185 views and 150 likes. The duration of the video is 00:21:18 or 1278 seconds.
In this Minecraft Modding Tutorial, we are generating JSON files with custom Data Generation in Minecraft 1.19.3 with Forge.
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== COMPATIBILITY == ▶️ Compatible with 1.19.3 and 1.19.4 ⏹️ Somewhat Compatible with 1.20.X
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.19.3/tree/6-dataGeneration
== 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 ▶️ 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 *
== 1 MONTH SKILLSHARE FOR FREE == ▶️ https://www.skillshare.com/r/user/kaupenjoe *
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== 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.
== 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