aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/everglades/gen
diff options
context:
space:
mode:
authorJohann Bernhardt <johann.bernhardt@tum.de>2021-12-12 19:38:06 +0100
committerJohann Bernhardt <johann.bernhardt@tum.de>2021-12-12 19:38:06 +0100
commit311ab89f93558233a40079f7cb16605b141b5346 (patch)
treec5f44ef47f441a57c5f57aa801f639c7879ed760 /src/main/java/gtPlusPlus/everglades/gen
parent896143b96132f5ac54aa8d8f7386f27487e5e530 (diff)
downloadGT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.gz
GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.tar.bz2
GT5-Unofficial-311ab89f93558233a40079f7cb16605b141b5346.zip
Move sources and resources
Diffstat (limited to 'src/main/java/gtPlusPlus/everglades/gen')
-rw-r--r--src/main/java/gtPlusPlus/everglades/gen/WorldGenDeadLilly.java28
-rw-r--r--src/main/java/gtPlusPlus/everglades/gen/WorldGenMinable_Custom.java90
-rw-r--r--src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT.java49
-rw-r--r--src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Base.java471
-rw-r--r--src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java514
-rw-r--r--src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_Ores.java97
6 files changed, 1249 insertions, 0 deletions
diff --git a/src/main/java/gtPlusPlus/everglades/gen/WorldGenDeadLilly.java b/src/main/java/gtPlusPlus/everglades/gen/WorldGenDeadLilly.java
new file mode 100644
index 0000000000..0314f71eec
--- /dev/null
+++ b/src/main/java/gtPlusPlus/everglades/gen/WorldGenDeadLilly.java
@@ -0,0 +1,28 @@
+package gtPlusPlus.everglades.gen;
+
+import java.util.Random;
+
+import net.minecraft.init.Blocks;
+import net.minecraft.world.World;
+import net.minecraft.world.gen.feature.WorldGenWaterlily;
+
+public class WorldGenDeadLilly extends WorldGenWaterlily {
+
+ @Override
+ public boolean generate(World world, Random rand, int x, int y, int z)
+ {
+ for (int l = 0; l < 10; ++l)
+ {
+ int i1 = x + rand.nextInt(8) - rand.nextInt(8);
+ int j1 = y + rand.nextInt(4) - rand.nextInt(4);
+ int k1 = z + rand.nextInt(8) - rand.nextInt(8);
+
+ if (world.isAirBlock(i1, j1, k1) && Blocks.waterlily.canPlaceBlockAt(world, i1, j1, k1))
+ {
+ world.setBlock(i1, j1, k1, Blocks.waterlily, 0, 2);
+ }
+ }
+
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/everglades/gen/WorldGenMinable_Custom.java b/src/main/java/gtPlusPlus/everglades/gen/WorldGenMinable_Custom.java
new file mode 100644
index 0000000000..303f7353f0
--- /dev/null
+++ b/src/main/java/gtPlusPlus/everglades/gen/WorldGenMinable_Custom.java
@@ -0,0 +1,90 @@
+package gtPlusPlus.everglades.gen;
+
+import static gtPlusPlus.core.lib.CORE.PI;
+
+import java.util.Random;
+
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import net.minecraft.world.gen.feature.WorldGenMinable;
+
+import gtPlusPlus.api.objects.Logger;
+
+public class WorldGenMinable_Custom extends WorldGenMinable
+{
+ /** The block to generate. */
+ private Block oreToGenerate;
+ /** The number of blocks to generate. */
+ private int numberOfBlocks;
+ /** The block to replace. */
+ private Block blockToReplace;
+ /** The meta of the block. */
+ private int mineableBlockMeta;
+
+ public WorldGenMinable_Custom(final Block block, final int count){
+ super(block, count, Blocks.stone);
+ }
+
+ public WorldGenMinable_Custom(final Block block, final int count, final Block target){
+ super(block, count, target);
+ this.oreToGenerate = block;
+ this.numberOfBlocks = count;
+ this.blockToReplace = target;
+ }
+
+ public WorldGenMinable_Custom(final Block block, final int meta, final int number, final Block target){
+ this(block, number, target);
+ this.mineableBlockMeta = meta;
+ }
+
+ @Override
+ public boolean generate(final World world, final Random rand, final int x, final int y, final int z)
+ {
+ final float f = rand.nextFloat() * PI;
+ final double d0 = x + 16 + ((MathHelper.sin(f) * this.numberOfBlocks) / 4.0F);
+ final double d1 = (x + 16) - ((MathHelper.sin(f) * this.numberOfBlocks) / 4.0F);
+ final double d2 = z + 16 + ((MathHelper.cos(f) * this.numberOfBlocks) / 4.0F);
+ final double d3 = (z + 16) - ((MathHelper.cos(f) * this.numberOfBlocks) / 4.0F);
+ final double d4 = (y + rand.nextInt(8)) - 1;
+ final double d5 = (y + rand.nextInt(8)) - 1;
+
+ for (int l = 0; l <= this.numberOfBlocks; ++l)
+ {
+ final double d6 = d0 + (((d1 - d0) * l) / this.numberOfBlocks);
+ final double d7 = d4 + (((d5 - d4) * l) / this.numberOfBlocks);
+ final double d8 = d2 + (((d3 - d2) * l) / this.numberOfBlocks);
+ final double d9 = (rand.nextDouble() * this.numberOfBlocks) / 8.0D;
+ final double d10 = ((MathHelper.sin((l * PI) / this.numberOfBlocks) + 1.0F) * d9) + 1.0D;
+ final double d11 = ((MathHelper.sin((l * PI) / this.numberOfBlocks) + 1.0F) * d9) + 1.0D;
+ final int i1 = MathHelper.floor_double(d6 - (d10 / 2.0D));
+ final int j1 = MathHelper.floor_double(d7 - (d11 / 2.0D));
+ final int k1 = MathHelper.floor_double(d8 - (d10 / 2.0D));
+ final int l1 = MathHelper.floor_double(d6 + (d10 / 2.0D));
+ final int i2 = MathHelper.floor_double(d7 + (d11 / 2.0D));
+ final int j2 = MathHelper.floor_double(d8 + (d10 / 2.0D));
+
+ for (int k2 = i1; k2 <= l1; ++k2){
+ final double d12 = ((k2 + 0.5D) - d6) / (d10 / 2.0D);
+ if ((d12 * d12) < 1.0D){
+ for (int l2 = j1; l2 <= i2; ++l2){
+ final double d13 = ((l2 + 0.5D) - d7) / (d11 / 2.0D);
+ if (((d12 * d12) + (d13 * d13)) < 1.0D){
+ for (int i3 = k1; i3 <= j2; ++i3){
+ final double d14 = ((i3 + 0.5D) - d8) / (d10 / 2.0D);
+ if ((((d12 * d12) + (d13 * d13) + (d14 * d14)) < 1.0D) && world.getBlock(k2, l2, i3).isReplaceableOreGen(world, k2, l2, i3, this.blockToReplace))
+ {
+ world.setBlock(k2, l2, i3, this.oreToGenerate, this.mineableBlockMeta, 3);
+ Logger.INFO("Generated a "+this.oreToGenerate.getLocalizedName()+" at x: "+k2+" | y: "+l2+" | z: "+i3);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT.java b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT.java
new file mode 100644
index 0000000000..2035cfe096
--- /dev/null
+++ b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT.java
@@ -0,0 +1,49 @@
+package gtPlusPlus.everglades.gen.gt;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
+
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.IChunkProvider;
+
+import gtPlusPlus.xmod.gregtech.HANDLER_GT;
+
+public abstract class WorldGen_GT {
+ public final String mWorldGenName;
+ public final boolean mEnabled;
+ private final Map<String, Boolean> mDimensionMap = new ConcurrentHashMap<String, Boolean>();
+
+ public WorldGen_GT(String aName, List aList, boolean aDefault) {
+ this.mWorldGenName = aName;
+ this.mEnabled = HANDLER_GT.sCustomWorldgenFile.get("worldgen", this.mWorldGenName, aDefault);
+ if (this.mEnabled) {
+ aList.add(this);
+ }
+
+ }
+
+ public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX,
+ int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
+ return false;
+ }
+
+ public boolean executeCavegen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX,
+ int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
+ return false;
+ }
+
+ public boolean isGenerationAllowed(World aWorld, int aDimensionType, int aAllowedDimensionType) {
+ String aDimName = aWorld.provider.getDimensionName();
+ Boolean tAllowed = (Boolean) this.mDimensionMap.get(aDimName);
+ if (tAllowed == null) {
+ boolean tValue = HANDLER_GT.sCustomWorldgenFile.get("worldgen.dimensions." + this.mWorldGenName, aDimName,
+ aDimensionType == aAllowedDimensionType);
+ this.mDimensionMap.put(aDimName, Boolean.valueOf(tValue));
+ return tValue;
+ } else {
+ return tAllowed.booleanValue();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Base.java b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Base.java
new file mode 100644
index 0000000000..f1d62cf58e
--- /dev/null
+++ b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Base.java
@@ -0,0 +1,471 @@
+package gtPlusPlus.everglades.gen.gt;
+
+import java.util.*;
+
+import cpw.mods.fml.common.IWorldGenerator;
+
+import net.minecraft.block.Block;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.Chunk;
+import net.minecraft.world.chunk.IChunkProvider;
+import net.minecraft.world.gen.feature.WorldGenMinable;
+
+import gregtech.api.util.GT_Log;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.random.XSTR;
+import gtPlusPlus.core.material.ELEMENT;
+import gtPlusPlus.everglades.dimension.Dimension_Everglades;
+import gtPlusPlus.xmod.gregtech.HANDLER_GT;
+
+public class WorldGen_GT_Base implements IWorldGenerator {
+
+ /**
+ * Class Variables
+ */
+
+ /**
+ * Control percentage of filled 3x3 chunks. Lower number means less oreveins
+ * spawn
+ */
+ public static int oreveinPercentage;
+ /**
+ * Control number of attempts to find a valid orevein. Generally this
+ * maximum limit isn't hit, selecting a vein is cheap
+ */
+ public static int oreveinAttempts;
+ /**
+ * Control number of attempts to place a valid orevein. If a vein wasn't
+ * placed due to height restrictions, completely in the water, etc, another
+ * attempt is tried.
+ */
+ public static int oreveinMaxPlacementAttempts;
+ /**
+ * Debug parameter for world generation. Tracks chunks added/removed from
+ * run queue.
+ */
+ public static boolean debugWorldGen = false;
+ /**
+ * Try re-implement Richard Hendrick's Chunk by Chunk Ore Generation from
+ * his GT5u fork.
+ */
+
+ public static List<Runnable> mList = new ArrayList<Runnable>();
+ public static HashSet<Long> ProcChunks = new HashSet<Long>();
+ // This is probably not going to work. Trying to create a fake orevein to
+ // put into hashtable when there will be no ores in a vein.
+ public static WorldGen_GT_Ore_Layer noOresInVein = new WorldGen_GT_Ore_Layer("vein0", 0, 255, 0, 0,
+ 0, ELEMENT.getInstance().IRON, ELEMENT.getInstance().IRON, ELEMENT.getInstance().IRON, ELEMENT.getInstance().IRON);
+
+ public static Hashtable<Long, WorldGen_GT_Ore_Layer> validOreveins = new Hashtable<Long, WorldGen_GT_Ore_Layer>(
+ 1024);
+
+ public boolean mIsGenerating = false;
+ public static final Object listLock = new Object();
+ // private static boolean gcAsteroids = true;
+
+ public WorldGen_GT_Base() {
+ if (debugWorldGen) {
+ GT_Log.out.println("GTPP_Worldgenerator created");
+ }
+ }
+
+ @Override
+ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator,
+ IChunkProvider chunkProvider) {
+ if (world.provider.dimensionId == Dimension_Everglades.DIMID) {
+ generateSafely(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
+ }
+ }
+
+ public synchronized void generateSafely(Random random, int chunkX, int chunkZ, World world,
+ IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
+ int xDim = Dimension_Everglades.DIMID;
+ switch (world.provider.dimensionId) {
+ case -1: // Nether
+ // generateNether(world, random, chunkX * 16, chunkZ * 16);
+ break;
+ case 0: // Overworld
+ // generateSurface(world, random, chunkX * 16, chunkZ * 16);
+ break;
+ case 1: // End
+ // generateEnd(world, random, chunkX * 16, chunkZ * 16);
+ break;
+ default: // Any other dimension
+ if (world.provider.dimensionId != xDim) {
+ break;
+ }
+ else {
+ generateEverglades(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider);
+ break;
+ }
+ }
+ }
+
+ private synchronized void generateEverglades(Random aRandom, int aX, int aZ, World aWorld,
+ IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
+ Logger.WORLD("Trying to Generate Dimension.");
+ synchronized (listLock) {
+ Logger.WORLD("Locked List addition.");
+ if (WorldGen_GT_Base.mList.add(new WorldGenContainer(new XSTR(Math.abs(aRandom.nextInt()) + 1), aX, aZ,
+ Dimension_Everglades.DIMID,
+ aWorld, aChunkGenerator, aChunkProvider,
+ aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName))){
+ Logger.WORLD("Locked List addition. Success.");
+ }
+ else {
+ Logger.WORLD("Locked List addition. Fail.");
+ }
+ if (debugWorldGen)
+ GT_Log.out.println("ADD WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId
+ + " chunk x:" + aX + " z:" + aZ + " SIZE: " + WorldGen_GT_Base.mList.size());
+ }
+
+ if (!this.mIsGenerating) {
+ Logger.WORLD("Is not generating.");
+ this.mIsGenerating = true;
+ Logger.WORLD("Setting Generation to true.");
+ int mList_sS = WorldGen_GT_Base.mList.size();
+ mList_sS = Math.min(mList_sS, 3); // Run a maximum of 3 chunks at a
+ // time through worldgen. Extra
+ // chunks get done later.
+ for (int i = 0; i < mList_sS; i++) {
+ WorldGenContainer toRun = (WorldGenContainer) WorldGen_GT_Base.mList.get(0);
+ if (debugWorldGen)
+ GT_Log.out.println("RUN WorldSeed:" + aWorld.getSeed() + " DimId" + aWorld.provider.dimensionId
+ + " chunk x:" + toRun.mX + " z:" + toRun.mZ + " SIZE: " + WorldGen_GT_Base.mList.size()
+ + " i: " + i);
+ synchronized (listLock) {
+ Logger.WORLD("Locked List Removal.");
+ WorldGen_GT_Base.mList.remove(0);
+ }
+ toRun.run();
+ }
+ this.mIsGenerating = false;
+ Logger.WORLD("Is Generating now set to false..");
+ }
+ }
+
+ public void generateOre(Block block, World world, Random random, int chunk_x, int chunk_z, int maxX, int maxZ,
+ int maxVeinSize, int chancesToSpawn, int minY, int maxY, Block generateIn) {
+ int heightRange = maxY - minY;
+ WorldGenMinable worldgenminable = new WorldGenMinable(block, maxVeinSize, generateIn);
+ for (int k1 = 0; k1 < chancesToSpawn; ++k1) {
+ int xrand = random.nextInt(16);
+ int yrand = random.nextInt(heightRange) + minY;
+ int zrand = random.nextInt(16);
+ worldgenminable.generate(world, random, chunk_x + xrand, yrand, chunk_z + zrand);
+ }
+ }
+
+ public static class WorldGenContainer implements Runnable {
+ public final Random mRandom;
+ public final int mX;
+ public final int mZ;
+ public final int mDimensionType;
+ public final World mWorld;
+ public final IChunkProvider mChunkGenerator;
+ public final IChunkProvider mChunkProvider;
+ public final String mBiome;
+
+ // Local class to track which orevein seeds must be checked when doing
+ // chunkified worldgen
+ class NearbySeeds {
+ public int mX;
+ public int mZ;
+
+ NearbySeeds(int x, int z) {
+ this.mX = x;
+ this.mZ = z;
+ }
+ };
+
+ public static ArrayList<NearbySeeds> seedList = new ArrayList<NearbySeeds>();
+
+ // aX and aZ are now the by-chunk X and Z for the chunk of interest
+ public WorldGenContainer(Random aRandom, int aX, int aZ, int aDimensionType, World aWorld,
+ IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider, String aBiome) {
+ this.mRandom = aRandom;
+ this.mX = aX;
+ this.mZ = aZ;
+ this.mDimensionType = aDimensionType;
+ this.mWorld = aWorld;
+ this.mChunkGenerator = aChunkGenerator;
+ this.mChunkProvider = aChunkProvider;
+ this.mBiome = aBiome;
+ }
+
+ public void worldGenFindVein(int oreseedX, int oreseedZ) {
+ // Explanation of oreveinseed implementation.
+ // (long)this.mWorld.getSeed()<<16) Deep Dark does two oregen
+ // passes, one with getSeed set to +1 the original world seed. This
+ // pushes that +1 off the low bits of oreseedZ, so that the hashes
+ // are far apart for the two passes.
+ // ((this.mWorld.provider.dimensionId & 0xffL)<<56) Puts the
+ // dimension in the top bits of the hash, to make sure to get unique
+ // hashes per dimension
+ // ((long)oreseedX & 0x000000000fffffffL) << 28) Puts the chunk X in
+ // the bits 29-55. Cuts off the top few bits of the chunk so we have
+ // bits for dimension.
+ // ( (long)oreseedZ & 0x000000000fffffffL )) Puts the chunk Z in the
+ // bits 0-27. Cuts off the top few bits of the chunk so we have bits
+ // for dimension.
+ long oreveinSeed = (this.mWorld.getSeed() << 16) ^ ((this.mWorld.provider.dimensionId & 0xffL) << 56
+ | ((oreseedX & 0x000000000fffffffL) << 28) | (oreseedZ & 0x000000000fffffffL)); // Use
+ // an
+ // RNG
+ // that
+ // is
+ // identical
+ // every
+ // time
+ // it
+ // is
+ // called
+ // for
+ // this
+ // oreseed.
+ XSTR oreveinRNG = new XSTR(oreveinSeed);
+ int oreveinPercentageRoll = oreveinRNG.nextInt(100); // Roll the
+ // dice, see
+ // if we get
+ // an
+ // orevein
+ // here at
+ // all
+ int noOrePlacedCount = 0;
+ String tDimensionName = "";
+ if (debugWorldGen) {
+ tDimensionName = this.mWorld.provider.getDimensionName();
+ }
+
+ if (debugWorldGen){
+ GT_Log.out.println(" Finding oreveins for oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ="
+ + this.mZ + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " worldSeed="
+ + this.mWorld.getSeed());
+ }
+
+ Logger.INFO("[World Generation Debug] !validOreveins.containsKey(oreveinSeed) | oreveinSeed: "+oreveinSeed);
+ // Search for a valid orevein for this dimension
+ if (!validOreveins.containsKey(oreveinSeed)) {
+
+
+ Logger.INFO("[World Generation Debug] oreveinPercentageRoll < oreveinPercentage? "+((oreveinPercentageRoll < oreveinPercentage)));
+ Logger.INFO("[World Generation Debug] WorldGen_GT_Ore_Layer.sWeight > 0? "+(WorldGen_GT_Ore_Layer.sWeight > 0));
+ Logger.INFO("[World Generation Debug] WorldGen_GT_Ore_Layer.sList.size() > 0? "+(WorldGen_GT_Ore_Layer.sList.size() > 0));
+ if ((oreveinPercentageRoll < oreveinPercentage) && (WorldGen_GT_Ore_Layer.sWeight > 0)
+ && (WorldGen_GT_Ore_Layer.sList.size() > 0)) {
+ int placementAttempts = 0;
+ boolean oreveinFound = false;
+ int i;
+ for (i = 0; (i < oreveinAttempts) && (!oreveinFound)
+ && (placementAttempts < oreveinMaxPlacementAttempts); i++) {
+ Logger.INFO("[World Generation Debug] i: "+i);
+ Logger.INFO("[World Generation Debug] placementAttempts: "+placementAttempts);
+ Logger.INFO("[World Generation Debug] oreveinAttempts: "+oreveinAttempts);
+ Logger.INFO("[World Generation Debug] (placementAttempts < oreveinMaxPlacementAttempts): "+(placementAttempts < oreveinMaxPlacementAttempts));
+ Logger.INFO("[World Generation Debug] oreveinFound: "+oreveinFound);
+ int tRandomWeight = oreveinRNG.nextInt(WorldGen_GT_Ore_Layer.sWeight);
+ for (WorldGen_GT_Ore_Layer tWorldGen : WorldGen_GT_Ore_Layer.sList) {
+ Logger.INFO("[World Generation Debug] Iterating sList - Size: "+WorldGen_GT_Ore_Layer.sList.size());
+ tRandomWeight -= (tWorldGen).mWeight;
+ if (tRandomWeight <= 0) {
+ try {
+ // Adjust the seed so that this layer has a
+ // series of unique random numbers.
+ // Otherwise multiple attempts at this same
+ // oreseed will get the same offset and X/Z
+ // values. If an orevein failed, any orevein
+ // with the
+ // same minimum heights would fail as well.
+ // This prevents that, giving each orevein a
+ // unique height each pass through here.
+ int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld,
+ new XSTR(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))), this.mBiome,
+ this.mDimensionType, this.mX * 16, this.mZ * 16, oreseedX * 16,
+ oreseedZ * 16, this.mChunkGenerator, this.mChunkProvider);
+ switch (placementResult) {
+ case WorldGen_GT_Ore_Layer.ORE_PLACED:
+ if (debugWorldGen)
+ GT_Log.out.println(" Added oreveinSeed=" + oreveinSeed
+ + " tries at oremix=" + i + " placementAttempts="
+ + placementAttempts + " dimensionName=" + tDimensionName);
+ validOreveins.put(oreveinSeed, tWorldGen);
+ oreveinFound = true;
+ Logger.INFO("[World Generation Debug] ORE_PLACED");
+ break;
+ case WorldGen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER:
+ placementAttempts++;
+ Logger.INFO("[World Generation Debug] NO_ORE_IN_BOTTOM_LAYER | Attempts: "+placementAttempts);
+ // SHould do retry in this case
+ // until out of chances
+ break;
+ case WorldGen_GT_Ore_Layer.NO_OVERLAP:
+ // Orevein didn't reach this chunk,
+ // can't add it yet to the hash
+ Logger.INFO("[World Generation Debug] NO_OVERLAP");
+ if (debugWorldGen) GT_Log.out.println(
+ " Added far oreveinSeed=" + oreveinSeed + " " +
+ ( tWorldGen).mWorldGenName +
+ " tries at oremix=" + i +
+ " placementAttempts=" + placementAttempts +
+ " dimensionName=" + tDimensionName
+ );
+ validOreveins.put(oreveinSeed, tWorldGen);
+ oreveinFound = true;
+ break;
+ case WorldGen_GT_Ore_Layer.NO_OVERLAP_AIR_BLOCK:
+ if (debugWorldGen) GT_Log.out.println(
+ " No overlap and air block in test spot=" + oreveinSeed + " " +
+ ( tWorldGen).mWorldGenName +
+ " tries at oremix=" + i +
+ " placementAttempts=" + placementAttempts +
+ " dimensionName=" + tDimensionName
+ );
+ // SHould do retry in this case until out of chances
+ Logger.INFO("[World Generation Debug] NO_OVERLAP_AIR_BLOCK");
+ placementAttempts++;
+ break;
+ }
+ break; // Try the next orevein
+ }
+ catch (Throwable e) {
+ if (debugWorldGen)
+ GT_Log.out.println("Exception occurred on oreVein" + tWorldGen + " oreveinSeed="
+ + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ + " oreseedX="
+ + oreseedX + " oreseedZ=" + oreseedZ);
+ e.printStackTrace(GT_Log.err);
+ }
+ }
+ }
+ }
+ // Only add an empty orevein if are unable to place a vein
+ // at the oreseed chunk.
+ if ((!oreveinFound) && (this.mX == oreseedX) && (this.mZ == oreseedZ)) {
+ if (debugWorldGen)
+ GT_Log.out.println(" Empty oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ
+ + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " tries at oremix=" + i
+ + " placementAttempts=" + placementAttempts + " dimensionName=" + tDimensionName);
+ validOreveins.put(oreveinSeed, noOresInVein);
+ }
+ }
+ else if (oreveinPercentageRoll >= oreveinPercentage) {
+ if (debugWorldGen)
+ GT_Log.out.println(" Skipped oreveinSeed=" + oreveinSeed + " mX=" + this.mX + " mZ=" + this.mZ
+ + " oreseedX=" + oreseedX + " oreseedZ=" + oreseedZ + " RNG=" + oreveinPercentageRoll
+ + " %=" + oreveinPercentage + " dimensionName=" + tDimensionName);
+ validOreveins.put(oreveinSeed, noOresInVein);
+ }
+ }
+ else {
+ // oreseed is located in the previously processed table
+ if (debugWorldGen)
+ GT_Log.out.print(" Valid oreveinSeed=" + oreveinSeed + " validOreveins.size()="
+ + validOreveins.size() + " ");
+ WorldGen_GT_Ore_Layer tWorldGen = validOreveins.get(oreveinSeed);
+ oreveinRNG.setSeed(oreveinSeed ^ (Block.getIdFromBlock(tWorldGen.mPrimaryMeta))); // Reset
+ // RNG
+ // to
+ // only
+ // be
+ // based
+ // on
+ // oreseed
+ // X/Z
+ // and
+ // type
+ // of
+ // vein
+ int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, oreveinRNG, this.mBiome,
+ this.mDimensionType, this.mX * 16, this.mZ * 16, oreseedX * 16, oreseedZ * 16,
+ this.mChunkGenerator, this.mChunkProvider);
+ switch (placementResult) {
+ case WorldGen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER:
+ if (debugWorldGen)
+ GT_Log.out.println(" No ore in bottom layer");
+ break;
+ case WorldGen_GT_Ore_Layer.NO_OVERLAP:
+ if (debugWorldGen)
+ GT_Log.out.println(" No overlap");
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void run() {
+ long startTime = System.nanoTime();
+ int oreveinMaxSize;
+
+ // Determine bounding box on how far out to check for oreveins
+ // affecting this chunk
+ // For now, manually reducing oreveinMaxSize when not in the
+ // Underdark for performance
+ if (this.mWorld.provider.getDimensionName().equals("Underdark")) {
+ oreveinMaxSize = 24; // Leave Deep Dark/Underdark max oregen at
+ // 32, instead of 64
+ }
+ else {
+ oreveinMaxSize = 48;
+ }
+
+ int wXbox = this.mX - (oreveinMaxSize / 16);
+ int eXbox = this.mX + (oreveinMaxSize / 16 + 1); // Need to add 1
+ // since it is
+ // compared
+ // using a <
+ int nZbox = this.mZ - (oreveinMaxSize / 16);
+ int sZbox = this.mZ + (oreveinMaxSize / 16 + 1);
+
+ // Search for orevein seeds and add to the list;
+ for (int x = wXbox; x < eXbox; x++) {
+ for (int z = nZbox; z < sZbox; z++) {
+ // Determine if this X/Z is an orevein seed
+ if (((Math.abs(x) % 3) == 1) && ((Math.abs(z) % 3) == 1)) {
+ if (debugWorldGen)
+ GT_Log.out.println("Adding seed x=" + x + " z=" + z);
+ seedList.add(new NearbySeeds(x, z));
+ }
+ }
+ }
+
+ // Now process each oreseed vs this requested chunk
+ for (; seedList.size() != 0; seedList.remove(0)) {
+ if (debugWorldGen)
+ GT_Log.out.println("Processing seed x=" + seedList.get(0).mX + " z=" + seedList.get(0).mZ);
+ worldGenFindVein(seedList.get(0).mX, seedList.get(0).mZ);
+ }
+
+ long oregenTime = System.nanoTime();
+
+ // Do leftover worldgen for this chunk (GT_Stones and GT_small_ores)
+ try {
+ for (WorldGen_GT tWorldGen : HANDLER_GT.sWorldgenListEverglades) {
+ /*
+ * if (debugWorldGen) GT_Log.out.println(
+ * "tWorldGen.mWorldGenName="+tWorldGen.mWorldGenName );
+ */
+ tWorldGen.executeWorldgen(this.mWorld, this.mRandom, this.mBiome, this.mDimensionType, this.mX * 16,
+ this.mZ * 16, this.mChunkGenerator, this.mChunkProvider);
+ }
+ }
+ catch (Throwable e) {
+ e.printStackTrace(GT_Log.err);
+ }
+
+ long leftOverTime = System.nanoTime();
+
+ Chunk tChunk = this.mWorld.getChunkFromBlockCoords(this.mX, this.mZ);
+ if (tChunk != null) {
+ tChunk.isModified = true;
+ }
+ long endTime = System.nanoTime();
+ long duration = (endTime - startTime);
+ if (debugWorldGen) {
+ GT_Log.out.println(" Oregen took " + (oregenTime - startTime) + " Leftover gen took "
+ + (leftOverTime - oregenTime) + " Worldgen took " + duration + " nanoseconds");
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java
new file mode 100644
index 0000000000..140098ee06
--- /dev/null
+++ b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_GT_Ore_Layer.java
@@ -0,0 +1,514 @@
+package gtPlusPlus.everglades.gen.gt;
+
+import static gtPlusPlus.everglades.gen.gt.WorldGen_GT_Base.debugWorldGen;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.*;
+
+import net.minecraft.block.Block;
+import net.minecraft.init.Blocks;
+import net.minecraft.util.MathHelper;
+import net.minecraft.world.World;
+import net.minecraft.world.chunk.IChunkProvider;
+
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Materials;
+import gregtech.api.util.GT_Log;
+import gregtech.common.blocks.GT_Block_Ores;
+import gregtech.common.blocks.GT_TileEntity_Ores;
+
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.core.lib.CORE;
+import gtPlusPlus.core.material.Material;
+import gtPlusPlus.core.util.Utils;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import gtPlusPlus.everglades.dimension.Dimension_Everglades;
+import gtPlusPlus.xmod.gregtech.HANDLER_GT;
+
+public class WorldGen_GT_Ore_Layer
+extends WorldGen_GT {
+ public static ArrayList<WorldGen_GT_Ore_Layer> sList = new ArrayList<WorldGen_GT_Ore_Layer>();
+ public static int sWeight = 0;
+ public final short mMinY;
+ public final short mMaxY;
+ public final short mWeight;
+ public final short mDensity;
+ public final short mSize;
+ public Block mPrimaryMeta;
+ public Block mSecondaryMeta;
+ public Block mBetweenMeta;
+ public Block mSporadicMeta;
+ public final Material mPrimary;
+ public final Material mSecondary;
+ public final Material mBetween;
+ public final Material mSporadic;
+
+ public static boolean mUpdated = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK;
+ public static final Block mStoneTypes;
+
+ //public final String mBiome;
+ public final String mRestrictBiome;
+ public final boolean mOverworld;
+ public final boolean mNether;
+ public final boolean mEnd;
+ public static final int WRONG_BIOME=0;
+ public static final int WRONG_DIMENSION=1;
+ public static final int NO_ORE_IN_BOTTOM_LAYER=2;
+ public static final int NO_OVERLAP=3;
+ public static final int ORE_PLACED=4;
+ public static final int NO_OVERLAP_AIR_BLOCK=5;
+
+ //public final boolean mMoon;
+ //public final boolean mMars;
+ //public final boolean mAsteroid;
+ public final String aTextWorldgen = "worldgen.";
+
+ static {
+ if (mUpdated) {
+ Object tempBlock = null;
+ try {
+ Field temp = ReflectionUtils.getField(GregTech_API.class, "sBlockStones");
+ tempBlock = temp.get(null);
+ }
+ catch (IllegalArgumentException | IllegalAccessException e) {}
+ mStoneTypes = (Block) tempBlock;
+ }
+ else {
+ mStoneTypes = null;
+ }
+ }
+
+
+ public WorldGen_GT_Ore_Layer(String aName, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic) {
+ this(aName, true, aMinY, aMaxY, aWeight, aDensity, aSize, false, false, false, false, false, false, aPrimary, aSecondary, aBetween, aSporadic);
+ }
+
+
+ public WorldGen_GT_Ore_Layer(String aName, boolean aDefault, int aMinY, int aMaxY, int aWeight, int aDensity, int aSize, boolean aOverworld, boolean aNether, boolean aEnd, boolean GC_UNUSED1, boolean GC_UNUSED2, boolean GC_UNUSED3, Material aPrimary, Material aSecondary, Material aBetween, Material aSporadic) {
+ super(aName, sList, aDefault);
+ Logger.WORLD("Creating Ore Layer Object");
+ this.mOverworld = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Overworld", aOverworld);
+ this.mNether = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Nether", aNether);
+ this.mEnd = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "TheEnd", aEnd);
+ //this.mMoon = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Moon", aMoon);
+ //this.mMars = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars);
+ //this.mAsteroid = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid);
+ this.mMinY = 5;
+ short mMaxY = 14;
+ if (mMaxY < (this.mMinY + 7)) {
+ GT_Log.out.println(
+ "Oremix " + this.mWorldGenName +
+ " has invalid Min/Max heights!"
+ );
+ mMaxY = (short) (this.mMinY + 7);
+ }
+ this.mMaxY = mMaxY;
+ this.mWeight = ((short) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight));
+ this.mDensity = ((short) HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity));
+ this.mSize = ((short) Math.max(1, HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize)));
+ this.mPrimary = aPrimary;
+ this.mSecondary = aSecondary;
+ this.mBetween = aBetween;
+ this.mSporadic = aSporadic;
+ this.mPrimaryMeta = aPrimary.getOreBlock(1);
+ this.mSecondaryMeta = aSecondary.getOreBlock(1);
+ this.mBetweenMeta = aBetween.getOreBlock(1);
+ this.mSporadicMeta = aSporadic.getOreBlock(1);
+ this.mRestrictBiome = HANDLER_GT.sCustomWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RestrictToBiomeName", "None");
+
+ //if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mPrimaryMeta + " for " + mWorldGenName + " does not exist");
+ //if (mSecondaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mSecondaryMeta + " for " + mWorldGenName + " does not exist");
+ //if (mBetweenMeta != -1 && GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mBetweenMeta + " for " + mWorldGenName + " does not exist");
+ //if (mPrimaryMeta != -1 && GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)] == null) throw new IllegalArgumentException("A Material for the supplied ID " + mSporadicMeta + " for " + mWorldGenName + " does not exist");
+
+ if (this.mEnabled) {
+ //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mPrimaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd);
+ //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSecondaryMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd);
+ //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mBetweenMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd);
+ //GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd);
+ sWeight += this.mWeight;
+ }
+ }
+
+ public int executeWorldgenChunkified(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, int aSeedX, int aSeedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
+
+ //Debug Handler
+ /**
+ * This handles Variables that are null during Init
+ */
+
+ if (this.mPrimaryMeta == Blocks.stone || this.mSecondaryMeta == Blocks.stone
+ || this.mBetweenMeta == Blocks.stone || this.mSporadicMeta == Blocks.stone){
+ this.mPrimaryMeta = this.mPrimary.getOreBlock(1);
+ this.mSecondaryMeta = this.mSecondary.getOreBlock(1);
+ this.mBetweenMeta = this.mBetween.getOreBlock(1);
+ this.mSporadicMeta = this.mSporadic.getOreBlock(1);
+ Logger.WORLD("[Vein Generator] An Ore in a Vein had defaulted back to a default value, so they have now been reset to correct values.");
+ }
+
+ if( mWorldGenName.equals("vein0") ) {
+ if (debugWorldGen) GT_Log.out.println(
+ " NoOresInVein-vein0"
+ );
+ // This is a special empty orevein
+ Logger.WORLD("[World Generation Debug] Special Empty Vein placed.");
+ return ORE_PLACED;
+ }
+ if (aDimensionType != Dimension_Everglades.DIMID) {
+ /* // Debug code, but spams log
+ if (debugWorldGen) {
+ GT_Log.out.println(
+ "Wrong dimension"
+ );
+ }
+ */
+ Logger.WORLD("[World Generation Debug] Wrong dimension.");
+ return WRONG_DIMENSION;
+ }
+ if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) {
+ return WRONG_BIOME;
+ }
+ int[] placeCount=new int[4];
+
+ int tMinY = mMinY + aRandom.nextInt(mMaxY - mMinY - 5);
+ // Determine West/East ends of orevein
+ int wXVein = aSeedX - aRandom.nextInt(mSize); // West side
+ int eXVein = aSeedX + 16 + aRandom.nextInt(mSize);
+ // Limit Orevein to only blocks present in current chunk
+ int wX = Math.max( wXVein, aChunkX + 2); // Bias placement by 2 blocks to prevent worldgen cascade.
+ int eX = Math.min( eXVein, aChunkX + 2 + 16);
+ if (wX >= eX) { //No overlap between orevein and this chunk exists in X
+ Block tBlock = aWorld.getBlock(aChunkX + 8, tMinY, aChunkZ + 8);
+ if (tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.stone) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Dimension_Everglades.blockSecondLayer) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Dimension_Everglades.blockMainFiller) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Dimension_Everglades.blockSecondaryFiller) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.netherrack) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.end_stone) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, GregTech_API.sBlockGranites) ||
+ (mUpdated && tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, mStoneTypes)) ) {
+ // Didn't reach, but could have placed. Save orevein for future use.
+ return NO_OVERLAP;
+ } else {
+ // Didn't reach, but couldn't place in test spot anywys, try for another orevein
+ return NO_OVERLAP_AIR_BLOCK;
+ }
+ }
+ // Determine North/Sound ends of orevein
+ int nZVein = aSeedZ - aRandom.nextInt(mSize);
+ int sZVein = aSeedZ + 16 + aRandom.nextInt(mSize);
+
+ int nZ = Math.max(nZVein, aChunkZ + 2); // Bias placement by 2 blocks to prevent worldgen cascade.
+ int sZ = Math.min(sZVein, aChunkZ + 2 + 16);
+ if (nZ >= sZ) { //No overlap between orevein and this chunk exists in Z
+ Block tBlock = aWorld.getBlock(aChunkX + 8, tMinY, aChunkZ + 8);
+ if (tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.stone) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.netherrack) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, Blocks.end_stone) ||
+ tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, GregTech_API.sBlockGranites) ||
+ (mUpdated && tBlock.isReplaceableOreGen(aWorld, aChunkX+8, tMinY, aChunkZ + 8, mStoneTypes)) ) {
+ // Didn't reach, but could have placed. Save orevein for future use.
+ return NO_OVERLAP;
+ } else {
+ // Didn't reach, but couldn't place in test spot anywys, try for another orevein
+ return NO_OVERLAP_AIR_BLOCK;
+ }
+
+ }
+
+ if (debugWorldGen) {
+ String tDimensionName = aWorld.provider.getDimensionName();
+ GT_Log.out.print(
+ "Trying Orevein:" + this.mWorldGenName +
+ " Dimension=" + tDimensionName +
+ " mX="+aChunkX/16+
+ " mZ="+aChunkZ/16+
+ " oreseedX="+ aSeedX/16 +
+ " oreseedZ="+ aSeedZ/16 +
+ " cY="+tMinY
+ );
+ }
+ // Adjust the density down the more chunks we are away from the oreseed. The 5 chunks surrounding the seed should always be max density due to truncation of Math.sqrt().
+ int localDensity = (Math.max(1, this.mDensity / ((int)Math.sqrt(2 + Math.pow(aChunkX/16 - aSeedX/16, 2) + Math.pow(aChunkZ/16 - aSeedZ/16, 2)))));
+
+ // To allow for early exit due to no ore placed in the bottom layer (probably because we are in the sky), unroll 1 pass through the loop
+ // Now we do bottom-level-first oregen, and work our way upwards.
+ int level = tMinY - 1; //Dunno why, but the first layer is actually played one below tMinY. Go figure.
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta != null) ) {
+ if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) {
+ placeCount[1]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
+ }
+ }
+ /*if ((placeCount[1]+placeCount[3])==0) {
+ if (debugWorldGen) GT_Log.out.println(
+ " No ore in bottom layer"
+ );
+ return NO_ORE_IN_BOTTOM_LAYER; // Exit early, didn't place anything in the bottom layer
+ }*/
+ Logger.WORLD("[World Generation Debug] Trying to set Ores?");
+ for (level = tMinY; level < (tMinY-1+3); level++) {
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSecondaryMeta != null) ) {
+ if (setOreBlock(aWorld, tX, level, tZ, this.mSecondaryMeta, false, false)) {
+ placeCount[1]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
+ }
+ }
+ }
+ // Low Middle layer is between + sporadic
+ // level should be = tMinY-1+3 from end of for loop
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta != null) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate
+ if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) {
+ placeCount[2]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
+ }
+ }
+ // High Middle layer is between + primary + sporadic
+ level++; // Increment level to next layer
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ((aRandom.nextInt(2) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mBetweenMeta != null) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate
+ if (setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) {
+ placeCount[2]++;
+ }
+ }
+ else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta != null) ) {
+ if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) {
+ placeCount[0]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
+ }
+ }
+ // Top two layers are primary + sporadic
+ level++; // Increment level to next layer
+ for( ; level < (tMinY + 6); level++){ // should do two layers
+ for (int tX = wX; tX < eX; tX++) {
+ int placeX = Math.max(1, Math.max(MathHelper.abs_int(wXVein - tX), MathHelper.abs_int(eXVein - tX))/localDensity);
+ for (int tZ = nZ; tZ < sZ; tZ++) {
+ int placeZ = Math.max(1, Math.max(MathHelper.abs_int(sZVein - tZ), MathHelper.abs_int(nZVein - tZ))/localDensity);
+ if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta != null) ) {
+ if (setOreBlock(aWorld, tX, level, tZ, this.mPrimaryMeta, false, false)) {
+ placeCount[0]++;
+ }
+ }
+ else if ((aRandom.nextInt(7) == 0) && ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mSporadicMeta != null) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate
+ if (setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false))
+ placeCount[3]++;
+ }
+ }
+ }
+ }
+ if (debugWorldGen) {
+ String tDimensionName = aWorld.provider.getDimensionName();
+ GT_Log.out.println(
+ "Generated Orevein:" + this.mWorldGenName +
+ " Dimension=" + tDimensionName +
+ " mX="+aChunkX/16+
+ " mZ="+aChunkZ/16+
+ " oreseedX="+ aSeedX/16 +
+ " oreseedZ="+ aSeedZ/16 +
+ " cY="+tMinY+
+ " wXVein" + wXVein +
+ " eXVein" + eXVein +
+ " nZVein" + nZVein +
+ " sZVein" + sZVein +
+ " locDen=" + localDensity +
+ " Den=" + this.mDensity +
+ " Sec="+placeCount[1]+
+ " Spo="+placeCount[3]+
+ " Bet="+placeCount[2]+
+ " Pri="+placeCount[0]
+ );
+ }
+ // Something (at least the bottom layer must have 1 block) must have been placed, return true
+ return ORE_PLACED;
+ }
+
+ private String fString = "unset", ore1String = "unset", ore2String = "unset", ore3String = "unset", ore4String = "unset";
+ Map<Materials, String> gtOreMap = new HashMap<Materials, String>();
+
+ @SuppressWarnings("deprecation")
+ public boolean setOreBlock(World aWorld, int aX, int aY, int aZ, Block aMetaData, boolean isSmallOre,
+ boolean air) {
+ if (!air) {
+ aY = Math.min(aWorld.getActualHeight(), Math.max(aY, 1));
+ }
+
+ //Set GT ORE
+ if (aMetaData instanceof GT_Block_Ores){
+ if (ore1String.equals("unset")) {
+ ore1String = Utils.sanitizeString(this.mPrimary.getLocalizedName().toLowerCase());
+ }
+ if (ore2String.equals("unset")) {
+ ore2String = Utils.sanitizeString(this.mSecondaryMeta.getLocalizedName().toLowerCase());
+ }
+ if (ore3String.equals("unset")) {
+ ore3String = Utils.sanitizeString(this.mBetweenMeta.getLocalizedName().toLowerCase());
+ }
+ if (ore4String.equals("unset")) {
+ ore4String = Utils.sanitizeString(this.mSporadicMeta.getLocalizedName().toLowerCase());
+ }
+
+ if (this.mPrimaryMeta == aMetaData){
+ for (Materials f : Materials.values()){
+ if (!gtOreMap.containsKey(f)) {
+ gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase()));
+ }
+ fString = gtOreMap.get(f);
+ if (fString.contains(ore1String)){
+ int r = f.mMetaItemSubID;
+ if (setOreBlock(aWorld, aX, aY, aZ, r, false)){
+ Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ);
+ return true;
+ }
+ }
+ }
+ }
+ if (this.mSecondaryMeta == aMetaData){
+ for (Materials f : Materials.values()){
+ if (!gtOreMap.containsKey(f)) {
+ gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase()));
+ }
+ fString = gtOreMap.get(f);
+ if (fString.contains(ore2String)){
+ int r = f.mMetaItemSubID;
+ if (setOreBlock(aWorld, aX, aY, aZ, r, false)){
+ Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ);
+ return true;
+ }
+ }
+ }
+ }
+ if (this.mBetweenMeta == aMetaData){
+ for (Materials f : Materials.values()){
+ if (!gtOreMap.containsKey(f)) {
+ gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase()));
+ }
+ fString = gtOreMap.get(f);
+ if (fString.contains(ore3String)){
+ int r = f.mMetaItemSubID;
+ if (setOreBlock(aWorld, aX, aY, aZ, r, false)){
+ Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ);
+ return true;
+ }
+ }
+ }
+ }
+ if (this.mSporadicMeta == aMetaData){
+ for (Materials f : Materials.values()){
+ if (!gtOreMap.containsKey(f)) {
+ gtOreMap.put(f, Utils.sanitizeString(f.name().toLowerCase()));
+ }
+ fString = gtOreMap.get(f);
+ if (fString.contains(ore4String)){
+ int r = f.mMetaItemSubID;
+ if (setOreBlock(aWorld, aX, aY, aZ, r, false)){
+ Logger.WORLD("[World Generation Debug] Set "+f.mDefaultLocalName+" Ore at X: "+aX+" | Y: "+aY+" | Z: "+aZ);
+ return true;
+ }
+ }
+ }
+ }
+
+ }
+
+ Block tBlock = aWorld.getBlock(aX, aY, aZ);
+ Block tOreBlock = aMetaData;
+ int BlockMeta = aWorld.getBlockMetadata(aX, aY, aZ);
+ String BlockName = tBlock.getUnlocalizedName();
+ if (
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone) ||
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sand) ||
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.dirt) ||
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, GregTech_API.sBlockGranites) ||
+ (mUpdated && tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, mStoneTypes)) ||
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockSecondLayer) ||
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockMainFiller) ||
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Dimension_Everglades.blockSecondaryFiller) ||
+ tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.sandstone)) {
+
+ if (aWorld.setBlock(aX, aY, aZ, tOreBlock, 0, 3)){
+ Logger.WORLD("[World Generation Debug] Set "+tOreBlock.getLocalizedName()+" at X: "+aX+" | Y: "+aY+" | Z: "+aZ);
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ private boolean setOreBlock(World aWorld, int aX, int aY, int aZ, int mMetaItemSubID, boolean useless){
+
+ //Get Class and Methods
+ Method setOres = null;
+ boolean is08 = !CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK;
+
+ //GT 5.08
+ if (is08){
+ try {
+ setOres = GT_TileEntity_Ores.class.getDeclaredMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class);
+ }
+ catch (NoSuchMethodException | SecurityException e) {
+
+ }
+ }
+ //GT 5.09
+ else {
+ try {
+ setOres = GT_TileEntity_Ores.class.getDeclaredMethod("setOreBlock", World.class, int.class, int.class, int.class, int.class, boolean.class);
+ }
+ catch (NoSuchMethodException | SecurityException e) {
+
+ }
+ }
+
+ try {
+ if (is08 && setOres != null){
+ setOres.invoke(null, aWorld, aX, aY, aZ, mMetaItemSubID);
+ }
+ else if (!is08 && setOres != null){
+ setOres.invoke(null, aWorld, aX, aY, aZ, mMetaItemSubID, useless);
+ }
+ else {
+ return false;
+ }}
+ catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+
+ }
+ return false;
+ }
+} \ No newline at end of file
diff --git a/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_Ores.java b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_Ores.java
new file mode 100644
index 0000000000..0715f86e01
--- /dev/null
+++ b/src/main/java/gtPlusPlus/everglades/gen/gt/WorldGen_Ores.java
@@ -0,0 +1,97 @@
+package gtPlusPlus.everglades.gen.gt;
+
+import java.util.Hashtable;
+
+import gtPlusPlus.core.material.ELEMENT;
+import gtPlusPlus.core.material.ORES;
+import gtPlusPlus.core.material.nuclear.FLUORIDES;
+
+public class WorldGen_Ores {
+
+ public static WorldGen_GT_Ore_Layer BaseVein = new WorldGen_GT_Ore_Layer("veinA", 20, 40, 1, 1, 128,
+ ELEMENT.getInstance().IRON, ELEMENT.getInstance().IRON, ELEMENT.getInstance().IRON,
+ ELEMENT.getInstance().IRON);
+
+ /**
+ * Custom ore Veins
+ */
+
+ public static WorldGen_GT_Ore_Layer Vein1 = new WorldGen_GT_Ore_Layer("vein1", 0, 60, 30, 2, 16, ORES.AGARDITE_CD,
+ ORES.AGARDITE_LA, ORES.DEMICHELEITE_BR, ORES.IRARSITE);
+
+ public static WorldGen_GT_Ore_Layer Vein2 = new WorldGen_GT_Ore_Layer("vein2", 0, 60, 30, 2, 16, ORES.AGARDITE_ND,
+ ORES.AGARDITE_Y, ORES.KASHINITE, ORES.CERITE);
+
+ public static WorldGen_GT_Ore_Layer Vein3 = new WorldGen_GT_Ore_Layer("vein3", 0, 60, 30, 3, 32, ORES.CERITE,
+ ORES.NICHROMITE, ORES.XENOTIME, ORES.HIBONITE);
+
+ public static WorldGen_GT_Ore_Layer Vein4 = new WorldGen_GT_Ore_Layer("vein4", 0, 60, 40, 3, 32, ORES.GEIKIELITE,
+ ORES.CRYOLITE, ORES.GADOLINITE_CE, ORES.AGARDITE_ND);
+
+ public static WorldGen_GT_Ore_Layer Vein5 = new WorldGen_GT_Ore_Layer("vein5", 30, 128, 20, 2, 48, ORES.HIBONITE,
+ ORES.YTTRIALITE, ORES.ZIRCONILITE, ORES.CERITE);
+ public static WorldGen_GT_Ore_Layer Vein6 = new WorldGen_GT_Ore_Layer("vein6", 0, 40, 20, 2, 48, ORES.XENOTIME,
+ ORES.ZIRKELITE, ORES.CROCROITE, ORES.IRARSITE);
+ public static WorldGen_GT_Ore_Layer Vein7 = new WorldGen_GT_Ore_Layer("vein7", 40, 128, 20, 2, 48, ORES.HONEAITE,
+ ORES.MIESSIITE, ORES.SAMARSKITE_Y, ORES.SAMARSKITE_YB);
+ public static WorldGen_GT_Ore_Layer Vein8 = new WorldGen_GT_Ore_Layer("vein8", 0, 40, 20, 2, 48, ORES.TITANITE,
+ ORES.ZIMBABWEITE, ORES.ZIRCON, ORES.FLORENCITE);
+
+ public static WorldGen_GT_Ore_Layer Vein9 = new WorldGen_GT_Ore_Layer("vein9", 10, 30, 20, 1, 48,
+ ORES.LANTHANITE_CE, FLUORIDES.FLUORITE, ORES.LAFOSSAITE, ORES.FLORENCITE);
+ public static WorldGen_GT_Ore_Layer Vein10 = new WorldGen_GT_Ore_Layer("vein10", 20, 50, 20, 2, 32, ORES.GEIKIELITE,
+ ORES.YTTROCERITE, ORES.LANTHANITE_LA, ORES.RADIOBARITE);
+ public static WorldGen_GT_Ore_Layer Vein11 = new WorldGen_GT_Ore_Layer("vein11", 30, 70, 20, 1, 48,
+ FLUORIDES.FLUORITE, ORES.KASHINITE, ORES.ZIRCON, ORES.CRYOLITE);
+ public static WorldGen_GT_Ore_Layer Vein12 = new WorldGen_GT_Ore_Layer("vein12", 40, 80, 20, 3, 32, ORES.CERITE,
+ ORES.ALBURNITE, ORES.MIESSIITE, ORES.HIBONITE);
+
+ /**
+ * Best Rarest Veins 2017
+ */
+
+ public static WorldGen_GT_Ore_Layer Vein13 = new WorldGen_GT_Ore_Layer("vein13", 5, 15, 5, 1, 16, ORES.CRYOLITE,
+ ORES.RADIOBARITE, ORES.HONEAITE, ORES.FLORENCITE);
+
+ public static WorldGen_GT_Ore_Layer Vein14 = new WorldGen_GT_Ore_Layer("vein14", 10, 20, 8, 2, 16,
+ ORES.DEMICHELEITE_BR, ORES.PERROUDITE, ORES.IRARSITE, ORES.RADIOBARITE);
+
+ public static WorldGen_GT_Ore_Layer Vein15 = new WorldGen_GT_Ore_Layer("vein15", 5, 25, 5, 3, 24, ORES.FLUORCAPHITE,
+ ORES.LAFOSSAITE, ORES.GADOLINITE_CE, ORES.GADOLINITE_Y);
+
+ public static WorldGen_GT_Ore_Layer Vein16 = new WorldGen_GT_Ore_Layer("vein16", 0, 25, 4, 2, 32, ORES.YTTROCERITE,
+ ORES.LEPERSONNITE, ORES.LAUTARITE, FLUORIDES.FLUORITE);
+
+ public static WorldGen_GT_Ore_Layer Vein17 = new WorldGen_GT_Ore_Layer("vein17", 10, 35, 4, 1, 32, ORES.FLORENCITE,
+ ORES.LAUTARITE, ORES.SAMARSKITE_YB, ORES.POLYCRASE);
+ public static WorldGen_GT_Ore_Layer Vein18 = new WorldGen_GT_Ore_Layer("vein18", 15, 40, 4, 1, 48,
+ ORES.GADOLINITE_CE, ORES.GADOLINITE_Y, ORES.AGARDITE_LA, ORES.AGARDITE_CD);
+
+ public static Hashtable<Long, WorldGen_GT_Ore_Layer> validOreveins = new Hashtable<Long, WorldGen_GT_Ore_Layer>(
+ 1024);
+
+ static long ID = 0;
+
+ public static void generateValidOreVeins() {
+ validOreveins.put(ID++, BaseVein);
+ validOreveins.put(ID++, Vein1);
+ validOreveins.put(ID++, Vein2);
+ validOreveins.put(ID++, Vein3);
+ validOreveins.put(ID++, Vein4);
+ validOreveins.put(ID++, Vein5);
+ validOreveins.put(ID++, Vein6);
+ validOreveins.put(ID++, Vein7);
+ validOreveins.put(ID++, Vein8);
+ validOreveins.put(ID++, Vein9);
+ validOreveins.put(ID++, Vein10);
+ validOreveins.put(ID++, Vein11);
+ validOreveins.put(ID++, Vein12);
+ validOreveins.put(ID++, Vein13);
+ validOreveins.put(ID++, Vein14);
+ validOreveins.put(ID++, Vein15);
+ validOreveins.put(ID++, Vein16);
+ validOreveins.put(ID++, Vein17);
+ validOreveins.put(ID++, Vein18);
+ }
+
+}