Hello and welcome back to another video today i’m going to be showing you how to create a config for your mod so that the user can configurate exactly what your mod does so in your core package let’s create a new package called dot config and in there i’m going To create a new class called tutorial config and i’m going to make sure that this class is final and in here i’m going to create a public static final forge config speg dot builder and i’m going to call this builder and this is going to be equal to a new Forged conflict spec dot builder and then i’m going to create a forward config spec and this is going to be our spec and we’re going to open a new static scope and then in here we can build our config so let’s do builder.comment and then we can add a comment so here I’m going to put config for tutorial mod and what we can do we can actually create an indent with builder.push and remove an indent with builder.pop and there we go now at the end i’m going to do spec is equal to builder dot build and now we’ve created a config However this config has nothing inside of it so let’s do that now so in order to make a value we can do public static final forge conflict spec dot config value and then we can pass in the type of that value so if i want an integer we can create an integer I’m going to call this example integer and we can also pass in pretty much any value that is serializable for example a string a double or a float so let’s do example string as well and i’m going to leave it at this for now but you can do pretty much anything you want And we can do example integer is equal to builder dot comment and then we can add a comment and then we can do dot define and then we pass in the name so example integer and then the default value which i’m going to set to three And here we go as you can see i’ve now defined our example integer and example string and that’s actually it for our config you can always add more properties and more indents with the push and pop and all we have to do to register this config is to go into Our main class we’re going to do mod loading context dot get dot register config and then we need to pass in a type so here we can do type dot common and we want to make sure to import the type from from net.minecraftware.fml.com and here we can choose between the Client configs that’s just for client stuff common config which is both for common and server and just for the server so i’m just going to do common then we want to pass in our tutorial config and finally our string for the name of the file so i’m going to call this Tutorial mod common dot tumble and you want to make sure that this ends in a dot tumble so your config registers correctly and once we load the game we can go to run config and you can click on config and press f5 to reload and you should see tutorial mod common And if you open this you can see that we have config for tutorial mod with our comments and our values over here so let’s set example integer to 10 and change this to cy4 tutorials and then save this and we already have this on player toss event so let’s just use this As an example so when the player tosses an item we can do system dot out dot print line to send a message to the console and here we can pass in tutorial config dot example integer dot get and let’s say this is example integer and we can Do the same thing for our example string and this is going to return an integer and this is going to return a string so now when we toss a player it’s going to output whatever integer and string are in our config file that’s over here and there we go Once we load the game and drop an item you can see that it prints 10 and disabled tutorials which are the new values that we set in our config that’s it for this video next time we’re going to do some world gen if you need any help join the discord And i’ll see you next time you Video Information
This video, titled ‘Minecraft Modding Tutorial 1.16 | 21.0 – Config Files’, was uploaded by Cy4’s Modding on 2021-07-07 15:18:42. It has garnered 4288 views and 102 likes. The duration of the video is 00:04:15 or 255 seconds.
1k special soon ???
(ɔ◔‿◔)ɔ ♥ ~ expand me
C://Follow_Me/ Subscribe: https://www.youtube.com/channel/UCJIDXtGpf4wv1ybDzdTA_vQ/ Website: https://cy4shot.github.io/
C://Help/ Java Tutorial: https://cy4shot.github.io/javatutorial/ Discord: https://discord.gg/x9Mj63m4QG Or comment on this video!
C://Source_Code/ This Episode: https://github.com/Cy4Shot/ModdingTutorial1.16/tree/main/21.0-ConfigFiles All Episodes: https://github.com/Cy4Shot/ModdingTutorial1.16/