From 3fc5fd13960bd6e2031923e6a5c1ed6c5c8fcb08 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Mon, 15 Jun 2015 18:33:17 +0100 Subject: Added config options for world gen --- .../jewelrycraft/config/ConfigHandler.java | 20 +- .../jewelrycraft/worldGen/Generation.java | 248 ++++++++++----------- 2 files changed, 139 insertions(+), 129 deletions(-) (limited to 'src/main/java/darkknight') diff --git a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java index cd688b7..1a281bc 100644 --- a/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java +++ b/src/main/java/darkknight/jewelrycraft/config/ConfigHandler.java @@ -11,7 +11,7 @@ public class ConfigHandler { public static Configuration config; public static final ConfigHandler INSTANCE = new ConfigHandler(); - public static final String[] categories = {"Timers", "Village Generation", "Misc"}; + public static final String[] categories = {"Timers", "Village Generation", "Misc", "World Generation"}; public static int INGOT_COOLING_TIME; public static int INGOT_MELTING_TIME; @@ -44,6 +44,15 @@ public class ConfigHandler public static boolean CURSE_VAMPIRE_HUNGER = true; public static boolean CURSE_HUMBLE_BUNDLE = true; + public static boolean ENABLE_WORLD_GEN = true; + public static boolean ORE_GEN = true; + public static boolean CRYSTAL_GEN = true; + public static boolean STRUCTURE_1_GEN = true; + public static boolean STRUCTURE_2_GEN = true; + public static boolean STRUCTURE_3_GEN = true; + public static boolean STRUCTURE_4_GEN = true; + public static boolean STRUCTURE_5_GEN = true; + public void loadConfig(FMLPreInitializationEvent event) { config = new Configuration(event.getSuggestedConfigurationFile(),true); @@ -73,6 +82,15 @@ public class ConfigHandler FURNACE_MAX_INGOT_STACK = config.getInt("Ingot Furnace Max", categories[1], 5, 0, Integer.MAX_VALUE, "Determines the maximum number of ingots that can generate in a furnace."); CRYSTAL_GLOW = config.getBoolean("Crystal Glow", categories[2], false, "If true, then crystal will slowly glow (can cause lag)"); + + ENABLE_WORLD_GEN = config.getBoolean("World Generation", categories[3], true, "If false, nothing will generate (this includes ore)"); + ORE_GEN = config.getBoolean("Ore Generation", categories[3], true, "If false, ores won't generate"); + CRYSTAL_GEN = config.getBoolean("Crystal Generation", categories[3], true, "If false, crystals won't generate"); + STRUCTURE_1_GEN = config.getBoolean("Structure 1 Generation", categories[3], true, "If false, structure no.1 won't generate"); + STRUCTURE_2_GEN = config.getBoolean("Structure 2 Generation", categories[3], true, "If false, structure no.2 won't generate"); + STRUCTURE_3_GEN = config.getBoolean("Structure 3 Generation", categories[3], true, "If false, structure no.3 won't generate"); + STRUCTURE_4_GEN = config.getBoolean("Structure 4 Generation", categories[3], true, "If false, structure no.4 won't generate"); + STRUCTURE_5_GEN = config.getBoolean("Structure 5 Generation", categories[3], true, "If false, structure no.5 won't generate"); // CURSES_ENABLED = config.getBoolean("Curses", categories[3], true, "If set to false curses will be deactivated."); // CURSE_ROTTEN_HEART = config.getBoolean("Rotten Heart", categories[3], true, "If set to false this curse will be deactivated."); diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java index d3bd3e5..3a81cfb 100644 --- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java +++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java @@ -1,139 +1,131 @@ package darkknight.jewelrycraft.worldGen; import java.util.Random; + import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; -import net.minecraft.world.gen.feature.WorldGenerator; import cpw.mods.fml.common.IWorldGenerator; import darkknight.jewelrycraft.block.BlockList; +import darkknight.jewelrycraft.config.ConfigHandler; + +public class Generation implements IWorldGenerator { + public static WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1(); + public static WorldGenStructure2 STRUCTURE_2 = new WorldGenStructure2(); + public static WorldGenStructure3 STRUCTURE_3 = new WorldGenStructure3(); + public static WorldGenStructure4 STRUCTURE_4 = new WorldGenStructure4(); + public static WorldGenStructure5 STRUCTURE_5 = new WorldGenStructure5(); + + // public static WorldGenerator STRUCTURE_6 = new WorldGenStructure6(); + // public static WorldGenerator STRUCTURE_7 = new WorldGenStructure7(); + // public static WorldGenerator STRUCTURE_8 = new WorldGenStructure8(); + // public static WorldGenerator STRUCTURE_9 = new WorldGenStructure9(); + // public static WorldGenerator STRUCTURE_10 = new WorldGenStructure10(); + // public static WorldGenerator STRUCTURE_11 = new WorldGenStructure11(); + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { + switch (world.provider.dimensionId) { + case -1: + generateNether(world, random, chunkX << 4, chunkZ << 4); + break; + case 0: + generateSurface(world, random, chunkX << 4, chunkZ << 4); + break; + case 1: + generateEnd(world, random, chunkX << 4, chunkZ << 4); + break; + } + } + + private void generateEnd(World world, Random random, int i, int j) { + } + + private void generateSurface(World world, Random random, int i, int j) { + if (ConfigHandler.ENABLE_WORLD_GEN) { + if(ConfigHandler.ORE_GEN) generateShadowOre(world, random, i, j); + if(ConfigHandler.CRYSTAL_GEN) generateCrystals(world, random, i, j); + if(ConfigHandler.STRUCTURE_1_GEN) generateStructure1(world, random, i, j); + if(ConfigHandler.STRUCTURE_2_GEN) generateStructure2(world, random, i, j); + if(ConfigHandler.STRUCTURE_3_GEN) generateStructure3(world, random, i, j); + if(ConfigHandler.STRUCTURE_4_GEN) generateStructure4(world, random, i, j); + if(ConfigHandler.STRUCTURE_5_GEN) generateStructure5(world, random, i, j); + } + } + + private void generateNether(World world, Random random, int i, int j) { + } + + private void generateShadowOre(World world, Random random, int i, int j) { + for (int k = 0; k < 1; k++) { + int x = i + random.nextInt(16); + int y = 5 + random.nextInt(4); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) world.setBlock(x, y, z, BlockList.shadowOre); + int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2); + if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre); + } + } + + private void generateCrystals(World world, Random random, int i, int j) { + for (int k = 0; k < 16; k++) { + int x = i + random.nextInt(12); + int y = 5 + random.nextInt(64); + int z = j + random.nextInt(12); + for (int r = 0; r < 12; r++) { + int randX = random.nextInt(4); + int randY = random.nextInt(2); + int randZ = random.nextInt(4); + if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2); + } + } + } + + private void generateStructure1(World world, Random random, int i, int j) { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_1.generate(world, biomeBase, random, x, y, z); + } + + private void generateStructure2(World world, Random random, int i, int j) { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(3) == 0) { + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_2.generate(world, biomeBase, random, x, y, z); + } + } + + private void generateStructure3(World world, Random random, int i, int j) { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(3) == 0) { + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_3.generate(world, biomeBase, random, x, y, z); + } + } + + private void generateStructure4(World world, Random random, int i, int j) { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(5) == 0) { + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_4.generate(world, biomeBase, random, x, y, z); + } + } -public class Generation implements IWorldGenerator -{ - public static WorldGenStructure1 STRUCTURE_1 = new WorldGenStructure1(); - public static WorldGenStructure2 STRUCTURE_2 = new WorldGenStructure2(); - public static WorldGenStructure3 STRUCTURE_3 = new WorldGenStructure3(); - public static WorldGenStructure4 STRUCTURE_4 = new WorldGenStructure4(); - public static WorldGenStructure5 STRUCTURE_5 = new WorldGenStructure5(); - - // public static WorldGenerator STRUCTURE_6 = new WorldGenStructure6(); - // public static WorldGenerator STRUCTURE_7 = new WorldGenStructure7(); - // public static WorldGenerator STRUCTURE_8 = new WorldGenStructure8(); - // public static WorldGenerator STRUCTURE_9 = new WorldGenStructure9(); - // public static WorldGenerator STRUCTURE_10 = new WorldGenStructure10(); - // public static WorldGenerator STRUCTURE_11 = new WorldGenStructure11(); - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) - { - switch(world.provider.dimensionId) - { - case -1: - generateNether(world, random, chunkX << 4, chunkZ << 4); - break; - case 0: - generateSurface(world, random, chunkX << 4, chunkZ << 4); - break; - case 1: - generateEnd(world, random, chunkX << 4, chunkZ << 4); - break; - } - } - - private void generateEnd(World world, Random random, int i, int j) - {} - - private void generateSurface(World world, Random random, int i, int j) - { - generateShadowOre(world, random, i, j); - generateCrystals(world, random, i, j); - generateStructure1(world, random, i, j); - generateStructure2(world, random, i, j); - generateStructure3(world, random, i, j); - generateStructure4(world, random, i, j); - generateStructure5(world, random, i, j); - } - - private void generateNether(World world, Random random, int i, int j) - {} - - private void generateShadowOre(World world, Random random, int i, int j) - { - for(int k = 0; k < 1; k++){ - int x = i + random.nextInt(16); - int y = 5 + random.nextInt(4); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) world.setBlock(x, y, z, BlockList.shadowOre); - int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2); - if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre); - } - } - - private void generateCrystals(World world, Random random, int i, int j) - { - for(int k = 0; k < 16; k++){ - int x = i + random.nextInt(12); - int y = 5 + random.nextInt(64); - int z = j + random.nextInt(12); - for(int r = 0; r < 12; r++){ - int randX = random.nextInt(4); - int randY = random.nextInt(2); - int randZ = random.nextInt(4); - if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2); - } - } - } - - private void generateStructure1(World world, Random random, int i, int j) - { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_1.generate(world, biomeBase, random, x, y, z); - } - - private void generateStructure2(World world, Random random, int i, int j) - { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(3) == 0){ - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_2.generate(world, biomeBase, random, x, y, z); - } - } - - private void generateStructure3(World world, Random random, int i, int j) - { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(3) == 0){ - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_3.generate(world, biomeBase, random, x, y, z); - } - } - - private void generateStructure4(World world, Random random, int i, int j) - { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(5) == 0){ - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) STRUCTURE_4.generate(world, biomeBase, random, x, y, z); - } - } - - private void generateStructure5(World world, Random random, int i, int j) - { - BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); - if (random.nextInt(3) == 0){ - int x = i + random.nextInt(16); - int y = random.nextInt(100); - int z = j + random.nextInt(16); - if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_5.generate(world, biomeBase, random, x, y, z); - } - } + private void generateStructure5(World world, Random random, int i, int j) { + BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j); + if (random.nextInt(3) == 0) { + int x = i + random.nextInt(16); + int y = random.nextInt(100); + int z = j + random.nextInt(16); + if (world.getBlock(x, y, z) == Blocks.stone) STRUCTURE_5.generate(world, biomeBase, random, x, y, z); + } + } } -- cgit v1.2.3