wire in the saved data logic a bit more

This commit is contained in:
Curle 2023-07-01 02:21:44 +01:00
parent f942596b7f
commit 398b216e85
2 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,7 @@
package uk.gemwire.engage; package uk.gemwire.engage;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.server.ServerStartedEvent;
import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; 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.Items;
import uk.gemwire.engage.registries.Worldgen; import uk.gemwire.engage.registries.Worldgen;
import uk.gemwire.engage.registries.fluid.FluidDeferredRegister; 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.List;
import java.util.Set; import java.util.Set;
@ -69,7 +73,12 @@ public class Engage {
Worldgen.BIOME_MODIFIER_SERIALIZERS.register(bus); Worldgen.BIOME_MODIFIER_SERIALIZERS.register(bus);
bus.addListener(this::commonSetup); bus.addListener(this::commonSetup);
MinecraftForge.EVENT_BUS.addListener(this::serverStarted);
} }
public void commonSetup(FMLCommonSetupEvent e) { } public void commonSetup(FMLCommonSetupEvent e) { }
public void serverStarted(ServerStartedEvent e) {
CoolantNetworksSavedData.NETWORKS = CoolantNetworksSavedData.getOrCreate(e.getServer().overworld());
}
} }

View File

@ -16,6 +16,8 @@ import java.util.*;
public class CoolantNetworksSavedData extends SavedData { public class CoolantNetworksSavedData extends SavedData {
public static CoolantNetworksSavedData NETWORKS;
// The list of all Coolant Networks currently loaded // The list of all Coolant Networks currently loaded
public List<CoolantNetworkGraph.Graph> networks; public List<CoolantNetworkGraph.Graph> networks;
@ -89,6 +91,6 @@ public class CoolantNetworksSavedData extends SavedData {
public static CoolantNetworksSavedData getOrCreate(ServerLevel level) { 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");
} }
} }