Move client-only config options to client config (#4084)

This commit is contained in:
ichttt 2017-08-01 21:22:21 +02:00 committed by LexManos
parent c8379da83b
commit 2d97f05796

View file

@ -35,7 +35,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -49,6 +48,7 @@ import net.minecraft.world.storage.SaveHandler;
import net.minecraft.world.storage.WorldInfo; import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.classloading.FMLForgePlugin; import net.minecraftforge.classloading.FMLForgePlugin;
import net.minecraftforge.common.config.Config; import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigCategory;
import net.minecraftforge.common.config.ConfigManager; import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property; import net.minecraftforge.common.config.Property;
@ -63,7 +63,6 @@ import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.fml.common.registry.ForgeRegistries; import net.minecraftforge.fml.common.registry.ForgeRegistries;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.fluids.UniversalBucket; import net.minecraftforge.fluids.UniversalBucket;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.server.command.ForgeCommand; import net.minecraftforge.server.command.ForgeCommand;
@ -76,7 +75,6 @@ import com.google.common.eventbus.Subscribe;
import net.minecraftforge.fml.client.FMLFileResourcePack; import net.minecraftforge.fml.client.FMLFileResourcePack;
import net.minecraftforge.fml.client.FMLFolderResourcePack; import net.minecraftforge.fml.client.FMLFolderResourcePack;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.AutomaticEventSubscriber;
import net.minecraftforge.fml.common.DummyModContainer; import net.minecraftforge.fml.common.DummyModContainer;
import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.FMLLog; import net.minecraftforge.fml.common.FMLLog;
@ -171,6 +169,18 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
return config; return config;
} }
private static void remapGeneralPropertyToClient(String key)
{
ConfigCategory GENERAL = config.getCategory(CATEGORY_GENERAL);
if (GENERAL.containsKey(key))
{
FMLLog.log.debug("Remapping property {} from category general to client", key);
Property property = GENERAL.get(key);
GENERAL.remove(key);
config.getCategory(CATEGORY_CLIENT).put(key, property);
}
}
/** /**
* Synchronizes the local fields with the values in the Configuration object. * Synchronizes the local fields with the values in the Configuration object.
*/ */
@ -201,6 +211,10 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
if (config.getCategory(CATEGORY_GENERAL).containsKey("disableStitchedFileSaving")) config.getCategory(CATEGORY_GENERAL).remove("disableStitchedFileSaving"); if (config.getCategory(CATEGORY_GENERAL).containsKey("disableStitchedFileSaving")) config.getCategory(CATEGORY_GENERAL).remove("disableStitchedFileSaving");
if (config.getCategory(CATEGORY_CLIENT).containsKey("java8Reminder")) config.getCategory(CATEGORY_CLIENT).remove("java8Reminder"); if (config.getCategory(CATEGORY_CLIENT).containsKey("java8Reminder")) config.getCategory(CATEGORY_CLIENT).remove("java8Reminder");
// remap properties wrongly listed as general properties to client properties
remapGeneralPropertyToClient("biomeSkyBlendRange");
remapGeneralPropertyToClient("forgeLightPipelineEnabled");
prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", false); prop = config.get(CATEGORY_GENERAL, "disableVersionCheck", false);
prop.setComment("Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github."); prop.setComment("Set to true to disable Forge's version check mechanics. Forge queries a small json file on our server for version information. For more details see the ForgeVersion class in our github.");
// Language keys are a good idea to implement if you are using config GUIs. This allows you to use a .lang file that will hold the // Language keys are a good idea to implement if you are using config GUIs. This allows you to use a .lang file that will hold the
@ -256,12 +270,6 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
fullBoundingBoxLadders = prop.getBoolean(false); fullBoundingBoxLadders = prop.getBoolean(false);
propOrder.add(prop.getName()); propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_GENERAL, "biomeSkyBlendRange", new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 });
prop.setComment("Control the range of sky blending for colored skies in biomes.");
prop.setLanguageKey("forge.configgui.biomeSkyBlendRange");
blendRanges = prop.getIntList();
propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBaseSummonChance", 0.1, prop = config.get(Configuration.CATEGORY_GENERAL, "zombieBaseSummonChance", 0.1,
"Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic.", 0.0D, 1.0D); "Base zombie summoning spawn chance. Allows changing the bonus zombie summoning mechanic.", 0.0D, 1.0D);
prop.setLanguageKey("forge.configgui.zombieBaseSummonChance").setRequiresWorldRestart(true); prop.setLanguageKey("forge.configgui.zombieBaseSummonChance").setRequiresWorldRestart(true);
@ -274,12 +282,6 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
zombieBabyChance = (float) prop.getDouble(0.05); zombieBabyChance = (float) prop.getDouble(0.05);
propOrder.add(prop.getName()); propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_GENERAL, "forgeLightPipelineEnabled", true,
"Enable the forge block rendering pipeline - fixes the lighting of custom models.");
forgeLightPipelineEnabled = prop.getBoolean(true);
prop.setLanguageKey("forge.configgui.forgeLightPipelineEnabled");
propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_GENERAL, "logCascadingWorldGeneration", true, prop = config.get(Configuration.CATEGORY_GENERAL, "logCascadingWorldGeneration", true,
"Log cascading chunk generation issues during terrain population."); "Log cascading chunk generation issues during terrain population.");
logCascadingWorldGeneration = prop.getBoolean(); logCascadingWorldGeneration = prop.getBoolean();
@ -329,6 +331,18 @@ public class ForgeModContainer extends DummyModContainer implements WorldAccessC
prop.setLanguageKey("forge.configgui.alwaysSetupTerrainOffThread"); prop.setLanguageKey("forge.configgui.alwaysSetupTerrainOffThread");
propOrder.add(prop.getName()); propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_CLIENT, "biomeSkyBlendRange", new int[] { 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34 });
prop.setComment("Control the range of sky blending for colored skies in biomes.");
prop.setLanguageKey("forge.configgui.biomeSkyBlendRange");
blendRanges = prop.getIntList();
propOrder.add(prop.getName());
prop = config.get(Configuration.CATEGORY_CLIENT, "forgeLightPipelineEnabled", true,
"Enable the forge block rendering pipeline - fixes the lighting of custom models.");
forgeLightPipelineEnabled = prop.getBoolean(true);
prop.setLanguageKey("forge.configgui.forgeLightPipelineEnabled");
propOrder.add(prop.getName());
config.setCategoryPropertyOrder(CATEGORY_CLIENT, propOrder); config.setCategoryPropertyOrder(CATEGORY_CLIENT, propOrder);
if (config.hasChanged()) if (config.hasChanged())