From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/worldgen/IHLWorldGenerator.java | 255 ++++++++++++++++++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 ihl/worldgen/IHLWorldGenerator.java (limited to 'ihl/worldgen/IHLWorldGenerator.java') diff --git a/ihl/worldgen/IHLWorldGenerator.java b/ihl/worldgen/IHLWorldGenerator.java new file mode 100644 index 0000000..71478b3 --- /dev/null +++ b/ihl/worldgen/IHLWorldGenerator.java @@ -0,0 +1,255 @@ +package ihl.worldgen; + +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(); + public static IHLWorldGenerator instance; + + + 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) + { + int x1 = 0,y1 = 0,z1 = 0; + for(int ix=-16+chunkX;ix<=16+chunkX;ix++) + { + 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)) + { + 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; + } +} -- cgit v1.2.3