aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlease <4586901+Glease@users.noreply.github.com>2022-03-14 14:21:25 +0800
committerGitHub <noreply@github.com>2022-03-14 07:21:25 +0100
commit34a94189cf413164d2364dad26325688bc8128e6 (patch)
tree1e36040a988261d9fd95e5098fc2e49095c88a8e
parentbb924f35d8e8c9ce58f5667e2df03ac02a4215b0 (diff)
downloadGT5-Unofficial-34a94189cf413164d2364dad26325688bc8128e6.tar.gz
GT5-Unofficial-34a94189cf413164d2364dad26325688bc8128e6.tar.bz2
GT5-Unofficial-34a94189cf413164d2364dad26325688bc8128e6.zip
save config late (#982)
-rw-r--r--src/main/java/gregtech/api/GregTech_API.java1
-rw-r--r--src/main/java/gregtech/api/enums/GT_Values.java12
-rw-r--r--src/main/java/gregtech/api/util/GT_Config.java17
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java9
4 files changed, 28 insertions, 11 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java
index f08f9d3fb8..980eab18de 100644
--- a/src/main/java/gregtech/api/GregTech_API.java
+++ b/src/main/java/gregtech/api/GregTech_API.java
@@ -247,6 +247,7 @@ public class GregTech_API {
sAfterGTLoad = new ArrayList<>(),
sBeforeGTPostload = new ArrayList<>(),
sAfterGTPostload = new ArrayList<>(),
+ sFirstWorldTick = new ArrayList<>(),
sBeforeGTServerstart = new ArrayList<>(),
sAfterGTServerstart = new ArrayList<>(),
sBeforeGTServerstop = new ArrayList<>(),
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java
index a02699d8e1..e41eafab78 100644
--- a/src/main/java/gregtech/api/enums/GT_Values.java
+++ b/src/main/java/gregtech/api/enums/GT_Values.java
@@ -223,7 +223,7 @@ public class GT_Values {
* Whether or not to place small ores as placer ores for an orevein
*/
public static boolean oreveinPlacerOres;
- /**
+ /**
* Multiplier to control how many placer ores get generated.
*/
public static int oreveinPlacerOresMultiplier;
@@ -231,18 +231,18 @@ public class GT_Values {
* How wide to look for oreveins that affect a requested chunk. Trying to use oreveins larger than this will not work correctly. Increasing the size will cause additional worldgenerator lag.
* Disabled for now, using 64 in Deep Dark, 32 elsewhere
*/
- // public static int oreveinMaxSize;
+ // public static int oreveinMaxSize;
/**
* Not really Constants, but they set using the Config and therefore should be constant (those are for the Debug Mode)
*/
public static boolean D1 = false, D2 = false;
/**
* Debug parameter for cleanroom testing.
- */
+ */
public static boolean debugCleanroom = false;
/**
* Debug parameter for driller testing.
- */
+ */
public static boolean debugDriller = false;
/**
* Debug parameter for world generation. Tracks chunks added/removed from run queue.
@@ -306,7 +306,7 @@ public class GT_Values {
public static boolean cls_enabled;
public static final Set<String> mCTMEnabledBlock = new HashSet<>();
public static final Set<String> mCTMDisabledBlock = new HashSet<>();
-
+
public static boolean hideAssLineRecipes = false;
public static boolean updateFluidDisplayItems = true;
public static final int STEAM_PER_WATER = 160;
@@ -314,4 +314,6 @@ public class GT_Values {
* If true, then digital chest with AE2 storage bus will be accessible only through AE2
*/
public static boolean disableDigitalChestsExternalAccess = false;
+ public static boolean lateConfigSave = true;
+ public static boolean worldTickHappened = false;
}
diff --git a/src/main/java/gregtech/api/util/GT_Config.java b/src/main/java/gregtech/api/util/GT_Config.java
index f78abc52fb..4a0b15408f 100644
--- a/src/main/java/gregtech/api/util/GT_Config.java
+++ b/src/main/java/gregtech/api/util/GT_Config.java
@@ -1,6 +1,7 @@
package gregtech.api.util;
import gregtech.api.GregTech_API;
+import gregtech.api.enums.GT_Values;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
@@ -20,13 +21,19 @@ public class GT_Config implements Runnable {
GregTech_API.sAfterGTPreload.add(this); // in case of crash on startup
GregTech_API.sAfterGTLoad.add(this); // in case of crash on startup
GregTech_API.sAfterGTPostload.add(this);
+ if (GT_Values.lateConfigSave)
+ GregTech_API.sFirstWorldTick.add(this);
+ }
+
+ private static boolean shouldSave() {
+ return GT_Values.lateConfigSave ? GT_Values.worldTickHappened : GregTech_API.sPostloadFinished;
}
public static int addIDConfig(Object aCategory, String aName, int aDefault) {
if (GT_Utility.isStringInvalid(aName)) return aDefault;
Property tProperty = sConfigFileIDs.get(aCategory.toString().replaceAll("\\|", "."), aName.replaceAll("\\|", "."), aDefault);
int rResult = tProperty.getInt(aDefault);
- if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) sConfigFileIDs.save();
+ if (!tProperty.wasRead() && shouldSave()) sConfigFileIDs.save();
return rResult;
}
@@ -52,7 +59,7 @@ public class GT_Config implements Runnable {
if (GT_Utility.isStringInvalid(aName)) return aDefault;
Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault);
boolean rResult = tProperty.getBoolean(aDefault);
- if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save();
+ if (!tProperty.wasRead() && shouldSave()) mConfig.save();
return rResult;
}
@@ -64,7 +71,7 @@ public class GT_Config implements Runnable {
if (GT_Utility.isStringInvalid(aName)) return aDefault;
Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault);
int rResult = tProperty.getInt(aDefault);
- if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save();
+ if (!tProperty.wasRead() && shouldSave()) mConfig.save();
return rResult;
}
@@ -76,7 +83,7 @@ public class GT_Config implements Runnable {
if (GT_Utility.isStringInvalid(aName)) return aDefault;
Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault);
double rResult = tProperty.getDouble(aDefault);
- if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save();
+ if (!tProperty.wasRead() && shouldSave()) mConfig.save();
return rResult;
}
@@ -88,7 +95,7 @@ public class GT_Config implements Runnable {
if (GT_Utility.isStringInvalid(aName)) return aDefault;
Property tProperty = mConfig.get(aCategory.toString().replaceAll("\\|", "_"), (aName + "_" + aDefault).replaceAll("\\|", "_"), aDefault);
String rResult = tProperty.getString();
- if (!tProperty.wasRead() && GregTech_API.sPostloadFinished) mConfig.save();
+ if (!tProperty.wasRead() && shouldSave()) mConfig.save();
return rResult;
}
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index ec4362ec75..987b573637 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -166,6 +166,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
public boolean mMagneticraftRecipes = false;
public boolean mImmersiveEngineeringRecipes = false;
private boolean isFirstServerWorldTick = true;
+ private boolean isFirstWorldTick = true;
private boolean mOreDictActivated = false;
public boolean mChangeHarvestLevels=false;
public boolean mNerfedCombs = true;
@@ -1459,7 +1460,13 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler {
@SubscribeEvent
public void onWorldTickEvent(TickEvent.WorldTickEvent aEvent) {
if(aEvent.world.provider.dimensionId == 0)
- mTicksUntilNextCraftSound--;
+ mTicksUntilNextCraftSound--;
+ if (isFirstWorldTick) {
+ for (Runnable runnable : GregTech_API.sFirstWorldTick)
+ runnable.run();
+ isFirstWorldTick = false;
+ worldTickHappened = true;
+ }
if (aEvent.side.isServer()) {
if (this.mUniverse == null) {
this.mUniverse = aEvent.world;