Skip to content

Commit

Permalink
Use WorldEvent$Load instead of FMLServerStartedEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
glowredman committed Jun 13, 2023
1 parent cd068ca commit 4e556e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 1 addition & 8 deletions src/main/java/gregtech/common/GT_Proxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.event.ForgeEventFactory;
Expand Down Expand Up @@ -1093,6 +1092,7 @@ public void onLoad() {

MinecraftForge.EVENT_BUS.register(new GlobalEnergyWorldSavedData(""));
MinecraftForge.EVENT_BUS.register(new SpaceProjectWorldSavedData());
MinecraftForge.EVENT_BUS.register(new GT_Worldgenerator.OregenPatternSavedData(""));

// IC2 Hazmat
addFullHazmatToIC2Item("hazmatHelmet");
Expand Down Expand Up @@ -1365,13 +1365,6 @@ public void onServerStarted() {
}
}
}
World world = DimensionManager.getWorld(0);
if (world.getWorldInfo()
.getWorldTotalTime() == 0L) {
// The world has just been created
GT_Worldgenerator.useNewOregenPattern = true;
}
GT_Worldgenerator.OregenPatternSavedData.loadData(world);
}

public void onServerStopping() {
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/gregtech/common/GT_Worldgenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import net.minecraft.world.WorldSavedData;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.event.world.WorldEvent;

import cpw.mods.fml.common.IWorldGenerator;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTech_API;
import gregtech.api.enums.Materials;
Expand Down Expand Up @@ -152,6 +154,19 @@ public static void loadData(World world) {
instance.markDirty();
}

@SubscribeEvent
public void onWorldLoad(WorldEvent.Load event) {
World world = event.world;
if (!world.isRemote && world.provider.dimensionId == 0) {
if (world.getWorldInfo()
.getWorldTotalTime() == 0L) {
// The world has just been created
oregenPattern = OregenPattern.values()[OregenPattern.values().length - 1];
}
loadData(world);
}
}

@Override
public void readFromNBT(NBTTagCompound p_76184_1_) {
if (p_76184_1_.hasKey(KEY)) {
Expand Down

0 comments on commit 4e556e1

Please sign in to comment.