diff options
Diffstat (limited to 'ihl/worldgen')
| -rw-r--r-- | ihl/worldgen/IHLWorldGenerator.java | 300 | ||||
| -rw-r--r-- | ihl/worldgen/WorldGenLiquidOre.java | 86 | ||||
| -rw-r--r-- | ihl/worldgen/WorldGenMinableMeta.java | 126 | ||||
| -rw-r--r-- | ihl/worldgen/WorldGeneratorBase.java | 69 | ||||
| -rw-r--r-- | ihl/worldgen/WorldGeneratorSurfaceLake.java | 41 | ||||
| -rw-r--r-- | ihl/worldgen/WorldGeneratorUndergroundLake.java | 39 | ||||
| -rw-r--r-- | ihl/worldgen/WorldGeneratorVein.java | 26 | ||||
| -rw-r--r-- | ihl/worldgen/ores/IHLFluid.java | 6 |
8 files changed, 251 insertions, 442 deletions
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<Long,Set<int[]>> oreCoordinatesToChunkCoordinates = new HashMap<Long,Set<int[]>>();
- protected final Map<Long,WorldGenMinableMeta> blockToOreCoordinates = new HashMap<Long,WorldGenMinableMeta>();
- public final Set<Long> precalculatedChunkChache = new HashSet<Long>();
+
+ 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<WorldGeneratorBase> generators = new HashSet<WorldGeneratorBase>(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<int[]> oreCoordinatesSet = this.oreCoordinatesToChunkCoordinates.get(chunkKey);
- if(oreCoordinatesSet!=null)
- {
- Object[] oreCoordinatesSetA = oreCoordinatesSet.toArray();
- for(int i=0;i<oreCoordinatesSetA.length;i++)
- {
- int[] oreCoordinate = (int[]) oreCoordinatesSetA[i];
- int x0 = oreCoordinate[0];
- int y0 = oreCoordinate[1];
- int z0 = oreCoordinate[2];
- long oreCoordinatesKey = (x0<<30)+(y0<<15)+z0;
- this.blockToOreCoordinates.get(oreCoordinatesKey).generate(world, random, x0, y0, z0);
- }
- }
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreSaltpeter"), replaceableMinerals));
}
- }
-
- private WorldGenMinableMeta switchCurrentOreGenerator(World world, Random random, int chunkX, int chunkZ)
- {
- switch(random.nextInt(1000))
+ if (IHLMod.config.generateGyubnera)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreGyubnera"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateCinnabar)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreCinnabar"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateRocksalt)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreRockSalt"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateLimestone)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreLimestone"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateGypsum)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreGypsum"), replaceableMinerals));
+ }
+ if (IHLMod.config.generatePotassiumFeldspar)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("orePotassiumFeldspar"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateTrona)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreTrona"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateBauxite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreBauxite"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateChromite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreChromite"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateMuscovite)
+ {
+ generators.add(new WorldGeneratorVein(IHLUtils.getOreDictBlock("oreMica"), replaceableMinerals));
+ }
+ if (IHLMod.config.generateOil)
+ {
+ generators.add(new WorldGeneratorUndergroundLake(IHLFluid.getBlock("oil"), Blocks.clay, replaceableForOil));
+ }
+ if (IHLMod.config.generateSaltwater)
{
- case 0:
- if (IHLMod.config.generateApatiteOre)
- {
- if (random.nextFloat() < 0.25f)
- {
- return apatiteGenerator;
- }
- }
- break;
- case 1:
- if (IHLMod.config.generateSaltpeterOre)
- {
- if (random.nextFloat() < 0.25f)
- {
- return saltpeterGenerator;
- }
- }
- break;
- case 2:
- if (IHLMod.config.generateGyubnera)
- {
- if (random.nextFloat() < 0.25f)
- {
- return gyubneraGenerator;
- }
- }
- break;
- case 3:
- if (IHLMod.config.generateCinnabar)
- {
- if (random.nextFloat() < 0.25f)
- {
- return cinnabarGenerator;
- }
- }
- break;
- case 4:
- if (IHLMod.config.generateRocksalt)
- {
- if (random.nextFloat() < 0.2F)
- {
- return rocksaltGenerator;
- }
- }
- break;
- case 5:
- if (IHLMod.config.generateLimestone)
- {
- return limestoneGenerator;
- }
- break;
- case 6:
- if (IHLMod.config.generateGypsum)
- {
- return gypsumGenerator;
- }
- break;
- case 7:
- if (IHLMod.config.generatePotassiumFeldspar)
- {
- return potassiumFeldsparGenerator;
- }
- break;
- case 8:
- if (IHLMod.config.generateTrona)
- {
- return tronaGenerator;
- }
- break;
- case 9:
- if (IHLMod.config.generateBauxite)
- {
- if (random.nextFloat() < 0.25F)
- {
- return bauxiteGenerator;
- }
- }
- break;
- case 10:
- if (IHLMod.config.generateChromite)
- {
- if (random.nextFloat() < 0.25F)
- {
- return chromiteGenerator;
- }
- }
- break;
- case 11:
- if (IHLMod.config.generateMuscovite)
- {
- return muscoviteGenerator;
- }
- break;
- case 12:
- if (IHLMod.config.generateOil)
- {
- return oilGenerator;
- }
- break;
- case 13:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- if (IHLMod.config.generateSaltwater)
- {
- BiomeGenBase biome = world.getBiomeGenForCoords(chunkX<<4, chunkZ<<4);
- if(biome.temperature > 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);
+ }
}
}
diff --git a/ihl/worldgen/WorldGenLiquidOre.java b/ihl/worldgen/WorldGenLiquidOre.java deleted file mode 100644 index f59fb2e..0000000 --- a/ihl/worldgen/WorldGenLiquidOre.java +++ /dev/null @@ -1,86 +0,0 @@ -package ihl.worldgen;
-
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import net.minecraft.block.Block;
-import net.minecraft.block.material.Material;
-import net.minecraft.init.Blocks;
-import net.minecraft.world.World;
-
-public class WorldGenLiquidOre extends WorldGenMinableMeta {
-
- public WorldGenLiquidOre(Set<Long> precalculatedChunkChache1,Map<Long, WorldGenMinableMeta> blockToOreCoordinates, Map<Long, Set<int[]>> oreCoordinatesToChunkCoordinates, Block block, Block liquidBedBlock1, int meta, int numberOfBlocks1, int veinMinHeightLimit1, int veinMaxHeightLimit1, Block... replacedBlock1)
- {
- super(precalculatedChunkChache1,blockToOreCoordinates, oreCoordinatesToChunkCoordinates,block, liquidBedBlock1, meta, numberOfBlocks1, veinMinHeightLimit1, veinMaxHeightLimit1, replacedBlock1);
- }
-
- @Override
- public boolean generate(World world, Random random, int x, int y, int z)
- {
- if(replaceableBlocks.contains(world.getBlock(x, y, z)))
- {
- if(y<44 || world.getBlock(x, y+1, z).isAir(world, x, y+1, z) || world.getBlock(x, y+1, z).equals(Blocks.air))
- {
- world.setBlock(x, y, z, mineableBlock, mineableBlockMeta, 2);
- int x1,y1,z1;
- int xyz[] = {0,0,1,0,0,-1,0,0};
- Block block;
- for(int i=0;i<=5;i++)
- {
- x1=x+xyz[i];
- y1=y+xyz[i+1];
- z1=z+xyz[i+2];
- block = world.getBlock(x1,y1,z1);
- if(block!=mineableBlock)
- {
- if(block.getMaterial()==Material.lava)
- {
- world.setBlock(x1, y1, z1, Blocks.obsidian, 0, 2);
- }
- else if(!block.isAir(world, x1, y1, z1) || xyz[i+1]<=0)
- {
- world.setBlock(x1, y1, z1, liquidBedBlock, 0, 2);
- }
- }
- }
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean generateNewVein(Random random, int chunkX1, int chunkZ1)
- {
- int chunkX = chunkX1;
- int chunkZ = chunkZ1;
- int x0=chunkX << 4;
- int z0=chunkZ << 4;
- long chunkKey = (chunkX<<16)+chunkZ;
- for(int ix=x0-this.numberOfBlocks/2;ix<x0+this.numberOfBlocks/2;ix++)
- {
- for(int iz=z0-this.numberOfBlocks/2;iz<z0+this.numberOfBlocks/2;iz++)
- {
- for(int iy=this.veinMinHeightLimit;iy<=this.veinMaxHeightLimit;iy++)
- {
- if((ix-x0)*(ix-x0)+(iz-z0)*(iz-z0) < this.numberOfBlocks*this.numberOfBlocks/4)
- {
- int[] oreCoordinatesArray = new int[] {ix,iy,iz};
- long oreCoordinatesKey = (ix<<30)+(iy<<15)+iz;
- {
- chunkX=x0>>4;
- chunkZ=z0>>4;
- chunkKey = (chunkX<<16)+chunkZ;
- updateOreCoordinatesToChunkCoordinates(chunkKey, oreCoordinatesArray);
- this.blockToOreCoordinates.put(oreCoordinatesKey, this);
- this.precalculatedChunkChache.add(chunkKey);
- }
- }
- }
- }
- }
- return true;
- }
-}
diff --git a/ihl/worldgen/WorldGenMinableMeta.java b/ihl/worldgen/WorldGenMinableMeta.java deleted file mode 100644 index f80edba..0000000 --- a/ihl/worldgen/WorldGenMinableMeta.java +++ /dev/null @@ -1,126 +0,0 @@ -package ihl.worldgen;
-
-import java.util.Arrays;
-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.util.Vec3;
-import net.minecraft.world.World;
-import net.minecraft.world.gen.feature.WorldGenerator;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public class WorldGenMinableMeta extends WorldGenerator {
-
- protected final Block mineableBlock;
- protected final Set<Block> replaceableBlocks=new HashSet<Block>();
- protected final Block liquidBedBlock;
- protected final int mineableBlockMeta;
- protected final int numberOfBlocks;
- protected int blockCounter;
- protected final int veinMaxHeightLimit;
- protected final int veinMinHeightLimit;
-
- public boolean maxBlockReached=false;
- public int lastX=-1;
- public int lastY=64;
- public int lastZ=-1;
- protected ForgeDirection veinDirection = ForgeDirection.SOUTH;//EAST
- protected final Map<Long, Set<int[]>> oreCoordinatesToChunkCoordinates;
- protected final Map<Long,WorldGenMinableMeta> blockToOreCoordinates;
- protected final Set<Long> precalculatedChunkChache;
-
- public WorldGenMinableMeta(Set<Long> precalculatedChunkChache1, Map<Long,WorldGenMinableMeta> blockToOreCoordinates1, Map<Long, Set<int[]>> oreCoordinatesToChunkCoordinates2, Block block, int meta, int numberOfBlocks1, Block... blocks) {
- this(precalculatedChunkChache1 ,blockToOreCoordinates1, oreCoordinatesToChunkCoordinates2, block, Blocks.clay, meta, numberOfBlocks1, 0, 128, blocks);
- }
-
- public WorldGenMinableMeta(Set<Long> precalculatedChunkChache1, Map<Long,WorldGenMinableMeta> blockToOreCoordinates1, Map<Long,Set<int[]>> oreCoordinatesToChunkCoordinates1, Block block, Block liquidBedBlock1, int meta, int numberOfBlocks1, int veinMinHeightLimit1, int veinMaxHeightLimit1, Block... replacedBlock1)
- {
- precalculatedChunkChache=precalculatedChunkChache1;
- blockToOreCoordinates=blockToOreCoordinates1;
- oreCoordinatesToChunkCoordinates=oreCoordinatesToChunkCoordinates1;
- mineableBlock = block;
- replaceableBlocks.addAll(Arrays.asList(replacedBlock1));
- mineableBlockMeta = meta;
- liquidBedBlock=liquidBedBlock1;
- numberOfBlocks = numberOfBlocks1;
- veinMaxHeightLimit=veinMaxHeightLimit1;
- veinMinHeightLimit=veinMinHeightLimit1;
- }
-
- @Override
- public boolean generate(World world, Random random, int x, int y, int z)
- {
- int chunkX = x>>4;
- int chunkZ = z>>4;
- int xyz[] = {0,0,1,0,0,-1,0,0};
- for(int i=0;i<=5;i++)
- {
- int x0 = x+xyz[i];
- int y0 = y+xyz[i+1];
- int z0 = z+xyz[i+2];
- if(x0>>4==chunkX && z0>>4==chunkZ)
- {
- if(replaceableBlocks.contains(world.getBlock(x0, y0, z0)))
- {
- world.setBlock(x0, y0, z0, mineableBlock, mineableBlockMeta, 2);
- }
- }
- }
- return false;
- }
-
- public boolean generateNewVein(Random random, int chunkX1, int chunkZ1)
- {
- Vec3 veinVector = Vec3.createVectorHelper(random.nextFloat()*2-1f, random.nextFloat()-0.5f, random.nextFloat()*2-1f);
- veinVector.normalize();
- int chunkX = chunkX1;
- int chunkZ = chunkZ1;
- int x0=chunkX << 4;
- int z0=chunkZ << 4;
- int y0=random.nextInt(veinMaxHeightLimit);
- //System.out.println("generated new vein with height="+y0);
- float fx=x0;
- float fy=y0;
- float fz=z0;
- long chunkKey = (chunkX<<16)+chunkZ;
- for(int i=0;i<this.numberOfBlocks;i++)
- {
- int[] oreCoordinatesArray = new int[] {x0,y0,z0};
- long oreCoordinatesKey = (x0<<30)+(y0<<15)+z0;
- {
- chunkX=x0>>4;
- chunkZ=z0>>4;
- chunkKey = (chunkX<<16)+chunkZ;
- updateOreCoordinatesToChunkCoordinates(chunkKey, oreCoordinatesArray);
- this.blockToOreCoordinates.put(oreCoordinatesKey, this);
- this.precalculatedChunkChache.add(chunkKey);
- }
- fx+=veinVector.xCoord+random.nextFloat()*0.25f;
- fy+=veinVector.yCoord+random.nextFloat()*0.25f;
- fz+=veinVector.zCoord+random.nextFloat()*0.25f;
- x0=Math.round(fx);
- y0=Math.round(fy);
- z0=Math.round(fz);
- }
- return true;
- }
-
- protected void updateOreCoordinatesToChunkCoordinates(long chunkKey, int[] oreCoordinates)
- {
- if(this.oreCoordinatesToChunkCoordinates.containsKey(chunkKey))
- {
- this.oreCoordinatesToChunkCoordinates.get(chunkKey).add(oreCoordinates);
- }
- else
- {
- Set<int[]> oreCoordinatesS = new HashSet<int[]>();
- oreCoordinatesS.add(oreCoordinates);
- this.oreCoordinatesToChunkCoordinates.put(chunkKey, oreCoordinatesS);
- }
- }
-
-}
diff --git a/ihl/worldgen/WorldGeneratorBase.java b/ihl/worldgen/WorldGeneratorBase.java new file mode 100644 index 0000000..aaaaa66 --- /dev/null +++ b/ihl/worldgen/WorldGeneratorBase.java @@ -0,0 +1,69 @@ +package ihl.worldgen; + +import java.util.HashSet; +import java.util.Random; +import java.util.Set; + +import ihl.utils.IHLUtils; +import net.minecraft.block.Block; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraft.world.chunk.storage.ExtendedBlockStorage; + +public abstract class WorldGeneratorBase { + private final Random random = new Random(); + protected final Block ore; + private final Set<Block> replaceableBlocks = new HashSet<Block>(2); + + public WorldGeneratorBase(Block oreIn, Block... replaceableBlocksIn) { + ore = oreIn; + for (Block block : replaceableBlocksIn) { + replaceableBlocks.add(block); + } + } + + public void generate(World world, int chunkX, int chunkZ) { + int[] centralPOI = this.getPOI(world, chunkX, chunkZ, 0, 0); + int[] xz = new int[] { 0, 1, 0, -1, 0 }; + for (int i = 0; i < 4; i++) { + int[] surroundPOI = this.getPOI(world, chunkX + xz[i], chunkZ + xz[i + 1], xz[i], xz[i + 1]); + this.replaceBlocks(world, centralPOI, surroundPOI, chunkX << 4, chunkZ << 4); + } + } + + protected abstract void replaceBlocks(World world, final int[] centralPOI, final int[] surroundPOI, + final int startX, final int startZ); + + protected boolean replace(World world, int absX, int absY, int absZ, final Block block) { + if (!world.getChunkProvider().chunkExists(absX >> 4, absZ >> 4)) { + throw new IllegalStateException("quered chunk is not yet generated!"); + } + Chunk chunk = world.getChunkFromBlockCoords(absX, absZ); + ExtendedBlockStorage ebs = chunk.getBlockStorageArray()[absY >> 4]; + if (ebs != null && replaceableBlocks.contains(ebs.getBlockByExtId(absX & 15, absY & 15, absZ & 15))) { + IHLUtils.setBlockRaw(ebs, absX & 15, absY & 15, absZ & 15, block); + return true; + } + return false; + } + + protected boolean replaceAll(World world, int absX, int absY, int absZ, final Block block) { + if (!world.getChunkProvider().chunkExists(absX >> 4, absZ >> 4)) { + throw new IllegalStateException("quered chunk is not yet generated!"); + } + Chunk chunk = world.getChunkFromBlockCoords(absX, absZ); + ExtendedBlockStorage ebs = chunk.getBlockStorageArray()[absY >> 4]; + if (ebs != null) { + IHLUtils.setBlockRaw(ebs, absX & 15, absY & 15, absZ & 15, block); + return true; + } + return false; + } + + private int[] getPOI(World world, int chunkX, int chunkZ, int xOffset, int zOffset) { + long seed = (long) chunkX << 16 ^ chunkZ << 8 ^ Block.getIdFromBlock(ore); + random.setSeed(seed); + return new int[] { random.nextInt(16) + xOffset * 16, random.nextInt(world.getActualHeight()/2), + random.nextInt(16) + zOffset * 16 }; + } +} diff --git a/ihl/worldgen/WorldGeneratorSurfaceLake.java b/ihl/worldgen/WorldGeneratorSurfaceLake.java new file mode 100644 index 0000000..3affdaf --- /dev/null +++ b/ihl/worldgen/WorldGeneratorSurfaceLake.java @@ -0,0 +1,41 @@ +package ihl.worldgen; + +import ihl.utils.IHLMathUtils; +import ihl.utils.IHLUtils; +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.storage.ExtendedBlockStorage; + +public class WorldGeneratorSurfaceLake extends WorldGeneratorBase { + + public WorldGeneratorSurfaceLake(Block oreIn, Block[] replaceableBlocksIn) { + super(oreIn, replaceableBlocksIn); + } + + @Override + protected void replaceBlocks(World world, int[] centralPOI, int[] surroundPOI, int startX, int startZ) { + BiomeGenBase biome = world.getBiomeGenForCoords(startX, startZ); + if (biome.temperature < 1.9f || biome.rainfall != 0f) { + return; + } + int x = centralPOI[0], y = centralPOI[1], z = centralPOI[2]; + for (int ix = x; ix < 16 && ix >= 0; ix += IHLMathUtils.sign(surroundPOI[0] - x)) { + int y2 = y += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y); + for (int iz = z; iz < 16 && iz >= 0; iz += IHLMathUtils.sign(surroundPOI[2] - z)) { + y2 += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y2); + if (y2 > world.getActualHeight() * 3 / 8 + && world.getBlock(ix + startX, 64, iz + startZ) == Blocks.air) { + this.replace(world, ix + startX, 63, iz + startZ, ore); + } + if (surroundPOI[2] == z) { + break; + } + } + if (surroundPOI[0] == x) { + break; + } + } + } +} diff --git a/ihl/worldgen/WorldGeneratorUndergroundLake.java b/ihl/worldgen/WorldGeneratorUndergroundLake.java new file mode 100644 index 0000000..6cd0870 --- /dev/null +++ b/ihl/worldgen/WorldGeneratorUndergroundLake.java @@ -0,0 +1,39 @@ +package ihl.worldgen; + +import ihl.utils.IHLMathUtils; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class WorldGeneratorUndergroundLake extends WorldGeneratorBase { + + private final Block clayBlock; + + public WorldGeneratorUndergroundLake(Block oreIn, Block clayIn, Block[] replaceableBlocksIn) { + super(oreIn, replaceableBlocksIn); + clayBlock = clayIn; + } + + @Override + protected void replaceBlocks(World world, int[] centralPOI, int[] surroundPOI, int startX, int startZ) { + int x = centralPOI[0], y = centralPOI[1] - world.getActualHeight() / 4, z = centralPOI[2]; + for (int ix = x; ix < 16 && ix >= 0; ix += IHLMathUtils.sign(surroundPOI[0] - x)) { + int y2 = y += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y); + for (int iz = z; iz < 16 && iz >= 0; iz += IHLMathUtils.sign(surroundPOI[2] - z)) { + y2 += IHLMathUtils.sign(surroundPOI[1] - world.getActualHeight() / 4 - y2); + if (y2 > 1) { + this.replace(world, ix + startX, y2 + 1, iz + startZ, clayBlock); + for (int iy = y2; iy > 0; iy--) { + this.replace(world, ix + startX, iy, iz + startZ, ore); + } + } + if (surroundPOI[2] == z) { + break; + } + } + if (surroundPOI[0] == x) { + break; + } + } + } + +} diff --git a/ihl/worldgen/WorldGeneratorVein.java b/ihl/worldgen/WorldGeneratorVein.java new file mode 100644 index 0000000..3be74e0 --- /dev/null +++ b/ihl/worldgen/WorldGeneratorVein.java @@ -0,0 +1,26 @@ +package ihl.worldgen; + +import ihl.utils.IHLMathUtils; +import net.minecraft.block.Block; +import net.minecraft.world.World; + +public class WorldGeneratorVein extends WorldGeneratorBase { + + public WorldGeneratorVein(Block oreIn, Block[] replaceableBlocksIn) { + super(oreIn, replaceableBlocksIn); + } + + @Override + protected void replaceBlocks(World world, int[] centralPOI, int[] surroundPOI, int startX, int startZ) { + int x = centralPOI[0], y = centralPOI[1], z = centralPOI[2]; + while (x < 16 && x >= 0 && y >= 0 && y < world.getActualHeight() && z >= 0 && z < 16) { + this.replace(world, x + startX, y, z + startZ, ore); + x += IHLMathUtils.sign(surroundPOI[0] - x); + y += IHLMathUtils.sign(surroundPOI[1] - y); + z += IHLMathUtils.sign(surroundPOI[2] - z); + if (IHLMathUtils.sign(surroundPOI[0] - x) == 0 && IHLMathUtils.sign(surroundPOI[1] - y) == 0 + && IHLMathUtils.sign(surroundPOI[2] - z) == 0) + break; + } + } +} diff --git a/ihl/worldgen/ores/IHLFluid.java b/ihl/worldgen/ores/IHLFluid.java index ce98b86..51e0999 100644 --- a/ihl/worldgen/ores/IHLFluid.java +++ b/ihl/worldgen/ores/IHLFluid.java @@ -181,7 +181,7 @@ public class IHLFluid extends Fluid { fluidRubberTreeSap("fluidRubberTreeSap", "fluidRubberTreeSap", 10019, 293, 273, 393, 1200f, "fluidrubbertreesap", Material.water, true, true, false, false),
SpruceResin("SpruceResin","fluidSpruceResin", 10018, 293, 273, 533, 1080, "spruceresin", Material.water, true, true, true, false),
CablingColophony("CablingColophony", 10017, 363, 363, 533, 1070, "cablingcolophony", Material.water, true, false, true),
- Glyceryl("Glyceryl", 10016, 293, 291, 583, 1261, "glyceryl", Material.water, true, false, true),
+ Glycerol("Glycerol", 10016, 293, 291, 583, 1261, "glycerol", Material.water, true, false, true),
SeedOil("SeedOil", 10015, 293, 256, 583, 920, "seedoil", Material.water, true, false, true),
AquaRegia("AquaRegia", 10014, 293, 231, 356, 1060),
SodiumPeroxide("SodiumPeroxide", 10013, 950, 950, 2223, 1800),
@@ -202,10 +202,6 @@ public class IHLFluid extends Fluid { MoltenCopper("MoltenCopper", "fluidMolten", 10048, 1356, 1356, 2840, 8920, "molten.copper", Material.lava, false, false, false),
MoltenBronze("MoltenBronze", 10005, 940, 940, 2840, 8000, "molten.bronze", Material.lava, false, false, false),
MoltenGold("MoltenGold", 10005, 1337, 1337, 3129, 17310, "molten.gold", Material.lava, false, false, false),
- VapourSulfuricAcid("VapourSulfuricAcid", 10004, 610, 283, 610, 4.522F, "vapour.sulfuricacid", new MaterialLiquid(
- MapColor.redColor), false, false, false),
- SulfuricAnhydride("SulfuricAnhydride", 10003, 45, 17, 45, 2, "sulfuricanhydride", new MaterialLiquid(
- MapColor.redColor), true, false, false),
SulfuricAcid("SulfuricAcid", 10002, 293, 283, 610, 1836),
NitricAcid("NitricAcid", 10001, 293, 231, 356, 1100);
|
