From 801598dc95ad9c596fc3ca64f496f28239318cd7 Mon Sep 17 00:00:00 2001 From: Gig Date: Sat, 11 Apr 2015 19:40:01 +0100 Subject: [PATCH] WorldGen GET!!!! --- src/main/java/techreborn/Core.java | 4 + src/main/java/techreborn/world/TROreGen.java | 202 +++++++++++++++++++ 2 files changed, 206 insertions(+) create mode 100644 src/main/java/techreborn/world/TROreGen.java diff --git a/src/main/java/techreborn/Core.java b/src/main/java/techreborn/Core.java index 11358dd0b..9d6f04269 100644 --- a/src/main/java/techreborn/Core.java +++ b/src/main/java/techreborn/Core.java @@ -7,9 +7,11 @@ import techreborn.config.ConfigTechReborn; import techreborn.init.ModBlocks; import techreborn.init.ModItems; import techreborn.lib.ModInfo; +import techreborn.world.TROreGen; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = ModInfo.MOD_DEPENDENCUIES, guiFactory = ModInfo.GUI_FACTORY_CLASS) public class Core { @@ -35,6 +37,8 @@ public class Core { ModBlocks.init(); //Register ModItems ModItems.init(); + // WorldGen + GameRegistry.registerWorldGenerator(new TROreGen(), 0); //Register Gui Handler NetworkRegistry.INSTANCE.registerGuiHandler(INSTANCE, new GuiHandler()); } diff --git a/src/main/java/techreborn/world/TROreGen.java b/src/main/java/techreborn/world/TROreGen.java new file mode 100644 index 000000000..6e5d6f4fa --- /dev/null +++ b/src/main/java/techreborn/world/TROreGen.java @@ -0,0 +1,202 @@ +package techreborn.world; + +import ic2.core.util.Config; + +import java.util.Random; + +import techreborn.config.ConfigTechReborn; +import techreborn.init.ModBlocks; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.chunk.IChunkProvider; +import net.minecraft.world.gen.feature.WorldGenMinable; +import cpw.mods.fml.common.IWorldGenerator; + +public class TROreGen implements IWorldGenerator{ + public static ConfigTechReborn config; + + WorldGenMinable oreGalena; + WorldGenMinable oreIridium; + WorldGenMinable oreRuby; + WorldGenMinable oreSapphire; + WorldGenMinable oreBauxite; + WorldGenMinable orePyrite; + WorldGenMinable oreCinnabar; + WorldGenMinable oreSphalerite; + WorldGenMinable oreTungston; + WorldGenMinable oreSheldonite; + WorldGenMinable oreOlivine; + WorldGenMinable oreSodalite; + + public TROreGen() + { + //World + oreGalena = new WorldGenMinable(ModBlocks.ore, 0, 8, Blocks.stone); + oreIridium = new WorldGenMinable(ModBlocks.ore, 1, 8, Blocks.stone); + oreRuby = new WorldGenMinable(ModBlocks.ore, 2, 8, Blocks.stone); + oreSapphire = new WorldGenMinable(ModBlocks.ore, 3, 8, Blocks.stone); + oreBauxite = new WorldGenMinable(ModBlocks.ore, 4, 8, Blocks.stone); + //Nether + orePyrite = new WorldGenMinable(ModBlocks.ore, 5, 8, Blocks.netherrack); + oreCinnabar = new WorldGenMinable(ModBlocks.ore, 6, 8, Blocks.netherrack); + oreSphalerite = new WorldGenMinable(ModBlocks.ore, 7, 8, Blocks.netherrack); + //End + oreTungston = new WorldGenMinable(ModBlocks.ore, 8, 8, Blocks.end_stone); + oreSheldonite = new WorldGenMinable(ModBlocks.ore, 9, 8, Blocks.end_stone); + oreOlivine = new WorldGenMinable(ModBlocks.ore, 10, 8, Blocks.end_stone); + oreSodalite = new WorldGenMinable(ModBlocks.ore, 11, 8, Blocks.end_stone); + } + + @Override + public void generate(Random random, int xChunk, int zChunk, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) + { + if(world.provider.isSurfaceWorld()) + { + generateUndergroundOres(random, xChunk * 16, zChunk * 16, world); + } + else if(world.provider.isHellWorld) + { + generateHellOres(random, xChunk * 16, zChunk * 16, world); + } + else + { + generateEndOres(random, xChunk * 16, zChunk * 16, world); + } + + } + + void generateUndergroundOres (Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (config.GalenaOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreGalena.generate(world, random, xPos, yPos, zPos); + } + } + if (config.IridiumOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreIridium.generate(world, random, xPos, yPos, zPos); + } + } + if (config.RubyOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreRuby.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SapphireOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSapphire.generate(world, random, xPos, yPos, zPos); + } + } + if (config.BauxiteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreBauxite.generate(world, random, xPos, yPos, zPos); + } + } + } + + void generateHellOres (Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (config.PyriteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + orePyrite.generate(world, random, xPos, yPos, zPos); + } + } + if (config.CinnabarOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreCinnabar.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SphaleriteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSphalerite.generate(world, random, xPos, yPos, zPos); + } + } + } + + void generateEndOres (Random random, int xChunk, int zChunk, World world) + { + int xPos, yPos, zPos; + if (config.TungstonOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreTungston.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SheldoniteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSheldonite.generate(world, random, xPos, yPos, zPos); + } + } + if (config.OlivineOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreOlivine.generate(world, random, xPos, yPos, zPos); + } + } + if (config.SodaliteOreTrue) + { + for (int i = 0; i <= 16; i++) + { + xPos = xChunk + random.nextInt(16); + yPos = 60 + random.nextInt(60 - 20); + zPos = zChunk + random.nextInt(16); + oreSodalite.generate(world, random, xPos, yPos, zPos); + } + } + } +}