summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/worldGen/Generation.java')
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/worldGen/Generation.java165
1 files changed, 111 insertions, 54 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
index 93310df..8419533 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
+++ b/src/main/java/darkknight/jewelrycraft/worldGen/Generation.java
@@ -2,6 +2,7 @@ package darkknight.jewelrycraft.worldGen;
import java.lang.reflect.Field;
import java.util.Random;
+
import cpw.mods.fml.common.IWorldGenerator;
import darkknight.jewelrycraft.block.BlockList;
import darkknight.jewelrycraft.config.ConfigHandler;
@@ -12,67 +13,95 @@ import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
public class Generation implements IWorldGenerator {
- public static WorldGenStructure STRUCTURE_1 = new WorldGenStructure1();
- public static WorldGenStructure STRUCTURE_2 = new WorldGenStructure2();
- public static WorldGenStructure STRUCTURE_3 = new WorldGenStructure3();
- public static WorldGenStructure STRUCTURE_4 = new WorldGenStructure4();
- public static WorldGenStructure STRUCTURE_5 = new WorldGenStructure5();
- public static WorldGenStructure STRUCTURE_6 = new WorldGenStructure6();
+ public static WorldGenStructure STRUCTURE_1 = new WorldGenStructure1();
+ public static WorldGenStructure STRUCTURE_2 = new WorldGenStructure2();
+ public static WorldGenStructure STRUCTURE_3 = new WorldGenStructure3();
+ public static WorldGenStructure STRUCTURE_4 = new WorldGenStructure4();
+ public static WorldGenStructure STRUCTURE_5 = new WorldGenStructure5();
+ public static WorldGenStructure STRUCTURE_6 = new WorldGenStructure6();
@Override
- public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
+ public void generate(Random random, int chunkX, int chunkZ,
+ World world, IChunkProvider chunkGenerator,
+ IChunkProvider chunkProvider) {
switch (world.provider.dimensionId) {
- case -1:
- generateNether(world, random, chunkX << 4, chunkZ << 4);
- break;
- case 0:
- generateSurface(world, random, chunkX << 4, chunkZ << 4);
- break;
- case 1:
- generateEnd(world, random, chunkX << 4, chunkZ << 4);
- break;
- default:
- generateSurface(world, random, chunkX << 4, chunkZ << 4);
- break;
+ case -1:
+ generateNether(world, random, chunkX << 4, chunkZ << 4);
+ break;
+ case 0:
+ generateSurface(world, random, chunkX << 4, chunkZ << 4);
+ break;
+ case 1:
+ generateEnd(world, random, chunkX << 4, chunkZ << 4);
+ break;
+ default:
+ generateSurface(world, random, chunkX << 4, chunkZ << 4);
+ break;
}
}
- private void generateEnd(World world, Random random, int i, int j) {}
+ private void generateEnd(World world, Random random, int i, int j) {
+ }
- private void generateSurface(World world, Random random, int i, int j) {
+ private void generateSurface(World world, Random random, int i,
+ int j) {
if (ConfigHandler.ENABLE_WORLD_GEN) {
- if (!world.getWorldInfo().getTerrainType().equals(WorldType.FLAT)) {
- if (ConfigHandler.ORE_GEN) generateShadowOre(world, random, i, j);
- if (ConfigHandler.CRYSTAL_GEN) generateCrystals(world, random, i, j);
- try{
- for(Field f: this.getClass().getDeclaredFields()){
- Object obj = f.get(null);
- if (obj instanceof WorldGenStructure && ConfigHandler.STRUCTURES[((WorldGenStructure)obj).structureNo() - 1])
- if(((WorldGenStructure)obj).isUnderground()) generateStructureUnderground((WorldGenStructure)obj, world, random, i, j, ConfigHandler.STRUCTURES_SPAWN_CHANCE[((WorldGenStructure)obj).structureNo()-1], false, true);
- else generateStructureOverground((WorldGenStructure)obj, world, random, i, j, ConfigHandler.STRUCTURES_SPAWN_CHANCE[((WorldGenStructure)obj).structureNo()-1], false, true);
- }
- }
- catch(IllegalAccessException e){
- throw new RuntimeException(e);
- }
+ if (!world.getWorldInfo().getTerrainType()
+ .equals(WorldType.FLAT)) {
+ if (ConfigHandler.ORE_GEN)
+ generateShadowOre(world, random, i, j);
+ if (ConfigHandler.CRYSTAL_GEN)
+ generateCrystals(world, random, i, j);
+ try {
+ for (Field f : this.getClass().getDeclaredFields()) {
+ Object obj = f.get(null);
+ if (obj instanceof WorldGenStructure
+ && ConfigHandler.STRUCTURES[((WorldGenStructure) obj)
+ .structureNo() - 1])
+ if (((WorldGenStructure) obj).isUnderground())
+ generateStructureUnderground(
+ (WorldGenStructure) obj, world,
+ random, i, j,
+ ConfigHandler.STRUCTURES_SPAWN_CHANCE[((WorldGenStructure) obj)
+ .structureNo() - 1],
+ false, true);
+ else
+ generateStructureOverground(
+ (WorldGenStructure) obj, world,
+ random, i, j,
+ ConfigHandler.STRUCTURES_SPAWN_CHANCE[((WorldGenStructure) obj)
+ .structureNo() - 1],
+ false, true);
+ }
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
}
}
}
- private void generateNether(World world, Random random, int i, int j) {}
+ private void generateNether(World world, Random random, int i, int j) {
+ }
- private void generateShadowOre(World world, Random random, int i, int j) {
+ private void generateShadowOre(World world, Random random, int i,
+ int j) {
for (int k = 0; k < 1; k++) {
int x = i + random.nextInt(16);
int y = 5 + random.nextInt(4);
int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.stone) world.setBlock(x, y, z, BlockList.shadowOre);
- int randX = random.nextInt(2), randY = random.nextInt(1), randZ = random.nextInt(2);
- if (random.nextInt(3) == 0 && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.stone) world.setBlock(x + randX, y + randY, z + randZ, BlockList.shadowOre);
+ if (world.getBlock(x, y, z) == Blocks.stone)
+ world.setBlock(x, y, z, BlockList.shadowOre);
+ int randX = random.nextInt(2), randY = random.nextInt(1),
+ randZ = random.nextInt(2);
+ if (random.nextInt(3) == 0 && world.getBlock(x + randX,
+ y + randY, z + randZ) == Blocks.stone)
+ world.setBlock(x + randX, y + randY, z + randZ,
+ BlockList.shadowOre);
}
}
- private void generateCrystals(World world, Random random, int i, int j) {
+ private void generateCrystals(World world, Random random, int i,
+ int j) {
for (int k = 0; k < 16; k++) {
int x = i + random.nextInt(12);
int y = 5 + random.nextInt(64);
@@ -81,47 +110,75 @@ public class Generation implements IWorldGenerator {
int randX = random.nextInt(4);
int randY = random.nextInt(2);
int randZ = random.nextInt(4);
- if (world.getBlock(x + randX, y + randY - 1, z + randZ) == Blocks.stone && world.getBlock(x + randX, y + randY, z + randZ) == Blocks.air) world.setBlock(x + randX, y + randY, z + randZ, BlockList.crystal, random.nextInt(16), 2);
+ if (world.getBlock(x + randX, y + randY - 1,
+ z + randZ) == Blocks.stone
+ && world.getBlock(x + randX, y + randY,
+ z + randZ) == Blocks.air)
+ world.setBlock(x + randX, y + randY, z + randZ,
+ BlockList.crystal, random.nextInt(16), 2);
}
}
}
- private void generateStructureUnderground(WorldGenStructure structure, World world, Random random, int i, int j, int maxAttempts, boolean noOfAttempts, boolean chanceOfSpawning) {
+ private void generateStructureUnderground(WorldGenStructure structure,
+ World world, Random random, int i, int j, int maxAttempts,
+ boolean noOfAttempts, boolean chanceOfSpawning) {
BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j);
if (noOfAttempts) {
for (int k = 0; k < maxAttempts; k++) {
int x = i + random.nextInt(16);
int y = random.nextInt(64);
int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.stone) structure.generate(world, biomeBase, random, x, y, z);
+ if (world.getBlock(x, y, z) == Blocks.stone)
+ structure.generate(world, biomeBase, random, x, y, z);
}
- }
- else if (chanceOfSpawning) {
+ } else if (chanceOfSpawning) {
if (random.nextInt(maxAttempts) == 0) {
int x = i + random.nextInt(16);
int y = random.nextInt(64);
int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.stone) structure.generate(world, biomeBase, random, x, y, z);
+ if (world.getBlock(x, y, z) == Blocks.stone)
+ structure.generate(world, biomeBase, random, x, y, z);
}
}
}
- private void generateStructureOverground(WorldGenStructure structure, World world, Random random, int i, int j, int maxAttempts, boolean noOfAttempts, boolean chanceOfSpawning) {
+ private void generateStructureOverground(WorldGenStructure structure,
+ World world, Random random, int i, int j, int maxAttempts,
+ boolean noOfAttempts, boolean chanceOfSpawning) {
BiomeGenBase biomeBase = world.getBiomeGenForCoords(i, j);
if (noOfAttempts) {
for (int k = 0; k < maxAttempts; k++) {
int x = i + random.nextInt(16);
- int y = (world.getChunkHeightMapMinimum(i, j) > 0 ? world.getChunkHeightMapMinimum(i, j) : world.getChunkFromChunkCoords(i, j).heightMapMinimum - 16) + random.nextInt(4);
+ int y = (world.getChunkHeightMapMinimum(i, j) > 0
+ ? world.getChunkHeightMapMinimum(i, j)
+ : world.getChunkFromChunkCoords(i,
+ j).heightMapMinimum - 16)
+ + random.nextInt(4);
int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) structure.generate(world, biomeBase, random, x, y, z);
+ if (world.getBlock(x, y, z) == Blocks.air
+ && (world.getBlock(x, y - 1, z) == Blocks.stone
+ || world.getBlock(x, y - 1,
+ z) == Blocks.sand
+ || world.getBlock(x, y - 1,
+ z) == Blocks.grass))
+ structure.generate(world, biomeBase, random, x, y, z);
}
- }
- else if (chanceOfSpawning) {
+ } else if (chanceOfSpawning) {
if (random.nextInt(maxAttempts) == 0) {
int x = i + random.nextInt(16);
- int y = (world.getChunkHeightMapMinimum(i, j) > 0 ? world.getChunkHeightMapMinimum(i, j) : world.getChunkFromChunkCoords(i, j).heightMapMinimum - 16) + random.nextInt(4);
+ int y = (world.getChunkHeightMapMinimum(i, j) > 0
+ ? world.getChunkHeightMapMinimum(i, j)
+ : world.getChunkFromChunkCoords(i,
+ j).heightMapMinimum - 16)
+ + random.nextInt(4);
int z = j + random.nextInt(16);
- if (world.getBlock(x, y, z) == Blocks.air && (world.getBlock(x, y - 1, z) == Blocks.stone || world.getBlock(x, y - 1, z) == Blocks.sand || world.getBlock(x, y - 1, z) == Blocks.grass)) {
+ if (world.getBlock(x, y, z) == Blocks.air
+ && (world.getBlock(x, y - 1, z) == Blocks.stone
+ || world.getBlock(x, y - 1,
+ z) == Blocks.sand
+ || world.getBlock(x, y - 1,
+ z) == Blocks.grass)) {
structure.generate(world, biomeBase, random, x, y, z);
System.out.println(x + " " + z);
}