Closed Lyle-Tafoya closed 2 years ago
Personally, I think the function should just exit immediately if save_gamerules is false. If this isn't how you want it to work, then please consider adding an additional option that prevents the config from being overwritten in any circumstances
I'm guessing you changed the value while being in-game and quickly closing the world. In that case the config system in forge hadn't gotten the file change yet and updated the in-memory config and that was used to save the config.
I've now change so the save only happens if any of the gamerules or difficulty settings differ.
The difficulty only changes if the set_difficulty
config is true and the gamerules only if the save_gamerules
is true.
Regarding the globalgamerules-common-1.toml.bak
file it's outside of the mod, the config system is handled by forge and a library that is used by them. Why that file would be created is probably because of an invalid file in some way.
I'm guessing you changed the value while being in-game and quickly closing the world. In that case the config system in forge hadn't gotten the file change yet and updated the in-memory config and that was used to save the config.
I've now change so the save only happens if any of the gamerules or difficulty settings differ. The difficulty only changes if the
set_difficulty
config is true and the gamerules only if thesave_gamerules
is true.Regarding the
globalgamerules-common-1.toml.bak
file it's outside of the mod, the config system is handled by forge and a library that is used by them. Why that file would be created is probably because of an invalid file in some way.
This also occurs for all other settings as well, even on 1.12.2, which I doubt you support.
I'm trying to make a mod pack with a large spawn radius, I set the spawn radius in the config, but it keeps getting reset back to default when I exit the game. The original config ends up in a backup file "globalgamerules-common-1.toml.bak" and I have to restore it from there nearly every time I play. I cannot expect the people who use my modpack to have to do this.
When I look at onWorldUnload(WorldEvent.Unload event) in WorldEvents.java, I see it checks whether save_gamerules is true before it attempts to update the config values in memory. However, outside of that if statement, it saves the config to file no matter what. Looking at the code, I'm guessing it's because you wanted the difficulty saving feature to work even with save_gamerules=false. I don't know why my spawn radius setting is getting reset during this, but there needs to be a way to ensure that GGRConfig.commonSpec.save() really does not ever get called here no matter what.