From 398b216e85fdea58870e1eb4278e3b3db100d5d4 Mon Sep 17 00:00:00 2001 From: Curle Date: Sat, 1 Jul 2023 02:21:44 +0100 Subject: [PATCH] wire in the saved data logic a bit more --- src/main/java/uk/gemwire/engage/Engage.java | 9 +++++++++ .../engage/systems/coolant/CoolantNetworksSavedData.java | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/gemwire/engage/Engage.java b/src/main/java/uk/gemwire/engage/Engage.java index 98f36ff..a4063ea 100644 --- a/src/main/java/uk/gemwire/engage/Engage.java +++ b/src/main/java/uk/gemwire/engage/Engage.java @@ -1,5 +1,7 @@ package uk.gemwire.engage; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.server.ServerStartedEvent; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; @@ -10,6 +12,8 @@ import uk.gemwire.engage.registries.Fluids; import uk.gemwire.engage.registries.Items; import uk.gemwire.engage.registries.Worldgen; import uk.gemwire.engage.registries.fluid.FluidDeferredRegister; +import uk.gemwire.engage.systems.coolant.CoolantNetworkGraph; +import uk.gemwire.engage.systems.coolant.CoolantNetworksSavedData; import java.util.List; import java.util.Set; @@ -69,7 +73,12 @@ public class Engage { Worldgen.BIOME_MODIFIER_SERIALIZERS.register(bus); bus.addListener(this::commonSetup); + MinecraftForge.EVENT_BUS.addListener(this::serverStarted); } public void commonSetup(FMLCommonSetupEvent e) { } + + public void serverStarted(ServerStartedEvent e) { + CoolantNetworksSavedData.NETWORKS = CoolantNetworksSavedData.getOrCreate(e.getServer().overworld()); + } } diff --git a/src/main/java/uk/gemwire/engage/systems/coolant/CoolantNetworksSavedData.java b/src/main/java/uk/gemwire/engage/systems/coolant/CoolantNetworksSavedData.java index a6527e0..572ffc7 100644 --- a/src/main/java/uk/gemwire/engage/systems/coolant/CoolantNetworksSavedData.java +++ b/src/main/java/uk/gemwire/engage/systems/coolant/CoolantNetworksSavedData.java @@ -16,6 +16,8 @@ import java.util.*; public class CoolantNetworksSavedData extends SavedData { + public static CoolantNetworksSavedData NETWORKS; + // The list of all Coolant Networks currently loaded public List networks; @@ -89,6 +91,6 @@ public class CoolantNetworksSavedData extends SavedData { public static CoolantNetworksSavedData getOrCreate(ServerLevel level) { - return level.getDataStorage().computeIfAbsent(CoolantNetworksSavedData::load, CoolantNetworksSavedData::new, "graphs"); + return level.getDataStorage().computeIfAbsent(CoolantNetworksSavedData::load, CoolantNetworksSavedData::new, "coolant_graphs"); } }