Skip to content

Instantly share code, notes, and snippets.

@primetoxinz
Last active October 27, 2017 23:09
Show Gist options
  • Save primetoxinz/ae90682189d1d0e6a68f9109affc7bf1 to your computer and use it in GitHub Desktop.
Save primetoxinz/ae90682189d1d0e6a68f9109affc7bf1 to your computer and use it in GitHub Desktop.
WorldGenDisabler Source
package com.primetoxinz.wgd;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.gen.MapGenBase;
import net.minecraft.world.gen.structure.*;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Config;
import net.minecraftforge.common.config.ConfigManager;
import net.minecraftforge.event.terraingen.InitMapGenEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.FMLLog;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.Map;
import static net.minecraftforge.common.ForgeVersion.MOD_ID;
@Mod(modid = WGD.MODID, version = WGD.VERSION)
public class WGD {
public static final String MODID = "worldgendisabler";
public static final String VERSION = "1.0";
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event) {
MinecraftForge.TERRAIN_GEN_BUS.register(this);
MinecraftForge.EVENT_BUS.register(this);
}
@SubscribeEvent
public void onMapGen(InitMapGenEvent event) {
switch (event.getType()) {
case CAVE:
if (ConfigHandler.disableCaves)
event.setNewGen(new MapGenNone());
break;
case MINESHAFT:
if (ConfigHandler.disableMineshaft)
event.setNewGen(new MapGenMineshaftNone());
break;
case NETHER_BRIDGE:
if (ConfigHandler.disableNetherFortress)
event.setNewGen(new MapGenFortressNone());
break;
case NETHER_CAVE:
if (ConfigHandler.disableNetherCaves)
event.setNewGen(new MapGenNone());
break;
case RAVINE:
if (ConfigHandler.disableRavines)
event.setNewGen(new MapGenNone());
break;
case SCATTERED_FEATURE:
if (ConfigHandler.disableTemples)
event.setNewGen(new MapGenScatteredNone());
break;
case STRONGHOLD:
if (ConfigHandler.disableStrongholds)
event.setNewGen(new MapGenStrongholdNone());
break;
case VILLAGE:
if (ConfigHandler.disableVillages)
event.setNewGen(new MapGenVillageNone());
break;
case OCEAN_MONUMENT:
if (ConfigHandler.disableOceanMonuments)
event.setNewGen(new MapGenOceanMonument());
break;
case CUSTOM:
break;
}
}
public class MapGenNone extends MapGenBase {
MapGenNone() {
}
@Override
public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
//NO-OP
}
}
public class MapGenStrongholdNone extends MapGenStronghold {
public MapGenStrongholdNone() {
}
public MapGenStrongholdNone(Map<String, String> p_i2068_1_) {
}
@Override
public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
//NO-OP
}
}
public class MapGenMineshaftNone extends MapGenMineshaft {
MapGenMineshaftNone() {
}
public MapGenMineshaftNone(Map<String, String> p_i2034_1_) {
}
@Override
public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
//NO-OP
}
}
public class MapGenScatteredNone extends MapGenScatteredFeature {
MapGenScatteredNone() {
}
public MapGenScatteredNone(Map<String, String> p_i2061_1_) {
}
@Override
public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
//NO-OP
}
}
public class MapGenOceanMonument extends StructureOceanMonument {
MapGenOceanMonument() {
}
public MapGenOceanMonument(Map<String, String> p_i45608_1_) {
}
@Override
public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
//NO-OP
}
}
public class MapGenVillageNone extends MapGenVillage {
MapGenVillageNone() {
}
public MapGenVillageNone(Map<String, String> map) {
}
@Override
public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
//NO-OP
}
}
public class MapGenFortressNone extends MapGenNetherBridge {
MapGenFortressNone() {
}
@Override
public void generate(World worldIn, int x, int z, ChunkPrimer primer) {
//NO-OP
}
}
@Mod.EventBusSubscriber
@Config(modid = MODID, name = MODID)
public static class ConfigHandler {
@Config.Comment("Disable Villages")
@Config.LangKey("wgd.disableVillages")
public static boolean disableVillages;
@Config.Comment("Disable Mineshaft")
@Config.LangKey("wgd.disableMineshaft")
public static boolean disableMineshaft;
@Config.Comment("Disable Desert Temple, Jungle Temple, Witchhut and Igloos")
@Config.LangKey("wgd.disableTemples")
public static boolean disableTemples;
@Config.Comment("Disable Strongholds")
@Config.LangKey("wgd.disableStrongholds")
public static boolean disableStrongholds;
@Config.Comment("Disable Ravines")
@Config.LangKey("wgd.disableRavines")
public static boolean disableRavines;
@Config.Comment("Disable Caves")
@Config.LangKey("wgd.disableCaves")
public static boolean disableCaves;
@Config.Comment("Disable Caves in the Nether")
@Config.LangKey("wgd.disableNetherCaves")
public static boolean disableNetherCaves;
@Config.Comment("Disable Ocean Monuments")
@Config.LangKey("wgd.disableOceanMonuments")
public static boolean disableOceanMonuments;
@Config.Comment("Disable Nether Fortresses")
@Config.LangKey("wgd.disableNetherFortress")
public static boolean disableNetherFortress;
@SubscribeEvent
public static void onConfigChange(ConfigChangedEvent event) {
if (event.getModID().equals(MODID)) {
ConfigManager.sync(MOD_ID, Config.Type.INSTANCE);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment