aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java
diff options
context:
space:
mode:
authorConnor-Colenso <52056774+Connor-Colenso@users.noreply.github.com>2022-08-05 04:59:28 +0100
committerGitHub <noreply@github.com>2022-08-05 10:59:28 +0700
commit61de1e1af46cf2596f360e7ef31cd23bea0edc16 (patch)
tree6f611a74ec558e36112bd12748c94c6e65bdc1c2 /src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java
parent706acdfc21857d5139a5dca304a1c84f6773484b (diff)
downloadGT5-Unofficial-61de1e1af46cf2596f360e7ef31cd23bea0edc16.tar.gz
GT5-Unofficial-61de1e1af46cf2596f360e7ef31cd23bea0edc16.tar.bz2
GT5-Unofficial-61de1e1af46cf2596f360e7ef31cd23bea0edc16.zip
Wireless Fixes (#1195)
* Fix possible out-of-bounds error. * Bye bye OpV * Bye bye OpV * Some textures while I'm here * Test * Maybe * New command * Fix forge minecraft shenanigans interfering with saving data. * Localisation of achievements * Add save intervals for energy map. Co-authored-by: GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java')
-rw-r--r--src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java
index bc0bf4a9e8..3ba59a54a2 100644
--- a/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java
+++ b/src/main/java/gregtech/api/interfaces/IGlobalWirelessEnergy.java
@@ -49,6 +49,8 @@ public interface IGlobalWirelessEnergy {
// --- Save data for global energy network --
default void SaveGlobalEnergyInfo(String world_name) {
+ // Replace chars because of bug in forge that doesn't understand MC converts . to _ upon world creation.
+ world_name = world_name.replace('.','_');
CreateStorageIfNotExist(world_name);
SaveGlobalEnergyMap(world_name);
SaveGlobalEnergyName(world_name);
@@ -104,7 +106,10 @@ public interface IGlobalWirelessEnergy {
// --- Load data for global energy network ---
default void LoadGlobalEnergyInfo(World world) {
- CreateStorageIfNotExist(world.getWorldInfo().getWorldName());
+ // Replace chars because of bug in forge that doesn't understand MC converts . to _ upon world creation.
+ String world_name = world.getWorldInfo().getWorldName().replace('.','_');
+ PrivateGlobalEnergy.WorldName = world_name;
+ CreateStorageIfNotExist(world_name);
LoadGlobalEnergyMap(world);
LoadGlobalEnergyName(world);
LoadGlobalEnergyTeam(world);
@@ -225,6 +230,13 @@ public interface IGlobalWirelessEnergy {
// as infrequently as possible and bulk store values to add to the global map.
default boolean addEUToGlobalEnergyMap(String user_uuid, BigInteger EU) {
+ PrivateGlobalEnergy.EnergyAdds += 1;
+
+ if (PrivateGlobalEnergy.EnergyAddsBeforeSaving >= PrivateGlobalEnergy.EnergyAdds) {
+ SaveGlobalEnergyInfo(PrivateGlobalEnergy.WorldName);
+ PrivateGlobalEnergy.EnergyAdds = 0;
+ }
+
// Get the team UUID. Users are by default in a team with a UUID equal to their player UUID.
String team_uuid = GlobalEnergyTeam.getOrDefault(user_uuid, user_uuid);
@@ -290,4 +302,15 @@ public interface IGlobalWirelessEnergy {
}
+class PrivateGlobalEnergy {
+ // EnergyAdds Counts the number of times energy has been added to the network since the last save.
+ public static long EnergyAdds = 0;
+
+ // EnergyAddsBeforeSaving stores the number of times energy must be added or removed from the network before a save
+ // is initiated. Do not set this number very low, or you may cause lag. If you use a large number of wireless
+ // machines increase this value.
+ public static long EnergyAddsBeforeSaving = 1000;
+ // Name of the folder the world is in.
+ public static String WorldName = "";
+}