From 7305ba719930ea3fbf8aa987aeec48b33cdbd82e Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Tue, 21 Mar 2017 17:34:07 +0300 Subject: Oregen --- ihl/worldgen/IHLWorldGenerator.java | 300 +++++++++--------------------------- 1 file changed, 75 insertions(+), 225 deletions(-) (limited to 'ihl/worldgen/IHLWorldGenerator.java') diff --git a/ihl/worldgen/IHLWorldGenerator.java b/ihl/worldgen/IHLWorldGenerator.java index 7a5c83d..95a91f3 100644 --- a/ihl/worldgen/IHLWorldGenerator.java +++ b/ihl/worldgen/IHLWorldGenerator.java @@ -4,248 +4,98 @@ import ihl.IHLMod; import ihl.utils.IHLUtils; import ihl.worldgen.ores.IHLFluid; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Random; import java.util.Set; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.chunk.IChunkProvider; import cpw.mods.fml.common.IWorldGenerator; public class IHLWorldGenerator implements IWorldGenerator { - - private WorldGenMinableMeta - apatiteGenerator, - saltpeterGenerator, - limestoneGenerator, - gypsumGenerator, - potassiumFeldsparGenerator, - tronaGenerator, - gyubneraGenerator, - rocksaltGenerator, - cinnabarGenerator, - bauxiteGenerator, - chromiteGenerator, - muscoviteGenerator, - oilGenerator, - datoliteGenerator, - saltwaterGenerator, - bischofiteGenerator; - private WorldGenMinableMeta currentGenerator; - protected final Map> oreCoordinatesToChunkCoordinates = new HashMap>(); - protected final Map blockToOreCoordinates = new HashMap(); - public final Set precalculatedChunkChache = new HashSet(); + + private static final Block[] replaceableMinerals = new Block[] { Blocks.stone, Blocks.gravel , Blocks.gold_ore, Blocks.coal_ore, Blocks.iron_ore, Blocks.lapis_ore, Blocks.clay, Blocks.diamond_ore, Blocks.redstone_ore, Blocks.emerald_ore}; + private static final Block[] replaceableSand = new Block[] { Blocks.sand }; + private static final Block[] replaceableForOil = new Block[] { Blocks.lava, Blocks.flowing_lava}; public static IHLWorldGenerator instance; - - + private final Set generators = new HashSet(8); + public IHLWorldGenerator() { super(); - apatiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates, IHLUtils.getOreDictBlock("oreApatite"), 0, 360, new Block[] {Blocks.stone,Blocks.gravel}); - saltpeterGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreSaltpeter"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); - limestoneGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreLimestone"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); - gypsumGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreGypsum"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); - potassiumFeldsparGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("orePotassiumFeldspar"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); - tronaGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreTrona"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); - gyubneraGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreGyubnera"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); - rocksaltGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreRockSalt"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); - cinnabarGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreCinnabar"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); - bauxiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreBauxite"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); - chromiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreChromite"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); - muscoviteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreMica"), 0, 140, new Block[] {Blocks.stone,Blocks.gravel}); - oilGenerator = new WorldGenLiquidOre(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLFluid.getBlock("oil"),Blocks.clay, 0, 32, 0, 8, new Block[] {Blocks.lava,Blocks.clay}); - datoliteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreDatolite"), 0, 700, new Block[] {Blocks.stone,Blocks.gravel}); - saltwaterGenerator = new WorldGenLiquidOre(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLFluid.getBlock("saltwater"),Blocks.sandstone, 0, 32, 62, 62, new Block[] {Blocks.sand,Blocks.sandstone}); - bischofiteGenerator = new WorldGenMinableMeta(precalculatedChunkChache,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,IHLUtils.getOreDictBlock("oreBischofite"), 0, 1400, new Block[] {Blocks.stone,Blocks.gravel}); - instance=this; - } - - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) - { - for(int ix=-16+chunkX;ix<=16+chunkX;ix++) + if (IHLMod.config.generateApatiteOre) { - for(int iz=-16+chunkZ;iz<=16+chunkZ;iz++) - { - long chunkKey = (ix<<16)+iz; - if(!this.precalculatedChunkChache.contains(chunkKey)) - { - if(!world.getChunkProvider().chunkExists(ix, iz) || (ix==chunkX && iz==chunkZ)) - { - currentGenerator = switchCurrentOreGenerator(world, random, ix, iz); - if(currentGenerator!=null) - { - if(currentGenerator.generateNewVein(random, ix, iz)) - { - - } - } - } - this.precalculatedChunkChache.add(chunkKey); - } - } - } - long chunkKey = (chunkX<<16)+chunkZ; - if(this.precalculatedChunkChache.contains(chunkKey)) + generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreApatite"), replaceableMinerals)); + } + if (IHLMod.config.generateSaltpeterOre) { - Set oreCoordinatesSet = this.oreCoordinatesToChunkCoordinates.get(chunkKey); - if(oreCoordinatesSet!=null) - { - Object[] oreCoordinatesSetA = oreCoordinatesSet.toArray(); - for(int i=0;i 1.9f && biome.rainfall==0f) - { - return saltwaterGenerator; - } - } - break; - case 14: - if (IHLMod.config.generateDatolite) - { - if (random.nextFloat() < 0.25F) - { - return datoliteGenerator; - } - } - break; - case 15: - if (IHLMod.config.generateBischofite) - { - if (random.nextFloat() < 0.25F) - { - return bischofiteGenerator; - } - } - } - return null; + generators.add(new WorldGeneratorSurfaceLake(IHLFluid.getBlock("saltwater"), replaceableSand)); + } + if (IHLMod.config.generateDatolite) + { + generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreDatolite"), replaceableMinerals)); + } + if (IHLMod.config.generateBischofite) + { + generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreBischofite"), replaceableMinerals)); + } + instance=this; + } + + @Override + public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, + IChunkProvider chunkProvider) { + for (WorldGeneratorBase generator : generators) { + generator.generate(world, chunkX, chunkZ); + } } } -- cgit v1.2.3