Hello guys I’m Uncle Matt from the Minecraft mana tutorial in today’s episode we’re going to go over how to create conflicts which will allow users of your mod to change values for certain things so I’ll make you a mod much more customizable so let’s get started first Things first we’re going to go into sauceman Java house of toil mod and create a new package cause config and then we’re going to create the conflict class this is going to be an event bus subscriber so apt mod event bus subscriber control shift over to import Mod it means up this class will be loaded when we are booting the game first I’m going to create is the Builder for our config which will be private static final forge config spec dot builder call it builder and this is going to be equal to a new barge config Spec . builder and then we’re going to create config itself public static final forge config spec config then we’re going to create a static initializer and this will be read when we are reading this class so we are going to say config is equal to builder dot build so that will initialize our Configuration so now we can actually load the config itself so we’re going to create a load config function public static ride load config forge config spec config has to configure self and then string path that’s the location of the config we’re going to add some lockers here to tell It in their console when we are loading the config so tutorial mod dots logger dot info loading config plus the path then we are going to create the actual file for the config final commented file config call it file and this is equal to commented file config dot builder new File and taking the path dot and there’s lots of properties here that you can use we won’t sync so will synchronize this file with the config then also save as we wanted to automatically save every time I make a modification dot writing mode we want writing mode dot replace so Whenever we write something new to the file if there’s already something there it will override it and then finally dot build and that will just build the actual thing itself then we’re gonna log doing the blogger tutorial mod dot logger dot info built config plus the path again so whenever we built The config it’ll tell then we will load the config file itself file dot load then we will again print out that we’ve loaded it the tutorial mods dot logger info loaded config and then the path again and then finally we have the set the configuration file to we set the Config to this creation configuration file and config dot set config file and there we are the configuration is now loaded in now to make sure added boost into our game let me go back to our main class below instance do mod loading context dot get dr. register config mod Config dot type dot server and then config dot config we don’t import that config you on the import our config file important how you dr. Ahmad config well I think I want to call this server config as you can’t have things that only will sync on client but the Majority of the time there isn’t many values to actally only sync on client you need to do sync them to both client and server and to make sure it happens so you just do it inside of the server config but you can create an a client Config exactly the same the way we just did so now we have it also have a client config and for things that need to only be run on client so there’s copy this change it to a conflict type client and config dot client config and now we’re actually going to load the configs Config dot load config config dot client config FML paths dot config directory config der dot get dot resolve tutorial mods – client dot skomal dot – string and that will load in the client config and finally server config ever do that same just server tunnel and we have created the two configs there Now there are many values in our config yet and so we need to we can create a specific conflict classes for each types of values you want so for example let’s create one for our odd generation or gen config so we’re going to get some values there’ll be public static forge config Spec dot int value that could be the chance so tutorial underscore tracks that refers to the chance to spawn then we’re going to create an init function public static void in it Forge configs back dot builder taking the server and forge config spec the dock builder taking the Client but for now all the values are going to be on the server side so firstly do server adopt comment this is the origin config so so below these lines it will be it will print out or Jane config inside the config file and then below these lines a bit Everything in the AL Jane config so now we have to declare what each value is so the chance value tutorial underscore chance is equal to server dot comment and you can comment something about it so what it is which is the maximum number of all vein off this tutorial or That can spawn in one chunk now let’s make them quite clean by doing this go down one line each time we add another property and the next one will be defined in range so we’re going to need a string for the path this will be or Gen dot tutorial chance the default Value so what the normal chances this can be 100 the minimum chance is 1 and the maximum chance can be any value 1 I’m going to put 100,000 and that’s that declared we now have that value we can now use that value if we go into our or Generation so we can replace this value here with our Gen config dot tutorial chance dot get so whatever we value we have this set to in of the configuration will be the chance to spawn in the world which means people can adjust the values of things for their own worlds I’ll do One more example of a value can have here would be a boolean value public static forge config dot bool value this can’t be generates overworld so does it one hour or so generate in the first place do generate overworld is equal to server dot comment and then adopt define or gen dr generates Overworld and the default value is true then back in order asian you puts an if statement if or gen config dot generates overworld so if that’s true then you can do all this stuff all right you’ve got get if that’s true you can do all that stuff but if not then it won’t Even bother trying to generate anything and it won’t generate hours so that’s two examples there’s also lots of different other values the double value and a long value but int and billion will probably be the ones you use the most so now we’ve had Lee created our Alteration config class go back into an config in here and do just a buff above those two things or gem config dot in it serve a builder client builder and that will initialize our origin config you can create as many different conflicts as you want yeah be exactly the same as that one Just with different values and and you just initialize the knee exact same way so now if we run the game you can go down to run here and down to config and it will generate the server config and client config files once is booted the Game so you want to click f5 to refresh down here we now have tutorial our client internal server instead of client there’s nothing in there but inside of server we’ve got the old gen definition and we’ve got decide if you want time mod also spawn the overworld and Generate every well equals true if we change that’s false all ours wouldn’t generate then maximum number of or veins that tutorial all can spawn in one chunk tutorial chance equals 100 but you can change that value and it will change things in the actual con in the national Game itself so if you have enjoyed this video or found it useful please leave a like down below and subscribe for more tutorials anyway guys thanks for watching mine has been hairy and goodbye Video Information
This video, titled ‘Config File / Customizable Values – Minecraft Modding Tutorial for MC 1.14/1.14.3’, was uploaded by Harry Talks on 2019-06-04 10:39:26. It has garnered 16605 views and 223 likes. The duration of the video is 00:13:52 or 832 seconds.
In this episode, we create config files that allow the users to change values inside of your mod.
Recipe Info: https://minecraft.gamepedia.com/Recip… Basic Java Tutorials: http://tiny.cc/JavaTuts Default Textures: http://tiny.cc/DefaultTextures LangToJSon convertor: https://tterrag.com/lang2json/ GitHub: http://tiny.cc/HarryGitHub Discord: https://discordapp.com/invite/xwg8zQJ
#Minecraft #Forge