Posted May 22, 20196 yr Under certain conditions, I would like to be able to prevent players from changing the config through forge's config GUI interface. Is it possible to grey out values so that the player does not have access to them? Here is my mod config class: package oresheepmod.command; import net.minecraftforge.common.config.Config; import net.minecraftforge.common.config.ConfigManager; import net.minecraftforge.fml.client.event.ConfigChangedEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import oresheepmod.ModOreSheep; @Config(modid = ModOreSheep.modid) @Config.LangKey("oresheepmod.config.title") public class ModConfig { @Config.Comment("Ignores the mobGriefing game rule.") public static boolean IgnoreGameRuleMobGriefing = true; @Config.Comment("Determines if sheep can go into love mode.") public static boolean CanBreed = true; @Config.Comment("If false, offspring are not ore sheep, but regular sheep.") public static boolean OffspringAreOreSheep = true; @Config.Comment("If false, ore sheep can't be created with a weakness potion and diamond, but must be spawned with a spawn egg.") public static boolean CanBrainwash = true; @Config.Comment("If false, ore sheep can't eat a different block to change their ore. They can only be changed through creative mode feeding.") public static boolean CanChangeOre = true; @Config.Comment("If false, ore sheep eat in front of themselves before they eat down, otherwise they eat directly down.") public static boolean DigStraightDown = false; @Config.Comment("If false, ore sheep can't eat bedrock.") public static boolean Bedrock = false; @Mod.EventBusSubscriber(modid = ModOreSheep.modid) private static class EventHandler { /** * Inject the new values and save to the config file when the config has been changed from the GUI. * * @param event The event */ @SubscribeEvent public static void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { if (event.getModID().equals(ModOreSheep.modid)) { ConfigManager.sync(ModOreSheep.modid, Config.Type.INSTANCE); } } } } The event handler class's onConfigChanged method looks like a good place to start, but I wanted to know first if there is any built-in/already-made solution. Thanks for any and all help!
May 22, 20196 yr Can't the player just change the .cfg file anyway? Some tips: Spoiler Modder Support: Spoiler 1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code. 2. Always post your code. 3. Never copy and paste code. You won't learn anything from doing that. 4. Quote Programming via Eclipse's hotfixes will get you nowhere 5. Learn to use your IDE, especially the debugger. 6. Quote The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it. Support & Bug Reports: Spoiler 1. Read the EAQ before asking for help. Remember to provide the appropriate log(s). 2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.
May 23, 20196 yr 3 hours ago, Icedice9 said: I would like to be able to prevent players from changing the config through forge's config GUI You could use your own GUI that doesn’t allow them to change it under certain conditions About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
May 23, 20196 yr Author Let me give a few more details to make what I am doing more clear. I have another custom config text file that is read in per world, but that file can have 0 or more of the config entries. If my custom file doesn't have a config entry, the global config entry is used and changing the global value in the GUI does nothing. What I want to do is make it so changing it in the global GUI doesn't give the player a false sense that they are changing something when it doesn't make a difference. The point of having a world config and a global one is so regular players can set their global settings, but map makers can set specific values per world that come with the world when it is downloaded. 2 hours ago, DavidM said: Can't the player just change the .cfg file anyway? DavidM- yes they can, but again, it doesn't change anything in game if my custom config file is filled in the world. 1 hour ago, Cadiboo said: You could use your own GUI that doesn’t allow them to change it under certain conditions That would be neat! Do you have any tutorial suggestions? It sounds pretty complicated and I want to stick with the forge-made one if at all possible. Edited May 23, 20196 yr by Icedice9 Fixed grammar
May 23, 20196 yr 15 minutes ago, Icedice9 said: I have another custom config text file that is read in per world, but that file can have 0 or more of the config entries. If my custom file doesn't have a config entry, the global config entry is used and changing the global value in the GUI does nothing. What I want to do is make it so changing it in the global GUI doesn't give the player a false sense that they are changing something when it doesn't make a difference. The point of having a world config and a global one is so regular players can set their global settings, but map makers can set specific values per world that come with the world when it is downloaded. This is all part of the new 1.13.2 config system About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
May 23, 20196 yr Author 1 hour ago, Cadiboo said: This is all part of the new 1.13.2 config system Nice! I can't wait to upgrade! That's my plan as soon as I put out this new update. Do you have any suggestions for 1.12.2 tutorials I can look into in the mean time?
May 23, 20196 yr Tutorials for what specifically? Look at/copy/extend the forge GUI code if you’re going to use the GUI approach. You can also just not save the config if it’s locked (you’re already subscribing to the config change event to save the config) Edited May 23, 20196 yr by Cadiboo About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
May 23, 20196 yr Author I'll look for those files and see what I can do. Thanks for the suggestions all!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.