From dd8de0d25b0bd41fa4788987dc2aedddee6d5056 Mon Sep 17 00:00:00 2001 From: Victorious3 Date: Sun, 9 Aug 2015 15:19:25 +0200 Subject: [PATCH] Add a config option to disable the legacy loader to preserve old 0.9 worlds. --- .../java/moe/nightfall/vic/integratedcircuits/Config.java | 3 +++ .../nightfall/vic/integratedcircuits/cp/CircuitData.java | 8 +++++--- .../resources/assets/integratedcircuits/lang/en_US.lang | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/Config.java b/src/main/java/moe/nightfall/vic/integratedcircuits/Config.java index 36c2b1b..5e7bdba 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/Config.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/Config.java @@ -25,6 +25,8 @@ private Config() { public static boolean enableTooltips; public static int sevenSegmentMaxDigits; + public static boolean enableLegacyLoader; + // TODO Generalize! public static void preInitialize(File file) { config = new Configuration(file); @@ -44,6 +46,7 @@ public static void loadValues() { enableTooltips = config.getBoolean("enableTooltips", "GENERAL", true, ""); enableTracker = config.getBoolean("enableTracker", "GENERAL", true, ""); sevenSegmentMaxDigits = config.getInt("sevenSegmentMaxDigits", "GENERAL", 16, 1, 16, ""); + enableLegacyLoader = config.getBoolean("enableLegacyLoader", "GENERAL", true, ""); config.setCategoryRequiresMcRestart("PARTS", true); } diff --git a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java index c725fca..cec7e6b 100644 --- a/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java +++ b/src/main/java/moe/nightfall/vic/integratedcircuits/cp/CircuitData.java @@ -7,6 +7,7 @@ import java.util.LinkedList; import java.util.List; +import moe.nightfall.vic.integratedcircuits.Config; import moe.nightfall.vic.integratedcircuits.IntegratedCircuits; import moe.nightfall.vic.integratedcircuits.cp.legacy.LegacyLoader; import moe.nightfall.vic.integratedcircuits.cp.part.PartIOBit; @@ -325,7 +326,8 @@ public static CircuitData readFromNBT(NBTTagCompound compound, ICircuit parent) int version = compound.getInteger("version"); List legacyLoaders = null; - if (version < CircuitData.version) { + boolean legacyLoad = version < CircuitData.version && Config.enableLegacyLoader; + if (legacyLoad) { // TODO This can't work for multiple versions as those steps have to // be executed in sequence. legacyLoaders = LegacyLoader.getLegacyLoaders(version); @@ -349,7 +351,7 @@ public static CircuitData readFromNBT(NBTTagCompound compound, ICircuit parent) CircuitProperties prop = CircuitProperties.readFromNBT(compound.getCompoundTag("properties")); int size = compound.getInteger("size"); - if (version < CircuitData.version) { + if (legacyLoad) { for (LegacyLoader loader : legacyLoaders) { loader.transform(size, id, meta); } @@ -375,7 +377,7 @@ public static CircuitData readFromNBT(NBTTagCompound compound, ICircuit parent) CircuitData cdata = new CircuitData(size, parent, id, meta, scheduledTicks, inputQueue, prop); - if (version < CircuitData.version) { + if (legacyLoad) { // TODO Not future-proof. Will break if e.g. inputQueue is removed. for (LegacyLoader loader : legacyLoaders) { loader.postTransform(cdata); diff --git a/src/main/resources/assets/integratedcircuits/lang/en_US.lang b/src/main/resources/assets/integratedcircuits/lang/en_US.lang index 21a5fc6..8c9cc2d 100644 --- a/src/main/resources/assets/integratedcircuits/lang/en_US.lang +++ b/src/main/resources/assets/integratedcircuits/lang/en_US.lang @@ -151,6 +151,8 @@ config.integratedcircuits.general.enableTracker=Enable tracker config.integratedcircuits.general.enableTracker.tooltip=This setting will make the game visit this URL on startup: https://raw.githubusercontent.com/Victorious3/Integrated-Circuits/master/version.dat %nThe connection is established over bit.ly for statistics. The data collected is publicly visible on https://bitly.com/1GIaUA6+. Bit.ly will track %nyour country via your IP address, no other, or personal, information is gathered. I like statistics, and I would like you to keep this setting enabled, %nso that I get a better overview of how often my mod is used. Thanks. config.integratedcircuits.general.sevenSegmentMaxDigits=Maximal digits seven segment display config.integratedcircuits.general.sevenSegmentMaxDigits.tooltip=The maximum number of digits a seven segment display can have +config.integratedcircuits.general.enableLegacyLoader=Enable legacy loader +config.integratedcircuits.general.enableLegacyLoader.tooltip=This setting will try and convert old versions of the circuit blueprints to the current version. This should be left ON unless you know what you are doing. config.integratedcircuits.parts.redirect=part.integratedcircuits.%s.name # misc