aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2017-10-17 19:01:41 +0200
committerGitHub <noreply@github.com>2017-10-17 19:01:41 +0200
commit267614fb520e61efdd75d33d9532ba1c17b0c8de (patch)
treeb7713b30ac9ca6e04bec465c69d00a9968ad1ead /src/main
parent3b78b258d2e117d5af44fe01a16fc1dd5e6fe565 (diff)
parentdf14479aacd21fd5c8029be15082ea19d3c18c9c (diff)
downloadGT5-Unofficial-267614fb520e61efdd75d33d9532ba1c17b0c8de.tar.gz
GT5-Unofficial-267614fb520e61efdd75d33d9532ba1c17b0c8de.tar.bz2
GT5-Unofficial-267614fb520e61efdd75d33d9532ba1c17b0c8de.zip
Merge pull request #39 from richardhendricks/debug/dd_broken_debug
Debug/dd broken debug
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/GT_Mod.java4
-rw-r--r--src/main/java/gregtech/api/enums/GT_Values.java28
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java39
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java3
-rw-r--r--src/main/java/gregtech/common/GT_Worldgenerator.java92
5 files changed, 121 insertions, 45 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java
index 90b7e74fb5..8889179326 100644
--- a/src/main/java/gregtech/GT_Mod.java
+++ b/src/main/java/gregtech/GT_Mod.java
@@ -189,6 +189,10 @@ public class GT_Mod implements IGT_Mod {
GT_Values.D1 = tMainConfig.get(aTextGeneral, "Debug", false).getBoolean(false);
GT_Values.D2 = tMainConfig.get(aTextGeneral, "Debug2", false).getBoolean(false);
GT_Values.debugCleanroom = tMainConfig.get(aTextGeneral, "debugCleanroom", false).getBoolean(false);
+ GT_Values.debugWorldGen = tMainConfig.get(aTextGeneral, "debugWorldGen", false).getBoolean(false);
+ GT_Values.debugOrevein = tMainConfig.get(aTextGeneral, "debugOrevein", false).getBoolean(false);
+ GT_Values.oreveinPercentage = tMainConfig.get(aTextGeneral, "oreveinPercentage_75",75).getInt(75);
+ GT_Values.oreveinAttempts = tMainConfig.get(aTextGeneral, "oreveinAttempts_64",64).getInt(64);
GregTech_API.TICKS_FOR_LAG_AVERAGING = tMainConfig.get(aTextGeneral, "TicksForLagAveragingWithScanner", 25).getInt(25);
GregTech_API.MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING = tMainConfig.get(aTextGeneral, "MillisecondsPassedInGTTileEntityUntilLagWarning", 100).getInt(100);
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java
index 27341027f7..71e22bb1d7 100644
--- a/src/main/java/gregtech/api/enums/GT_Values.java
+++ b/src/main/java/gregtech/api/enums/GT_Values.java
@@ -117,16 +117,32 @@ public class GT_Values {
* For Internal Usage (Network)
*/
public static IGT_NetworkHandler NW;
- /**
- * Debug parameter for cleanroom testing.
- */
- public static boolean debugCleanroom = false;
- /**
+ /**
+ * 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. Lower numbers is slightly faster chunkgen, but more empty chunks with thin stone height.
+ */
+ public static int oreveinAttempts;
+ /**
* Not really Constants, but they set using the Config and therefore should be constant (those are for the Debug Mode)
*/
public static boolean D1 = false, D2 = false;
+ /**
+ * Debug parameter for cleanroom testing.
+ */
+ public static boolean debugCleanroom = false;
+ /**
+ * Debug parameter for world generation. Tracks chunks added/removed from run queue.
+ */
+ public static boolean debugWorldGen = false;
+ /**
+ * Debug parameter for orevein generation.
+ */
+ public static boolean debugOrevein = false;
/**
* If you have to give something a World Parameter but there is no World... (Dummy World)
*/
public static World DW;
-}
+} \ No newline at end of file
diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
index 0cf8a65898..dcc256498b 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java
@@ -15,7 +15,8 @@ import net.minecraft.world.chunk.IChunkProvider;
import java.util.ArrayList;
import java.util.Random;
-import static gregtech.api.enums.GT_Values.D1;
+import static gregtech.api.enums.GT_Values.debugOrevein;
+import static gregtech.api.enums.GT_Values.debugWorldGen;
public class GT_Worldgen_GT_Ore_Layer
extends GT_Worldgen {
@@ -51,7 +52,15 @@ public class GT_Worldgen_GT_Ore_Layer
//this.mMars = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Mars", aMars);
//this.mAsteroid = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid);
this.mMinY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY));
- this.mMaxY = ((short) Math.max(this.mMinY + 5, GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY)));
+ short mMaxY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MaxHeight", aMaxY));
+ 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) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "RandomWeight", aWeight));
this.mDensity = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Density", aDensity));
this.mSize = ((short) Math.max(1, GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Size", aSize)));
@@ -92,7 +101,6 @@ public class GT_Worldgen_GT_Ore_Layer
int cX = aChunkX - aRandom.nextInt(this.mSize);
int eX = aChunkX + 16 + aRandom.nextInt(this.mSize);
- int[] execCount=new int[4];
int[] placeCount=new int[4];
for (int tX = cX; tX <= eX; tX++) {
int cZ = aChunkZ - aRandom.nextInt(this.mSize);
@@ -103,43 +111,46 @@ public class GT_Worldgen_GT_Ore_Layer
if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) {
if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, i, tZ, this.mSecondaryMeta, false))
placeCount[1]++;
- execCount[1]++;
}
}
}
if ((this.mBetweenMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) {
if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, tMinY + 2 + aRandom.nextInt(2), tZ, this.mBetweenMeta, false))
placeCount[2]++;
- execCount[2]++;
}
if (this.mPrimaryMeta > 0) {
for (int i = tMinY + 3; i < tMinY + 6; i++) {
if ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0)) {
if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, i, tZ, this.mPrimaryMeta, false))
placeCount[0]++;
- execCount[0]++;
}
}
}
if ((this.mSporadicMeta > 0) && ((aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cZ - tZ), MathHelper.abs_int(eZ - tZ)) / this.mDensity)) == 0) || (aRandom.nextInt(Math.max(1, Math.max(MathHelper.abs_int(cX - tX), MathHelper.abs_int(eX - tX)) / this.mDensity)) == 0))) {
if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, tMinY - 1 + aRandom.nextInt(7), tZ, this.mSporadicMeta, false))
placeCount[3]++;
- execCount[3]++;
}
}
}
- if (D1) {
+ if (debugOrevein) {
+ String tDimensionName = aWorld.provider.getDimensionName();
GT_Log.out.println(
"Generated Orevein:" + this.mWorldGenName +
- " @ dim="+aDimensionType+
" chunkX="+aChunkX+
" chunkZ="+aChunkZ+
- " Secondary="+execCount[1]+","+placeCount[1]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSecondaryMeta).getDisplayName()+
- " Between="+execCount[2]+","+placeCount[2]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mBetweenMeta).getDisplayName()+
- " Primary="+execCount[0]+","+placeCount[0]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mPrimaryMeta).getDisplayName()+
- " Sporadic="+execCount[3]+","+placeCount[3]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSporadicMeta).getDisplayName()
+ " chunkY="+tMinY+
+ " Density=" + this.mDensity +
+ " Secondary="+placeCount[1]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSecondaryMeta).getDisplayName()+
+ " Between="+placeCount[2]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mBetweenMeta).getDisplayName()+
+ " Primary="+placeCount[0]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mPrimaryMeta).getDisplayName()+
+ " Sporadic="+placeCount[3]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSporadicMeta).getDisplayName() +
+ " Dimension=" + tDimensionName
);
}
- return true;
+ // Didn't place anything, return false
+ if( (placeCount[0] + placeCount[1] + placeCount[2] + placeCount[3]) == 0 )
+ return false;
+ else
+ return true;
}
}
diff --git a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
index 6a8cd49b6f..e0a729104e 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_GT_Ore_SmallPieces.java
@@ -12,6 +12,7 @@ import net.minecraft.world.chunk.IChunkProvider;
import java.util.Random;
import static gregtech.api.enums.GT_Values.D1;
+import static gregtech.api.enums.GT_Values.D2;
public class GT_Worldgen_GT_Ore_SmallPieces
extends GT_Worldgen {
@@ -53,7 +54,7 @@ public class GT_Worldgen_GT_Ore_SmallPieces
count++;
}
}
- if(D1){
+ if(D2){
GT_Log.out.println(
"Small Ore:" + this.mWorldGenName +
" @ dim="+aDimensionType+
diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java
index 9d68b13f40..f42bc4ef1b 100644
--- a/src/main/java/gregtech/common/GT_Worldgenerator.java
+++ b/src/main/java/gregtech/common/GT_Worldgenerator.java
@@ -15,10 +15,16 @@ import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderEnd;
import net.minecraft.world.gen.ChunkProviderHell;
+import static gregtech.api.enums.GT_Values.D1;
+import static gregtech.api.enums.GT_Values.oreveinPercentage;
+import static gregtech.api.enums.GT_Values.debugWorldGen;
+import static gregtech.api.enums.GT_Values.debugOrevein;
+import static gregtech.api.enums.GT_Values.oreveinAttempts;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
+import java.util.HashSet;
import static gregtech.api.enums.GT_Values.D1;
@@ -34,6 +40,7 @@ public class GT_Worldgenerator
//private static int gcMaxSize = 400;
private static boolean endAsteroids = true;
public List<Runnable> mList = new ArrayList();
+ public HashSet<Long> ProcChunks = new HashSet<Long>();
public boolean mIsGenerating = false;
public static final Object listLock = new Object();
//private static boolean gcAsteroids = true;
@@ -49,35 +56,34 @@ public class GT_Worldgenerator
//gcMaxSize = GregTech_API.sWorldgenFile.get("gcasteroids", "GCAsteroidMaxSize", 400);
//mGCAsteroidProbability = GregTech_API.sWorldgenFile.get("gcasteroids", "GCAsteroidProbability", 300);
GameRegistry.registerWorldGenerator(this, 1073741823);
- if (D1) {
+ if (debugWorldGen) {
GT_Log.out.println(
"GT_Worldgenerator created"
);
}
}
+
public void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
- synchronized (listLock)
- {
- this.mList.add(new WorldGenContainer(new XSTR(aRandom.nextInt()), aX * 16, aZ * 16, ((aChunkGenerator instanceof ChunkProviderEnd)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.sky) ? 1 : ((aChunkGenerator instanceof ChunkProviderHell)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.hell) ? -1 : 0, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName));
- if (D1) {GT_Log.out.println("ADD WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size());}
- }
+ this.mList.add(new WorldGenContainer(new XSTR(aRandom.nextInt()), aX * 16, aZ * 16, ((aChunkGenerator instanceof ChunkProviderEnd)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.sky) ? 1 : ((aChunkGenerator instanceof ChunkProviderHell)) || (aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8) == BiomeGenBase.hell) ? -1 : 0, aWorld, aChunkGenerator, aChunkProvider, aWorld.getBiomeGenForCoords(aX * 16 + 8, aZ * 16 + 8).biomeName));
if (!this.mIsGenerating) {
this.mIsGenerating = true;
int mList_sS=this.mList.size();
for (int i = 0; i < mList_sS; i++) {
- WorldGenContainer toRun = (WorldGenContainer) this.mList.get(0);
- if (D1) {GT_Log.out.println("RUN WorldGen chunk x:" + toRun.mX/16 + " z:" + toRun.mZ/16 + " SIZE: " + this.mList.size());}
- synchronized (listLock)
- {
- this.mList.remove(0);
- }
- toRun.run();
+ ((Runnable) this.mList.get(i)).run();
}
+ if (debugWorldGen) {
+ GT_Log.out.println(
+ "Tossing " + (this.mList.size() - mList_sS) +
+ " chunks!"
+ );
+ }
+ this.mList.clear();
this.mIsGenerating = false;
}
}
+
//public synchronized void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {//TODO CHECK???
// int tempDimensionId = aWorld.provider.dimensionId;
// if (tempDimensionId != -1 && tempDimensionId != 1 && !aChunkGenerator.getClass().getName().contains("galacticraft")) {
@@ -109,11 +115,17 @@ public class GT_Worldgenerator
}
public void run() {
+ String tDimensionName = "";
+ if (debugOrevein) { tDimensionName = this.mWorld.provider.getDimensionName(); }
+ long startTime = System.nanoTime();
if ((Math.abs(this.mX / 16) % 3 == 1) && (Math.abs(this.mZ / 16) % 3 == 1)) {
- if ((GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) {
+ int oreveinRNG = this.mRandom.nextInt(100);
+ if (( oreveinRNG < oreveinPercentage) && (GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) {
boolean temp = true;
+
int tRandomWeight;
- for (int i = 0; (i < 256) && (temp); i++) {
+ int i;
+ for (i = 0; (i < oreveinAttempts) && (temp); i++) {
tRandomWeight = this.mRandom.nextInt(GT_Worldgen_GT_Ore_Layer.sWeight);
for (GT_Worldgen tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) {
tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer) tWorldGen).mWeight;
@@ -129,15 +141,38 @@ public class GT_Worldgenerator
}
}
}
- if (D1 & temp) {
+ if (debugOrevein & temp) {
GT_Log.out.println(
- "No Orevein Selected!" +
- " @ dim="+ this.mDimensionType+
+ "No orevein selected!" +
" chunkX="+ this.mX +
- " chunkZ="+ this.mZ
+ " chunkZ="+ this.mZ +
+ " oreveinAttemps=" + oreveinAttempts +
+ " dimensionName=" + tDimensionName
);
- }
+ } else if (debugOrevein)
+ {
+ GT_Log.out.println(
+ "Orevein took " + i +
+ " attempts to find" +
+ " dimensionName=" + tDimensionName
+ );
+ }
+
+ }else
+ {
+ if((oreveinRNG >= oreveinPercentage) && (debugOrevein))
+ {
+ GT_Log.out.println(
+ "Skipped orevein in this 3x3 chunk!" +
+ " chunkX="+ this.mX +
+ " chunkZ="+ this.mZ +
+ " RNG=" + oreveinRNG +
+ " %=" + oreveinPercentage+
+ " dimensionName=" + tDimensionName
+ );
+ }
}
+
int i = 0;
for (int tX = this.mX - 16; i < 3; tX += 16) {
int j = 0;
@@ -160,12 +195,13 @@ public class GT_Worldgenerator
}
else
{
- if (D1) {
+ if (debugOrevein) {
GT_Log.out.println(
- "Chunk Skipped, not 3x3 center" +
+ "Skipped chunk, not 3x3 center" +
" @ dim="+this.mDimensionType+
" chunkX="+this.mX+
- " chunkZ="+this.mZ
+ " chunkZ="+this.mZ+
+ " dimensionName=" + tDimensionName
);
}
}
@@ -182,7 +218,7 @@ public class GT_Worldgenerator
if ((GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) {
boolean temp = true;
int tRandomWeight;
- for (int i = 0; (i < 256) && (temp); i++) {
+ for (int i = 0; (i < oreveinAttempts) && (temp); i++) {
tRandomWeight = aRandom.nextInt(GT_Worldgen_GT_Ore_Layer.sWeight);
for (GT_Worldgen_GT_Ore_Layer tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) {
tRandomWeight -= ((GT_Worldgen_GT_Ore_Layer) tWorldGen).mWeight;
@@ -280,6 +316,14 @@ public class GT_Worldgenerator
if (tChunk != null) {
tChunk.isModified = true;
}
+ long endTime = System.nanoTime();
+ long duration = (endTime - startTime);
+ if (debugWorldGen) {
+ GT_Log.out.println(
+ "Oregen took " + duration +
+ " nanoseconds"
+ );
+ }
}
}
}