summaryrefslogtreecommitdiff
path: root/ihl/worldgen
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2017-04-05 20:41:13 +0300
committerFoghrye4 <foghrye4@gmail.com>2017-04-05 20:41:13 +0300
commit5b9935f737c226847e668bde0185adbc6a5a8b7b (patch)
tree980cdbadd8635bcd48aa67966c7cceef4677ca64 /ihl/worldgen
parentcd9b5adda974ad9a5e5732fe645571907313b38d (diff)
some experiments
Diffstat (limited to 'ihl/worldgen')
-rw-r--r--ihl/worldgen/IHLWorldGenerator.java4
-rw-r--r--ihl/worldgen/WorldGeneratorBase.java23
-rw-r--r--ihl/worldgen/WorldGeneratorSurfaceLake.java11
-rw-r--r--ihl/worldgen/WorldGeneratorUndergroundLake.java18
4 files changed, 45 insertions, 11 deletions
diff --git a/ihl/worldgen/IHLWorldGenerator.java b/ihl/worldgen/IHLWorldGenerator.java
index 95a91f3..1c65b78 100644
--- a/ihl/worldgen/IHLWorldGenerator.java
+++ b/ihl/worldgen/IHLWorldGenerator.java
@@ -17,7 +17,7 @@ public class IHLWorldGenerator implements IWorldGenerator {
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};
+ private static final Block[] replaceableForOil = new Block[] { Blocks.lava, Blocks.flowing_lava, Blocks.obsidian};
public static IHLWorldGenerator instance;
private final Set<WorldGeneratorBase> generators = new HashSet<WorldGeneratorBase>(8);
@@ -74,7 +74,7 @@ public class IHLWorldGenerator implements IWorldGenerator {
}
if (IHLMod.config.generateOil)
{
- generators.add(new WorldGeneratorUndergroundLake(IHLFluid.getBlock("oil"), Blocks.clay, replaceableForOil));
+ generators.add(new WorldGeneratorUndergroundLake(IHLFluid.getBlock("oil"), Blocks.obsidian, replaceableForOil));
}
if (IHLMod.config.generateSaltwater)
{
diff --git a/ihl/worldgen/WorldGeneratorBase.java b/ihl/worldgen/WorldGeneratorBase.java
index aaaaa66..b5468f5 100644
--- a/ihl/worldgen/WorldGeneratorBase.java
+++ b/ihl/worldgen/WorldGeneratorBase.java
@@ -6,6 +6,7 @@ import java.util.Set;
import ihl.utils.IHLUtils;
import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
@@ -60,10 +61,30 @@ public abstract class WorldGeneratorBase {
return false;
}
+ protected boolean replaceAllExceptOre(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) {
+ Block olblock = ebs.getBlockByExtId(absX & 15, absY & 15, absZ & 15);
+ if(!olblock.equals(ore) &&
+ !olblock.equals(Blocks.bedrock) &&
+ !olblock.equals(Blocks.netherrack) &&
+ !olblock.equals(Blocks.stone) &&
+ !olblock.equals(Blocks.clay)) {
+ 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),
+ 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
index 3affdaf..11abf5e 100644
--- a/ihl/worldgen/WorldGeneratorSurfaceLake.java
+++ b/ihl/worldgen/WorldGeneratorSurfaceLake.java
@@ -1,12 +1,10 @@
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 {
@@ -25,9 +23,12 @@ public class WorldGeneratorSurfaceLake extends WorldGeneratorBase {
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);
+ int dx = ix-x;
+ int dz = iz-z;
+ int d = dx*dx+dz*dz;
+ if (d < 64 && y2 > world.getActualHeight() * 3 / 8
+ && world.getBlock(ix + startX, 63, iz + startZ) == Blocks.air) {
+ this.replace(world, ix + startX, 62, iz + startZ, ore);
}
if (surroundPOI[2] == z) {
break;
diff --git a/ihl/worldgen/WorldGeneratorUndergroundLake.java b/ihl/worldgen/WorldGeneratorUndergroundLake.java
index 6cd0870..b902efa 100644
--- a/ihl/worldgen/WorldGeneratorUndergroundLake.java
+++ b/ihl/worldgen/WorldGeneratorUndergroundLake.java
@@ -18,11 +18,23 @@ public class WorldGeneratorUndergroundLake extends WorldGeneratorBase {
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)) {
+ nextZ: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);
+ int dx = ix - x;
+ int dz = iz - z;
+ int d = dx * dx + dz * dz;
+ if (y2 > 1 && d < 64) {
for (int iy = y2; iy > 0; iy--) {
+ int[] xyz = new int[] { 0, 0, -1, 0, 0, 1, 0, 0 };
+ for (int i = 2; i < xyz.length; i++) {
+ int absX = ix + startX + xyz[i - 2];
+ int absZ = iz + startZ + xyz[i];
+ if(!world.getChunkProvider().chunkExists(absX >> 4, absZ >> 4)) {
+ continue nextZ;
+ }
+ this.replaceAllExceptOre(world, absX, iy + xyz[i - 1],absZ,
+ clayBlock);
+ }
this.replace(world, ix + startX, iy, iz + startZ, ore);
}
}