From 65a7b7764ea5a5f67afc19d19070aa8e9cbbd7e6 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Mon, 2 Oct 2017 20:24:24 -0500 Subject: Rebase to latest experimental head --- .../gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 6 +++- .../common/GT_Worldgen_GT_Ore_SmallPieces.java | 3 +- .../java/gregtech/common/GT_Worldgenerator.java | 41 +++++++++++++++++----- 3 files changed, 40 insertions(+), 10 deletions(-) (limited to 'src/main/java/gregtech/common') 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..5fcfffad8b 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 @@ -140,6 +140,10 @@ public class GT_Worldgen_GT_Ore_Layer " Sporadic="+execCount[3]+","+placeCount[3]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSporadicMeta).getDisplayName() ); } - 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..d69cf5c9c7 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -15,6 +15,9 @@ 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 java.util.ArrayList; import java.util.List; @@ -49,7 +52,7 @@ 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" ); @@ -60,14 +63,14 @@ public class GT_Worldgenerator 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());} + if (debugWorldGen) {GT_Log.out.println("ADD WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size());} } 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());} + if (debugWorldGen) {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); @@ -110,10 +113,12 @@ public class GT_Worldgenerator public void run() { 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 < 256) && (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; @@ -131,13 +136,33 @@ public class GT_Worldgenerator } if (D1 & temp) { GT_Log.out.println( - "No Orevein Selected!" + + "No orevein selected!" + " @ dim="+ this.mDimensionType+ " chunkX="+ this.mX + " chunkZ="+ this.mZ ); - } + } else if (D1) + { + GT_Log.out.println( + "Orevein took " + i + " attempts to find" + ); + } + + }else + { + if((oreveinRNG >= oreveinPercentage) && (D1)) + { + GT_Log.out.println( + "Skipped orevein in this 3x3 chunk!" + + " @ dim="+ this.mDimensionType+ + " chunkX="+ this.mX + + " chunkZ="+ this.mZ + + " RNG=" + oreveinRNG + + " %=" + oreveinPercentage + ); + } } + int i = 0; for (int tX = this.mX - 16; i < 3; tX += 16) { int j = 0; @@ -162,7 +187,7 @@ public class GT_Worldgenerator { if (D1) { GT_Log.out.println( - "Chunk Skipped, not 3x3 center" + + "Skipped chunk, not 3x3 center" + " @ dim="+this.mDimensionType+ " chunkX="+this.mX+ " chunkZ="+this.mZ -- cgit From f2acf6b6f2ea7ed7158857b0a86d8380488fccf8 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Sat, 16 Sep 2017 12:31:38 -0500 Subject: Removed execCount, focus only on blocks actually placed. --- src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/main/java/gregtech/common') 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 5fcfffad8b..17f35c2e54 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 @@ -92,7 +92,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,7 +102,6 @@ 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]++; } } } @@ -117,14 +115,12 @@ 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.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]++; } } } @@ -134,10 +130,11 @@ public class GT_Worldgen_GT_Ore_Layer " @ 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+ + " 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() ); } // Didn't place anything, return false -- cgit From 8c867332c01b823293006ea5fa9f91fe79d55008 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Sat, 16 Sep 2017 13:15:51 -0500 Subject: Missed a execCount. Modified output to print dimension name instead of dimension number, since TF and others reuse dim 0. --- .../java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 2 -- src/main/java/gregtech/common/GT_Worldgenerator.java | 15 +++++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/main/java/gregtech/common') 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 17f35c2e54..8008510b2b 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 @@ -108,7 +108,6 @@ public class GT_Worldgen_GT_Ore_Layer 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++) { @@ -127,7 +126,6 @@ public class GT_Worldgen_GT_Ore_Layer if (D1) { GT_Log.out.println( "Generated Orevein:" + this.mWorldGenName + - " @ dim="+aDimensionType+ " chunkX="+aChunkX+ " chunkZ="+aChunkZ+ " chunkY="+tMinY+ diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index d69cf5c9c7..a99da09916 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -112,10 +112,12 @@ public class GT_Worldgenerator } public void run() { + String tDimensionName = this.mWorld.provider.getDimensionName(); if ((Math.abs(this.mX / 16) % 3 == 1) && (Math.abs(this.mZ / 16) % 3 == 1)) { 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; int i; for (i = 0; (i < 256) && (temp); i++) { @@ -139,12 +141,15 @@ public class GT_Worldgenerator "No orevein selected!" + " @ dim="+ this.mDimensionType+ " chunkX="+ this.mX + - " chunkZ="+ this.mZ + " chunkZ="+ this.mZ + + " dimensionName=" + tDimensionName ); } else if (D1) { GT_Log.out.println( - "Orevein took " + i + " attempts to find" + "Orevein took " + i + + " attempts to find" + + " dimensionName=" + tDimensionName ); } @@ -158,7 +163,8 @@ public class GT_Worldgenerator " chunkX="+ this.mX + " chunkZ="+ this.mZ + " RNG=" + oreveinRNG + - " %=" + oreveinPercentage + " %=" + oreveinPercentage+ + " dimensionName=" + tDimensionName ); } } @@ -190,7 +196,8 @@ public class GT_Worldgenerator "Skipped chunk, not 3x3 center" + " @ dim="+this.mDimensionType+ " chunkX="+this.mX+ - " chunkZ="+this.mZ + " chunkZ="+this.mZ+ + " dimensionName=" + tDimensionName ); } } -- cgit From 94b24d92e0b533e0631c70748c32a0b5719bfb68 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Mon, 2 Oct 2017 20:04:20 -0500 Subject: Add variable to configure number of attempts before giving up, default to 64. Set default orevein fill rate to 75% --- src/main/java/gregtech/GT_Mod.java | 4 +++- src/main/java/gregtech/api/enums/GT_Values.java | 20 ++++++++++++++------ .../gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 8 +++++--- src/main/java/gregtech/common/GT_Worldgenerator.java | 17 +++++++++-------- 4 files changed, 31 insertions(+), 18 deletions(-) (limited to 'src/main/java/gregtech/common') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 39bd959262..8889179326 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -190,7 +190,9 @@ public class GT_Mod implements IGT_Mod { 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.oreveinPercentage = tMainConfig.get(aTextGeneral, "oreveinPercentage_100",100).getInt(100); + 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 8f98e2ceef..71e22bb1d7 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -117,24 +117,32 @@ public class GT_Values { * For Internal Usage (Network) */ public static IGT_NetworkHandler NW; - /** + /** + * 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; - /** - * Control percentage of filled 3x3 chunks. Lower number means less oreveins spawn - */ - public static int oreveinPercentage; } \ 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 8008510b2b..7c89ea443f 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,7 @@ 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; public class GT_Worldgen_GT_Ore_Layer extends GT_Worldgen { @@ -123,7 +123,8 @@ public class GT_Worldgen_GT_Ore_Layer } } } - if (D1) { + if (debugOrevein) { + String tDimensionName = aWorld.provider.getDimensionName(); GT_Log.out.println( "Generated Orevein:" + this.mWorldGenName + " chunkX="+aChunkX+ @@ -132,7 +133,8 @@ public class GT_Worldgen_GT_Ore_Layer " 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() + " Sporadic="+placeCount[3]+" "+new ItemStack(GregTech_API.sBlockOres1,1,mSporadicMeta).getDisplayName() + + " Dimension=" + tDimensionName ); } // Didn't place anything, return false diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index a99da09916..47990cae64 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -18,6 +18,8 @@ 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; @@ -120,7 +122,7 @@ public class GT_Worldgenerator int tRandomWeight; int i; - for (i = 0; (i < 256) && (temp); 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; @@ -136,15 +138,15 @@ public class GT_Worldgenerator } } } - if (D1 & temp) { + if (debugOrevein & temp) { GT_Log.out.println( "No orevein selected!" + - " @ dim="+ this.mDimensionType+ " chunkX="+ this.mX + " chunkZ="+ this.mZ + + " oreveinAttemps=" + oreveinAttempts + " dimensionName=" + tDimensionName ); - } else if (D1) + } else if (debugOrevein) { GT_Log.out.println( "Orevein took " + i + @@ -155,11 +157,10 @@ public class GT_Worldgenerator }else { - if((oreveinRNG >= oreveinPercentage) && (D1)) + if((oreveinRNG >= oreveinPercentage) && (debugOrevein)) { GT_Log.out.println( "Skipped orevein in this 3x3 chunk!" + - " @ dim="+ this.mDimensionType+ " chunkX="+ this.mX + " chunkZ="+ this.mZ + " RNG=" + oreveinRNG + @@ -191,7 +192,7 @@ public class GT_Worldgenerator } else { - if (D1) { + if (debugOrevein) { GT_Log.out.println( "Skipped chunk, not 3x3 center" + " @ dim="+this.mDimensionType+ @@ -214,7 +215,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; -- cgit From 29d2846c40e9f69374f2b0c2701c11073ec7e287 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Tue, 17 Oct 2017 02:23:08 -0500 Subject: Preserve debug messages and bugfix for deep dark doing multiple worldgens on a single chunk. --- .../gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 12 +++++++++- .../java/gregtech/common/GT_Worldgenerator.java | 26 ++++++++++++++++++---- 2 files changed, 33 insertions(+), 5 deletions(-) (limited to 'src/main/java/gregtech/common') 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 7c89ea443f..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 @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.Random; 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))); @@ -130,6 +139,7 @@ public class GT_Worldgen_GT_Ore_Layer " chunkX="+aChunkX+ " chunkZ="+aChunkZ+ " 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()+ diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index 47990cae64..8ccce145ed 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -24,6 +24,7 @@ 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; @@ -39,6 +40,7 @@ public class GT_Worldgenerator //private static int gcMaxSize = 400; private static boolean endAsteroids = true; public List mList = new ArrayList(); + public HashSet ProcChunks = new HashSet(); public boolean mIsGenerating = false; public static final Object listLock = new Object(); //private static boolean gcAsteroids = true; @@ -64,15 +66,21 @@ public class GT_Worldgenerator 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 (debugWorldGen) {GT_Log.out.println("ADD WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size());} + if (!this.ProcChunks.contains( ((long)aX << 32) | ((long)(aZ) & 0x00000000ffffffffL)) ) { + this.ProcChunks.add( ((long)aX << 32) | ((long)(aZ) & 0x00000000ffffffffL)); + 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 (debugWorldGen) {GT_Log.out.println("ADD WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size());} + } else { + if (debugWorldGen) {GT_Log.out.println("DUP WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size() + " ProcChunks.size(): " + ProcChunks.size() ); } + } } 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 (debugWorldGen) {GT_Log.out.println("RUN WorldGen chunk x:" + toRun.mX/16 + " z:" + toRun.mZ/16 + " SIZE: " + this.mList.size());} + if (debugWorldGen) {GT_Log.out.println("RUN WorldGen chunk x:" + toRun.mX/16 + " z:" + toRun.mZ/16 + " SIZE: " + this.mList.size() + " i: " + i );} + this.ProcChunks.remove( ((long)(toRun.mX/16) << 32) | ((long)(toRun.mZ/16) & 0x00000000ffffffffL)); synchronized (listLock) { this.mList.remove(0); @@ -114,7 +122,9 @@ public class GT_Worldgenerator } public void run() { - String tDimensionName = this.mWorld.provider.getDimensionName(); + 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)) { int oreveinRNG = this.mRandom.nextInt(100); if (( oreveinRNG < oreveinPercentage) && (GT_Worldgen_GT_Ore_Layer.sWeight > 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) { @@ -313,6 +323,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" + ); + } } } } -- cgit From df14479aacd21fd5c8029be15082ea19d3c18c9c Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Tue, 17 Oct 2017 03:03:25 -0500 Subject: Revert threadsafe code back to lossy code. Chunks will get skipped with this, but at least the worldgen won't lag. --- .../java/gregtech/common/GT_Worldgenerator.java | 29 ++++++++-------------- 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'src/main/java/gregtech/common') diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index 8ccce145ed..f42bc4ef1b 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -63,34 +63,27 @@ public class GT_Worldgenerator } } + public void generate(Random aRandom, int aX, int aZ, World aWorld, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - synchronized (listLock) - { - if (!this.ProcChunks.contains( ((long)aX << 32) | ((long)(aZ) & 0x00000000ffffffffL)) ) { - this.ProcChunks.add( ((long)aX << 32) | ((long)(aZ) & 0x00000000ffffffffL)); - 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 (debugWorldGen) {GT_Log.out.println("ADD WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size());} - } else { - if (debugWorldGen) {GT_Log.out.println("DUP WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size() + " ProcChunks.size(): " + ProcChunks.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 (debugWorldGen) {GT_Log.out.println("RUN WorldGen chunk x:" + toRun.mX/16 + " z:" + toRun.mZ/16 + " SIZE: " + this.mList.size() + " i: " + i );} - this.ProcChunks.remove( ((long)(toRun.mX/16) << 32) | ((long)(toRun.mZ/16) & 0x00000000ffffffffL)); - 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")) { -- cgit