diff options
author | Richard Hendricks <richardhendricks@pobox.com> | 2017-11-20 18:41:20 -0600 |
---|---|---|
committer | Richard Hendricks <richardhendricks@pobox.com> | 2017-11-24 00:50:30 -0600 |
commit | 11ffc12143d6faa3ff8b877c30c6545431243d76 (patch) | |
tree | 2c4a88d523afb3e97723fd0b3f82a8fdd71caaa5 /src/main/java/gregtech | |
parent | 9c7e89d7946ba83b0c9b60587afeb9c325bf3a24 (diff) | |
download | GT5-Unofficial-11ffc12143d6faa3ff8b877c30c6545431243d76.tar.gz GT5-Unofficial-11ffc12143d6faa3ff8b877c30c6545431243d76.tar.bz2 GT5-Unofficial-11ffc12143d6faa3ff8b877c30c6545431243d76.zip |
Removed oreveinSize to use a hardcoded value for now, until we can do per-dimension setup. Other minor fixes
Diffstat (limited to 'src/main/java/gregtech')
4 files changed, 29 insertions, 100 deletions
diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index b2408affe5..94d268fd58 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -131,8 +131,9 @@ public class GT_Values { public static int oreveinMaxPlacementAttempts; /** * How wide to look for oreveins that affect a requested chunk. Trying to use oreveins larger than this will not work correctly. Increasing the size will cause additional worldgenerator lag. + * Disabled for now, using 64 in Deep Dark, 32 elsewhere */ - public static int oreveinMaxSize; + // public static int oreveinMaxSize; /** * Not really Constants, but they set using the Config and therefore should be constant (those are for the Debug Mode) */ 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 fa15da33df..225b85b680 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 @@ -102,10 +102,8 @@ public class GT_Worldgen_GT_Ore_Layer // This is a special empty orevein
return ORE_PLACED;
}
-
- //if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) || ((aDimensionType == 1) && (this.mEnd)) || ((aWorld.provider.getDimensionName().equals("Moon")) && (this.mMoon)) || ((aWorld.provider.getDimensionName().equals("Mars")) && (this.mMars)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) {
if (!isGenerationAllowed(aWorld, aDimensionType, ((aDimensionType == -1) && (this.mNether)) || ((aDimensionType == 0) && (this.mOverworld)) || ((aDimensionType == 1) && (this.mEnd)) ? aDimensionType : aDimensionType ^ 0xFFFFFFFF)) {
- /*
+ /* // Debug code, but spams log
if (debugOrevein) {
GT_Log.out.println(
"Wrong dimension"
@@ -115,13 +113,10 @@ public class GT_Worldgen_GT_Ore_Layer return WRONG_DIMENSION;
}
if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) {
- return WRONG_BIOME; //Not the correct biome for ore mix
+ return WRONG_BIOME;
}
int[] placeCount=new int[4];
- // Need to "reseed" RNG with values based on the orevein constants so that two oreveins at this same chunk don't end up trying the same sizes and offsets.
- aRandom.nextInt( this.mPrimaryMeta + this.mSecondaryMeta + this.mSporadicMeta + this.mBetweenMeta + Math.abs(aChunkX + aChunkZ));
-
int tMinY = mMinY + aRandom.nextInt(mMaxY - mMinY - 5);
// Determine West/East ends of orevein
int wXVein = aSeedX - aRandom.nextInt(mSize); // West side
diff --git a/src/main/java/gregtech/common/GT_Worldgen_Stone.java b/src/main/java/gregtech/common/GT_Worldgen_Stone.java index b936998656..d6f735fd17 100644 --- a/src/main/java/gregtech/common/GT_Worldgen_Stone.java +++ b/src/main/java/gregtech/common/GT_Worldgen_Stone.java @@ -67,8 +67,8 @@ public class GT_Worldgen_Stone long hash = ((long)((aWorld.provider.dimensionId & 0xffL)<<56) |( ((long)x & 0x000000000fffffffL) << 28) | ( (long)z & 0x000000000fffffffL )); if( !validStoneSeeds.containsKey(hash) ) { // Determine if RNG says to add stone at this chunk - stoneRNG.setSeed((long)aWorld.getSeed() ^ hash + Math.abs(mBlockMeta) + Math.abs(mSize) + Math.abs(mProbability) + ((GregTech_API.sBlockGranites==mBlock)?(1000):(0))); //Don't judge me. Want different values for different block types - if ( (this.mProbability <= 1) || (stoneRNG.nextInt(this.mProbability*3/2) == 0) ) { // Decreased probability of stones by factor of 66%. + stoneRNG.setSeed((long)aWorld.getSeed() ^ hash + Math.abs(mBlockMeta) + Math.abs(mSize) + ((GregTech_API.sBlockGranites==mBlock)?(32768):(0))); //Don't judge me. Want different values for different block types + if ( (this.mProbability <= 1) || (stoneRNG.nextInt(this.mProbability*2) == 0) ) { // Decreased probability of stones by factor of 2 // Add stone at this chunk validStoneSeeds.put( hash, new StoneSeeds(true) ); // Add to generation list @@ -101,7 +101,7 @@ public class GT_Worldgen_Stone int x = stones.get(0).mX*16; int z = stones.get(0).mZ*16; - stoneRNG.setSeed((long)aWorld.getSeed() ^ ((long)((aWorld.provider.dimensionId & 0xffL)<<60) |( ((long)x & 0x000000000fffffffL)<< 28) | ( (long)z & 0x000000000fffffffL )) + Math.abs(mBlockMeta) + Math.abs(mSize) + Math.abs(mProbability) + ((GregTech_API.sBlockGranites==mBlock)?(1000):(0))); //Don't judge me + stoneRNG.setSeed((long)aWorld.getSeed() ^ ((long)((aWorld.provider.dimensionId & 0xffL)<<56) |( ((long)x & 0x000000000fffffffL)<< 28) | ( (long)z & 0x000000000fffffffL )) + Math.abs(mBlockMeta) + Math.abs(mSize) + ((GregTech_API.sBlockGranites==mBlock)?(32768):(0))); //Don't judge me for (int i = 0; i < this.mAmount; i++) { // Not sure why you would want more than one in a chunk! Left alone though. // Locate the stoneseed XYZ. Original code would request an isAir at the seed location, causing a chunk generation request. // To reduce potential worldgen cascade, we just always try to place a ball and use the check inside the for loop to prevent @@ -190,88 +190,6 @@ public class GT_Worldgen_Stone } } } - -/* Old stone code - int tX = x + stoneRNG.nextInt(16); - int tY = this.mMinY + stoneRNG.nextInt(this.mMaxY - this.mMinY); - int tZ = z + stoneRNG.nextInt(16); - if ((this.mAllowToGenerateinVoid) || (!aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ))) { // Causes slight amount of worldgen cascade since it may load a chunk that is far away. - float math_pi = 3.141593F;//FB: CNT - CNT_ROUGH_CONSTANT_VALUE - float var6 = stoneRNG.nextFloat() * math_pi; - float var1d = this.mSize / 8.0F; - int var2d = tX + 8; - int var3d = tZ + 8; - int var4d = tY - 2; - float mh_s_0 = MathHelper.sin(var6) * var1d; - float mh_c_0 = MathHelper.cos(var6) * var1d; - float var7 = var2d + mh_s_0; - float var11 = var3d + mh_c_0; - int var15r = stoneRNG.nextInt(3); - int var17r = stoneRNG.nextInt(3); - int var15 = var4d + var15r; - int mh_n_4=var17r - var15r; - float mh_n_0 = -2*mh_s_0; - float mh_n_1 = -2*mh_c_0; - for (int var19 = 0; var19 <= this.mSize; var19++) { - float var5d = var19 / this.mSize; - float var20 = var7 + mh_n_0 * var5d; - float var22 = var15 + mh_n_4 * var5d; - float var24 = var11 + mh_n_1 * var5d; - float var6d = var19 * math_pi / this.mSize; - float var26 = stoneRNG.nextFloat() * this.mSize / 16.0F; - float var28 = ((MathHelper.sin(var6d) + 1.0F) * var26 + 1.0F) / 2.0F; - int tMinX = MathHelper.floor_float(var20 - var28); - int tMinY = MathHelper.floor_float(var22 - var28); - int tMinZ = MathHelper.floor_float(var24 - var28); - int tMaxX = MathHelper.floor_float(var20 + var28); - int tMaxY = MathHelper.floor_float(var22 + var28); - int tMaxZ = MathHelper.floor_float(var24 + var28); - - int wX = Math.max( tMinX, aChunkX + 8); - int eX = Math.min( tMaxX, aChunkX + 8 + 16 ); - - int sZ = Math.max( tMinZ, aChunkZ + 8); - int nZ = Math.min( tMaxZ, aChunkZ + 8 + 16 ); - - for (int iX = wX; iX < eX; iX++) { - float var39 = (iX + 0.5F - var20) / (var28); - float var10d = var39 * var39; - if (var10d < 1.0F) { - for (int iY = tMinY; iY <= tMaxY; iY++) { - float var42 = (iY + 0.5F - var22) / (var28); - float var12d = var10d + var42 * var42; - if (var12d < 1.0F) { - for (int iZ = sZ; iZ < nZ; iZ++) { - float var45 = (iZ + 0.5F - var24) / (var28); - if (var12d + var45 * var45 < 1.0F) { - Block tTargetedBlock = aWorld.getBlock(iX, iY, iZ); - if (tTargetedBlock instanceof GT_Block_Ores_Abstract) { - TileEntity tTileEntity = aWorld.getTileEntity(iX, iY, iZ); - if ((tTileEntity instanceof GT_TileEntity_Ores)) { - if (tTargetedBlock != GregTech_API.sBlockOres1) { - ((GT_TileEntity_Ores) tTileEntity).convertOreBlock(aWorld, iX, iY, iZ); - } - ((GT_TileEntity_Ores)tTileEntity).overrideOreBlockMaterial(this.mBlock, (byte) this.mBlockMeta); - } - } else if (((this.mAllowToGenerateinVoid) && (aWorld.getBlock(iX, iY, iZ).isAir(aWorld, iX, iY, iZ))) || ((tTargetedBlock != null) && ((tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, Blocks.stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, Blocks.end_stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, Blocks.netherrack)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, GregTech_API.sBlockGranites)) || (tTargetedBlock.isReplaceableOreGen(aWorld, iX, iY, iZ, GregTech_API.sBlockStones))))) { - aWorld.setBlock(iX, iY, iZ, this.mBlock, this.mBlockMeta, 0); - } - } - } - } - } - } - } - } - } -*/ - - - - - - - } } return result; diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index d477065c55..2540a298a2 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -21,7 +21,7 @@ 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 static gregtech.api.enums.GT_Values.oreveinMaxPlacementAttempts;
-import static gregtech.api.enums.GT_Values.oreveinMaxSize;
+// Disabled for hardcoded value. import static gregtech.api.enums.GT_Values.oreveinMaxSize;
import gregtech.api.enums.Materials;
@@ -191,11 +191,13 @@ implements IWorldGenerator { int i;
for( i = 0; (i < oreveinAttempts) && (!oreveinFound) && (placementAttempts<oreveinMaxPlacementAttempts); i++ ) {
int tRandomWeight = oreveinRNG.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;
+ for (GT_Worldgen_GT_Ore_Layer tWorldGen : GT_Worldgen_GT_Ore_Layer.sList) {
+ tRandomWeight -= ( tWorldGen).mWeight;
if (tRandomWeight <= 0) {
try {
- int placementResult = tWorldGen.executeWorldgenChunkified(this.mWorld, new XSTR( oreveinSeed ), this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, oreseedX*16, oreseedZ*16, this.mChunkGenerator, this.mChunkProvider);
+ // 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 + tWorldGen.mPrimaryMeta), this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, oreseedX*16, oreseedZ*16, this.mChunkGenerator, this.mChunkProvider);
switch(placementResult) {
case GT_Worldgen_GT_Ore_Layer.ORE_PLACED:
if (debugOrevein) GT_Log.out.println(
@@ -269,12 +271,12 @@ implements IWorldGenerator { switch( placementResult )
{
case GT_Worldgen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER:
- if (debugOrevein) GT_Log.out.print(
+ if (debugOrevein) GT_Log.out.println(
" No ore in bottom layer"
);
break;
case GT_Worldgen_GT_Ore_Layer.NO_OVERLAP:
- if (debugOrevein) GT_Log.out.print(
+ if (debugOrevein) GT_Log.out.println(
" No overlap"
);
}
@@ -283,8 +285,15 @@ implements IWorldGenerator { 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=64;
+ } else {
+ oreveinMaxSize=32;
+ }
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);
@@ -313,6 +322,8 @@ implements IWorldGenerator { 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 (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) {
@@ -326,6 +337,8 @@ implements IWorldGenerator { } catch (Throwable e) {
e.printStackTrace(GT_Log.err);
}
+
+ long leftOverTime = System.nanoTime();
//Asteroid Worldgen
int tDimensionType = this.mWorld.provider.dimensionId;
@@ -442,7 +455,9 @@ implements IWorldGenerator { long duration = (endTime - startTime);
if (debugWorldGen) {
GT_Log.out.println(
- " Oregen took " + duration +
+ " Oregen took " + (oregenTime-startTime)+
+ " Leftover gen took " + (leftOverTime - oregenTime ) +
+ " Worldgen took " + duration +
" nanoseconds"
);
}
|