classic-worldgen/src/main/java/dev/tilera/cwg/ClassicWorldgen.java
Timo Ley 8a5cb94ded
All checks were successful
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is passing
feat: WorldType instead of config
2022-11-06 18:29:02 +01:00

51 lines
1.7 KiB
Java

package dev.tilera.cwg;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import dev.tilera.cwg.caves.MapGenCavesSwiss;
import dev.tilera.cwg.command.CommandChangeWorld;
import net.minecraft.world.WorldType;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.terraingen.InitMapGenEvent;
@Mod(modid = Constants.ID, name = Constants.NAME, version = Constants.VERSION)
public class ClassicWorldgen {
public static final WorldType CLASSIC = new WorldTypeClassic("onesix");
public static WorldType USED = null;
@Mod.Instance
public static ClassicWorldgen INSTANCE;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
Config.initConfig();
}
@EventHandler
public void init(FMLInitializationEvent event)
{
MinecraftForge.TERRAIN_GEN_BUS.register(this);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onInitMapGen(InitMapGenEvent event) {
if (event.type == InitMapGenEvent.EventType.CAVE && (Config.enableSwissCheeseCaves || USED == CLASSIC)) {
event.newGen = new MapGenCavesSwiss();
}
}
@EventHandler
public void onServerLoad(FMLServerStartingEvent event) {
USED = event.getServer().getEntityWorld().getWorldInfo().getTerrainType();
if (Config.changeWorldTypeCommand)
event.registerServerCommand(new CommandChangeWorld());
}
}