aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_GT_Ore_Layer.java17
-rw-r--r--src/main/java/gregtech/common/GT_Worldgen_Stone.java260
-rw-r--r--src/main/java/gregtech/common/GT_Worldgenerator.java83
3 files changed, 259 insertions, 101 deletions
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 564292451d..fa15da33df 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
@@ -105,6 +105,13 @@ public class GT_Worldgen_GT_Ore_Layer
//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)) {
+ /*
+ if (debugOrevein) {
+ GT_Log.out.println(
+ "Wrong dimension"
+ );
+ }
+ */
return WRONG_DIMENSION;
}
if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) {
@@ -123,11 +130,13 @@ public class GT_Worldgen_GT_Ore_Layer
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
+ /*
if (debugOrevein) {
GT_Log.out.println(
"No X overlap"
);
}
+ */
return NO_OVERLAP;
}
// Determine North/Sound ends of orevein
@@ -137,11 +146,13 @@ public class GT_Worldgen_GT_Ore_Layer
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
+ /*
if (debugOrevein) {
GT_Log.out.println(
"No Z overlap"
);
}
+ */
return NO_OVERLAP;
}
// 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().
@@ -256,6 +267,10 @@ public class GT_Worldgen_GT_Ore_Layer
" oreseedX="+ aSeedX/16 +
" oreseedZ="+ aSeedZ/16 +
" cY="+tMinY+
+ " wXVein" + wXVein +
+ " eXVein" + eXVein +
+ " nZVein" + nZVein +
+ " sZVein" + sZVein +
" locDen=" + localDensity +
" Den=" + this.mDensity +
" Sec="+placeCount[1]+
@@ -265,6 +280,6 @@ public class GT_Worldgen_GT_Ore_Layer
);
}
// Something (at least the bottom layer must have 1 block) must have been placed, return true
- return ORE_PLACED;
+ return ORE_PLACED;
}
}
diff --git a/src/main/java/gregtech/common/GT_Worldgen_Stone.java b/src/main/java/gregtech/common/GT_Worldgen_Stone.java
index d7ee1d0bfd..b936998656 100644
--- a/src/main/java/gregtech/common/GT_Worldgen_Stone.java
+++ b/src/main/java/gregtech/common/GT_Worldgen_Stone.java
@@ -23,81 +23,175 @@ import static gregtech.api.enums.GT_Values.debugStones;
public class GT_Worldgen_Stone
extends GT_Worldgen_Ore {
- public Hashtable<Long, StoneSeeds> validStoneSeeds = new Hashtable(1024);
-
- class StoneSeeds {
- public boolean mExists;
-
- StoneSeeds( boolean exists ) {
- mExists = exists;
- }
- };
-
- class ValidSeeds {
- public int mX;
- public int mZ;
- ValidSeeds( int x, int z) {
- this.mX = x;
- this.mZ = z;
- }
- };
+ static final double sizeConversion[] = { 1, 1, 1.333333, 1.333333, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; // Bias the sizes towards skinnier boulders, ie more "shafts" than dikes or sills.
+
+ public Hashtable<Long, StoneSeeds> validStoneSeeds = new Hashtable(1024);
+
+ class StoneSeeds {
+ public boolean mExists;
+
+ StoneSeeds( boolean exists ) {
+ mExists = exists;
+ }
+ };
+
+ class ValidSeeds {
+ public int mX;
+ public int mZ;
+ ValidSeeds( int x, int z) {
+ this.mX = x;
+ this.mZ = z;
+ }
+ };
public GT_Worldgen_Stone(String aName, boolean aDefault, Block aBlock, int aBlockMeta, int aDimensionType, int aAmount, int aSize, int aProbability, int aMinY, int aMaxY, Collection<String> aBiomeList, boolean aAllowToGenerateinVoid) {
super(aName, aDefault, aBlock, aBlockMeta, aDimensionType, aAmount, aSize, aProbability, aMinY, aMaxY, aBiomeList, aAllowToGenerateinVoid);
}
public boolean executeWorldgen(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) {
- XSTR stoneRNG = new XSTR();
- ArrayList<ValidSeeds> stones = new ArrayList();
-
+ XSTR stoneRNG = new XSTR();
+ ArrayList<ValidSeeds> stones = new ArrayList();
+
if ( !isGenerationAllowed(aWorld, aDimensionType, this.mDimensionType)) {
- return false;
+ return false;
+ }
+ if ( !(this.mBiomeList.isEmpty() || this.mBiomeList.contains(aBiome)) ) {
+ return false;
}
- if ( !(this.mBiomeList.isEmpty() || this.mBiomeList.contains(aBiome)) ) {
- return false;
- }
- int windowWidth = (mSize/8)/16 + 1; // Width of chunks to check for a potential stoneseed (I think the real size of the balls is mSize/8, but the code below is difficult to understand)
- // Check stone seeds to see if they have been added
- for( int x = aChunkX/16 - windowWidth; x < (aChunkX/16 + windowWidth + 1); x++ ) {
- for( int z = aChunkZ/16 - windowWidth; z < (aChunkZ/16 + windowWidth + 1); z++ ) {
- long hash = (( (long)x << 32) | ( (long)z & 0x00000000ffffffffL ));
- if( !validStoneSeeds.containsKey(hash) ) {
- // Determine if RNG says to add stone at this chunk
- stoneRNG.setSeed((long)aWorld.getSeed() ^ hash);
- if ( (this.mProbability <= 1) || (aRandom.nextInt(this.mProbability) == 0) ) {
- // Add stone at this chunk
- validStoneSeeds.put( hash, new StoneSeeds(true) );
- // Add to generation list
- stones.add( new ValidSeeds(x,z) );
- if (debugStones) GT_Log.out.println(
- "New stoneseed x="+x+
- " z="+z+
- " mSize="+mSize
- );
- } else {
- validStoneSeeds.put( hash, new StoneSeeds(false) );
- }
- } else {
- // This chunk has already been checked, check to see if a boulder exists here
- if( validStoneSeeds.get(hash).mExists ) {
- // Add to generation list
- stones.add( new ValidSeeds(x,z) );
- }
- }
- }
- }
-
- boolean result = true;
- if (stones.size() == 0) {
- result = false;
- }
- // Now process each oreseed vs this requested chunk
- for( ; stones.size() != 0; stones.remove(0) ) {
- int x = stones.get(0).mX*16;
- int z = stones.get(0).mZ*16;
-
- stoneRNG.setSeed((long)aWorld.getSeed() ^ (( (long)x << 32) | ( (long)z & 0x00000000ffffffffL )));
-
- for (int i = 0; i < this.mAmount; i++) {
+ // I think the real size of the balls is mSize/8, but the original code was difficult to understand.
+ // Overall there will be less GT stones since they aren't spheres any more. /16 since this code uses it as a radius.
+ double realSize = mSize/16;
+ int windowWidth = ((int)realSize)/16 + 1; // Width of chunks to check for a potential stoneseed
+ // Check stone seeds to see if they have been added
+ for( int x = aChunkX/16 - windowWidth; x < (aChunkX/16 + windowWidth + 1); x++ ) {
+ for( int z = aChunkZ/16 - windowWidth; z < (aChunkZ/16 + windowWidth + 1); z++ ) {
+ 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%.
+ // Add stone at this chunk
+ validStoneSeeds.put( hash, new StoneSeeds(true) );
+ // Add to generation list
+ stones.add( new ValidSeeds(x,z) );
+ if (debugStones) GT_Log.out.println(
+ "New stoneseed="+mWorldGenName+
+ " x="+x+
+ " z="+z+
+ " realSize="+realSize
+ );
+ } else {
+ validStoneSeeds.put( hash, new StoneSeeds(false) );
+ }
+ } else {
+ // This chunk has already been checked, check to see if a boulder exists here
+ if( validStoneSeeds.get(hash).mExists ) {
+ // Add to generation list
+ stones.add( new ValidSeeds(x,z) );
+ }
+ }
+ }
+ }
+
+ boolean result = true;
+ if (stones.size() == 0) {
+ result = false;
+ }
+ // Now process each oreseed vs this requested chunk
+ for( ; stones.size() != 0; stones.remove(0) ) {
+ 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
+ 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
+ // placement instead.
+ int tX = x + stoneRNG.nextInt(16);
+ int tY = mMinY + stoneRNG.nextInt(mMaxY - mMinY);
+ int tZ = z + stoneRNG.nextInt(16);
+ //Determine the XYZ sizes of the stoneseed
+ double xSize = sizeConversion[stoneRNG.nextInt(sizeConversion.length)];
+ double ySize = sizeConversion[stoneRNG.nextInt(sizeConversion.length)/2]; // Skew the ySize towards the larger sizes, more long skinny pipes
+ double zSize = sizeConversion[stoneRNG.nextInt(sizeConversion.length)];
+
+ //Equation for an ellipsoid centered around 0,0,0
+ // Sx, Sy, and Sz are size controls (size = 1/S_)
+ // 1 = full size, 1.333 = 75%, 2 = 50%, 4 = 25%
+ // (x * Sx)^2 + (y * Sy)^2 + (z * sZ)^2 <= (mSize)^2
+
+ //So, we setup the intial boundaries to be the size of the boulder plus a block in each direction
+ int tMinX = tX-(int)(realSize/xSize-1.0);
+ int tMaxX = tX+(int)(realSize/xSize+2.0);
+ int tMinY = tY-(int)(realSize/ySize-1.0);
+ int tMaxY = tY+(int)(realSize/ySize+2.0);
+ int tMinZ = tZ-(int)(realSize/zSize-1.0);
+ int tMaxZ = tZ+(int)(realSize/zSize+2.0);
+
+ //Chop the boundaries by the parts that intersect with the current chunk
+ 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 );
+
+ if (debugStones) GT_Log.out.println(
+ mWorldGenName +
+ " tX=" + tX +
+ " tY=" + tY +
+ " tZ=" + tZ +
+ " realSize=" + realSize +
+ " xSize=" + realSize/xSize +
+ " ySize=" + realSize/ySize +
+ " zSize=" + realSize/zSize +
+ " wX=" + wX +
+ " eX=" + eX +
+ " tMinY=" + tMinY +
+ " tMaxY=" + tMaxY +
+ " sZ=" + sZ +
+ " nZ=" + nZ
+ );
+
+ double rightHandSide = realSize*realSize + 1; //Precalc the right hand side
+ for( int iY = tMinY; iY < tMaxY; iY++) { // Do placement from the bottom up layer up. Maybe better on cache usage?
+ double yCalc = ( (double)(iY-tY)*ySize );
+ yCalc = yCalc * yCalc; // (y*Sy)^2
+ double leftHandSize = yCalc;
+ if( leftHandSize > rightHandSide ) {
+ continue; // If Y alone is larger than the RHS, skip the rest of the loops
+ }
+ for( int iX = wX; iX < eX; iX++) {
+ double xCalc = ( (double)(iX-tX)*xSize );
+ xCalc = xCalc * xCalc;
+ leftHandSize = yCalc + xCalc;
+ if( leftHandSize > rightHandSide ) { // Again, if X and Y is larger than the RHS, skip to the next value
+ continue;
+ }
+ for( int iZ = sZ; iZ < nZ; iZ++ ) {
+ double zCalc = ( (double)(iZ-tZ)*zSize );
+ zCalc = zCalc * zCalc;
+ leftHandSize = zCalc + xCalc + yCalc;
+ if( leftHandSize > rightHandSide ) {
+ continue;
+ } else {
+ // Yay! We can actually place a block now. (this part copied from original code)
+ 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);
+ }
+ }
+ }
+ }
+ }
+
+/* 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);
@@ -105,19 +199,19 @@ public class GT_Worldgen_Stone
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;
+ 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 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 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;
+ 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;
@@ -133,12 +227,12 @@ public class GT_Worldgen_Stone
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 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 );
-
+ 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;
@@ -170,6 +264,14 @@ public class GT_Worldgen_Stone
}
}
}
+*/
+
+
+
+
+
+
+
}
}
return result;
diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java
index 85fbcae141..d477065c55 100644
--- a/src/main/java/gregtech/common/GT_Worldgenerator.java
+++ b/src/main/java/gregtech/common/GT_Worldgenerator.java
@@ -74,21 +74,42 @@ implements IWorldGenerator {
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, aZ, ((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 (debugWorldGen) GT_Log.out.println(
+ "aWorld.getSeed()="+aWorld.getSeed()
+ );
+ if (!this.ProcChunks.contains( ((aWorld.provider.dimensionId & 0xffL)<<56) |( ((long)aX & 0x000000000fffffffL) << 28) | ( (long)aZ & 0x000000000fffffffL )) ) { // Have to add ProcChunks due to Deep Dark bug that calls oregen twice
+ this.ProcChunks.add( ((aWorld.provider.dimensionId & 0xffL)<<56) |( ((long)aX & 0x000000000fffffffL) << 28) | ( (long)aZ & 0x000000000fffffffL ));
+*/
+ this.mList.add(new WorldGenContainer(new XSTR(Math.abs(aRandom.nextInt()) +1), aX, aZ, ((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 WorldSeed:"+aWorld.getSeed() +
+ " DimId" + aWorld.provider.dimensionId +
+ " 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 + " z:" + toRun.mZ + " SIZE: " + this.mList.size() + " i: " + i );}
- this.ProcChunks.remove( ((long)(toRun.mX) << 32) | ((long)(toRun.mZ) & 0x00000000ffffffffL));
+ if (debugWorldGen) GT_Log.out.println(
+ "RUN WorldSeed:"+aWorld.getSeed()+
+ " DimId" + aWorld.provider.dimensionId +
+ " chunk x:" + toRun.mX +
+ " z:" + toRun.mZ +
+ " SIZE: " + this.mList.size() +
+ " i: " + i
+ );
synchronized (listLock)
{
this.mList.remove(0);
@@ -141,21 +162,26 @@ implements IWorldGenerator {
}
public void worldGenFindVein( int oreseedX, int oreseedZ) {
- long oreveinSeed = (long)this.mWorld.getSeed() ^ (( (long)oreseedX << 32) | ( (long)oreseedZ & 0x00000000ffffffffL )); // Use an RNG that is identical every time it is called for this oreseed
+ // 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 = ((long)this.mWorld.getSeed()<<16) ^ ((long)((this.mWorld.provider.dimensionId & 0xffL)<<56) |( ((long)oreseedX & 0x000000000fffffffL) << 28) | ( (long)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 (debugOrevein) { tDimensionName = this.mWorld.provider.getDimensionName(); }
- /*
+
if (debugOrevein) GT_Log.out.println(
" Finding oreveins for oreveinSeed="+ oreveinSeed +
" mX="+ this.mX +
" mZ="+ this.mZ +
" oreseedX="+ oreseedX +
- " oreseedZ="+ oreseedZ
+ " oreseedZ="+ oreseedZ +
+ " worldSeed="+this.mWorld.getSeed()
);
- */
// Search for a valid orevein for this dimension
if( !validOreveins.containsKey(oreveinSeed) ) {
@@ -163,7 +189,6 @@ implements IWorldGenerator {
int placementAttempts = 0;
boolean oreveinFound = false;
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) {
@@ -175,10 +200,6 @@ implements IWorldGenerator {
case GT_Worldgen_GT_Ore_Layer.ORE_PLACED:
if (debugOrevein) GT_Log.out.println(
" Added oreveinSeed=" + oreveinSeed +
- " mX="+ this.mX +
- " mZ="+ this.mZ +
- " oreseedX="+ oreseedX +
- " oreseedZ="+ oreseedZ +
" tries at oremix=" + i +
" placementAttempts=" + placementAttempts +
" dimensionName=" + tDimensionName
@@ -243,8 +264,20 @@ implements IWorldGenerator {
" validOreveins.size()=" + validOreveins.size() + " "
);
GT_Worldgen tWorldGen = validOreveins.get(oreveinSeed);
- oreveinRNG.setSeed(oreveinSeed); // reset seed for RNG to only be based on oreseed X/Z
- tWorldGen.executeWorldgenChunkified(this.mWorld, oreveinRNG, this.mBiome, this.mDimensionType, this.mX*16, this.mZ*16, oreseedX*16, oreseedZ*16, this.mChunkGenerator, this.mChunkProvider);
+ oreveinRNG.setSeed(oreveinSeed); // Reset RNG to only be based on oreseed X/Z
+ 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 GT_Worldgen_GT_Ore_Layer.NO_ORE_IN_BOTTOM_LAYER:
+ if (debugOrevein) GT_Log.out.print(
+ " No ore in bottom layer"
+ );
+ break;
+ case GT_Worldgen_GT_Ore_Layer.NO_OVERLAP:
+ if (debugOrevein) GT_Log.out.print(
+ " No overlap"
+ );
+ }
}
}
@@ -252,16 +285,20 @@ implements IWorldGenerator {
long startTime = System.nanoTime();
// Determine bounding box on how far out to check for oreveins affecting this chunk
- 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);
+ 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) );
}
}
@@ -269,6 +306,10 @@ implements IWorldGenerator {
// 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 );
}