From 376f7c63f6d7ea9df0b967e9dc1ecbd710370307 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Sun, 12 Nov 2017 21:27:13 -0600 Subject: First pass at chunkifying oreveins --- src/main/java/gregtech/api/enums/GT_Values.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/gregtech/api/enums/GT_Values.java') diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index d6fae23b01..d4b98fd291 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -122,10 +122,18 @@ public class GT_Values { */ 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. + * 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; + /** + * 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. + */ + public static int oreveinMaxSize; + /** * 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; @@ -149,4 +157,4 @@ public class GT_Values { * 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 +} -- cgit From e15136ba1a3cf7cc110dedb776428b97ece94faa Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Wed, 15 Nov 2017 01:35:17 -0600 Subject: Feature complete. Ready for testing in multiple dimensions. --- src/main/java/gregtech/GT_Mod.java | 1 + src/main/java/gregtech/api/enums/GT_Values.java | 6 +- src/main/java/gregtech/api/world/GT_Worldgen.java | 2 +- .../gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 34 ++---- .../common/GT_Worldgen_GT_Ore_SmallPieces.java | 13 +- .../java/gregtech/common/GT_Worldgen_Stone.java | 135 +++++++++++++++++---- .../java/gregtech/common/GT_Worldgenerator.java | 18 +-- 7 files changed, 148 insertions(+), 61 deletions(-) (limited to 'src/main/java/gregtech/api/enums/GT_Values.java') diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index e2ed973ed6..ca3e2edaa1 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -192,6 +192,7 @@ public class GT_Mod implements IGT_Mod { GT_Values.debugWorldGen = tMainConfig.get(aTextGeneral, "debugWorldGen", false).getBoolean(false); GT_Values.debugOrevein = tMainConfig.get(aTextGeneral, "debugOrevein", false).getBoolean(false); GT_Values.debugSmallOres = tMainConfig.get(aTextGeneral, "debugSmallOres", false).getBoolean(false); + GT_Values.debugStones = tMainConfig.get(aTextGeneral, "debugStones", 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); GT_Values.oreveinMaxPlacementAttempts = tMainConfig.get(aTextGeneral, "oreveinMaxPlacementAttempts_8",8).getInt(8); diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index d4b98fd291..a9af1bb266 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -153,7 +153,11 @@ public class GT_Values { * Debug parameter for small ore generation. */ public static boolean debugSmallOres = false; - /** + /** + * Debug parameter for stones generation. + */ + public static boolean debugStones = false; + /** * If you have to give something a World Parameter but there is no World... (Dummy World) */ public static World DW; diff --git a/src/main/java/gregtech/api/world/GT_Worldgen.java b/src/main/java/gregtech/api/world/GT_Worldgen.java index fb202b5a82..0b73ac7331 100644 --- a/src/main/java/gregtech/api/world/GT_Worldgen.java +++ b/src/main/java/gregtech/api/world/GT_Worldgen.java @@ -35,7 +35,7 @@ public abstract class GT_Worldgen { } public int executeWorldgenChunkified(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, int seedX, int seedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - return 4; // This is for the empryOrevein + return 4; // This is for the empty Orevein } /** 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 edb1fa020d..86d140d6b5 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,7 +16,6 @@ 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 { @@ -97,11 +96,9 @@ public class GT_Worldgen_GT_Ore_Layer public int executeWorldgenChunkified(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, int aSeedX, int aSeedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { if( mWorldGenName.equals("NoOresInVein") ) { - /* if (debugOrevein) GT_Log.out.println( - " NoOresInVein, skipping" + " NoOresInVein" ); - */ // This is a special empty orevein return ORE_PLACED; } @@ -116,39 +113,35 @@ public class GT_Worldgen_GT_Ore_Layer 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 + aChunkX + aChunkZ); + 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 int eXVein = aSeedX + 16 + aRandom.nextInt(mSize); // Limit Orevein to only blocks present in current chunk - int wX = Math.max( wXVein, aChunkX); - int eX = Math.min( eXVein, aChunkX + 16); + 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) { - System.out.println( - "No overlap in X dim!" + GT_Log.out.println( + "No X overlap" ); } -*/ return NO_OVERLAP; } // 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); - int sZ = Math.min(sZVein, aChunkZ + 16); + 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) { - System.out.println( - "No overlap in Z dim!" + 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(). @@ -173,12 +166,9 @@ public class GT_Worldgen_GT_Ore_Layer } } if ((placeCount[1]+placeCount[3])==0) { -/* - GT_Log.out.println( - "Generated Orevein:" + this.mWorldGenName + - " did not place any ores in bottom layer, skipping" + if (debugOrevein) 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 } for (level = tMinY; level < (tMinY-1+3); level++) { 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 a299698f6d..35d619dad5 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 @@ -47,10 +47,11 @@ public class GT_Worldgen_GT_Ore_SmallPieces return false; } int count=0; + if (this.mMeta > 0) { - int i = 0; - for (int j = Math.max(1, this.mAmount / 2 + aRandom.nextInt(this.mAmount) / 2); i < j; i++) { - GT_TileEntity_Ores.setOreBlock(aWorld, aChunkX + aRandom.nextInt(16), this.mMinY + aRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), aChunkZ + aRandom.nextInt(16), this.mMeta, true); + int j = Math.max(1, this.mAmount / 2 + aRandom.nextInt(this.mAmount) / 2); + for ( int i = 0; i < j; i++) { + GT_TileEntity_Ores.setOreBlock(aWorld, aChunkX + 8 + aRandom.nextInt(16), this.mMinY + aRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), aChunkZ + 8 + aRandom.nextInt(16), this.mMeta, true); count++; } } @@ -58,9 +59,9 @@ public class GT_Worldgen_GT_Ore_SmallPieces GT_Log.out.println( "Small Ore:" + this.mWorldGenName + " @ dim="+aDimensionType+ - " chunkX="+aChunkX+ - " chunkZ="+aChunkZ+ - " ore="+count+" "+new ItemStack(GregTech_API.sBlockOres1,1,mMeta).getDisplayName() + " mX="+aChunkX/16+ + " mZ="+aChunkZ/16+ + " ore="+count ); } return true; diff --git a/src/main/java/gregtech/common/GT_Worldgen_Stone.java b/src/main/java/gregtech/common/GT_Worldgen_Stone.java index c22585d26a..d7ee1d0bfd 100644 --- a/src/main/java/gregtech/common/GT_Worldgen_Stone.java +++ b/src/main/java/gregtech/common/GT_Worldgen_Stone.java @@ -1,6 +1,8 @@ package gregtech.common; import gregtech.api.GregTech_API; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_Log; import gregtech.api.world.GT_Worldgen_Ore; import gregtech.common.blocks.GT_Block_Ores_Abstract; import gregtech.common.blocks.GT_TileEntity_Ores; @@ -13,37 +15,116 @@ import net.minecraft.world.chunk.IChunkProvider; import java.util.Collection; import java.util.Random; +import java.util.Hashtable; +import java.util.ArrayList; + +import static gregtech.api.enums.GT_Values.debugStones; public class GT_Worldgen_Stone extends GT_Worldgen_Ore { + + public Hashtable 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 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) { - if ((isGenerationAllowed(aWorld, aDimensionType, this.mDimensionType)) && ((this.mBiomeList.isEmpty()) || (this.mBiomeList.contains(aBiome))) && ((this.mProbability <= 1) || (aRandom.nextInt(this.mProbability) == 0))) { + XSTR stoneRNG = new XSTR(); + ArrayList stones = new ArrayList(); + + if ( !isGenerationAllowed(aWorld, aDimensionType, this.mDimensionType)) { + 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++) { - int tX = aChunkX + aRandom.nextInt(16); - int tY = this.mMinY + aRandom.nextInt(this.mMaxY - this.mMinY); - int tZ = aChunkZ + aRandom.nextInt(16); - if ((this.mAllowToGenerateinVoid) || (!aWorld.getBlock(tX, tY, tZ).isAir(aWorld, tX, tY, tZ))) { + 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 = aRandom.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 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 = aRandom.nextInt(3);int var17r = aRandom.nextInt(3); + 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; + 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 = aRandom.nextFloat() * this.mSize / 16.0F; + 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); @@ -51,28 +132,35 @@ public class GT_Worldgen_Stone int tMaxX = MathHelper.floor_float(var20 + var28); int tMaxY = MathHelper.floor_float(var22 + var28); int tMaxZ = MathHelper.floor_float(var24 + var28); - for (int eX = tMinX; eX <= tMaxX; eX++) { - float var39 = (eX + 0.5F - var20) / (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 eY = tMinY; eY <= tMaxY; eY++) { - float var42 = (eY + 0.5F - var22) / (var28); + 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 eZ = tMinZ; eZ <= tMaxZ; eZ++) { - float var45 = (eZ + 0.5F - var24) / (var28); + for (int iZ = sZ; iZ < nZ; iZ++) { + float var45 = (iZ + 0.5F - var24) / (var28); if (var12d + var45 * var45 < 1.0F) { - Block tTargetedBlock = aWorld.getBlock(eX, eY, eZ); + Block tTargetedBlock = aWorld.getBlock(iX, iY, iZ); if (tTargetedBlock instanceof GT_Block_Ores_Abstract) { - TileEntity tTileEntity = aWorld.getTileEntity(eX, eY, eZ); + TileEntity tTileEntity = aWorld.getTileEntity(iX, iY, iZ); if ((tTileEntity instanceof GT_TileEntity_Ores)) { if (tTargetedBlock != GregTech_API.sBlockOres1) { - ((GT_TileEntity_Ores) tTileEntity).convertOreBlock(aWorld, eX, eY, eZ); + ((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(eX, eY, eZ).isAir(aWorld, eX, eY, eZ))) || ((tTargetedBlock != null) && ((tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, Blocks.stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, Blocks.end_stone)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, Blocks.netherrack)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, GregTech_API.sBlockGranites)) || (tTargetedBlock.isReplaceableOreGen(aWorld, eX, eY, eZ, GregTech_API.sBlockStones))))) { - aWorld.setBlock(eX, eY, eZ, this.mBlock, this.mBlockMeta, 0); + } 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); } } } @@ -83,8 +171,7 @@ public class GT_Worldgen_Stone } } } - return true; } - return false; + return result; } } diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index 019917a148..60fa422d6a 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -173,7 +173,7 @@ implements IWorldGenerator { 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); switch(placementResult) { case GT_Worldgen_GT_Ore_Layer.ORE_PLACED: - if (debugWorldGen) GT_Log.out.println( + if (debugOrevein) GT_Log.out.println( " Added oreveinSeed=" + oreveinSeed + " mX="+ this.mX + " mZ="+ this.mZ + @@ -196,7 +196,7 @@ implements IWorldGenerator { } break; // Try the next orevein } catch (Throwable e) { - if (debugWorldGen) GT_Log.out.println( + if (debugOrevein) GT_Log.out.println( "Exception occurred on oreVein" + tWorldGen + " oreveinSeed="+ oreveinSeed + " mX="+ this.mX + @@ -211,7 +211,7 @@ implements IWorldGenerator { } // 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( + if (debugOrevein) GT_Log.out.println( " Empty oreveinSeed="+ oreveinSeed + " mX="+ this.mX + " mZ="+ this.mZ + @@ -224,7 +224,7 @@ implements IWorldGenerator { validOreveins.put(oreveinSeed, noOresInVein ); } } else if(oreveinPercentageRoll >= oreveinPercentage) { - if (debugWorldGen) GT_Log.out.println( + if (debugOrevein) GT_Log.out.println( " Skipped oreveinSeed="+ oreveinSeed + " mX="+ this.mX + " mZ="+ this.mZ + @@ -238,7 +238,7 @@ implements IWorldGenerator { } }else { // oreseed is located in the previously processed table - if (debugWorldGen) GT_Log.out.print( + if (debugOrevein) GT_Log.out.print( " Valid oreveinSeed="+ oreveinSeed + " validOreveins.size()=" + validOreveins.size() + " " ); @@ -268,15 +268,19 @@ implements IWorldGenerator { } // Now process each oreseed vs this requested chunk - for( ; seedList.size() != 0; ) { + for( ; seedList.size() != 0; seedList.remove(0) ) { worldGenFindVein( seedList.get(0).mX, seedList.get(0).mZ ); - seedList.remove(0); } // Do leftover worldgen for this chunk (GT_Stones and GT_small_ores) try { for (GT_Worldgen tWorldGen : GregTech_API.sWorldgenList) { + /* + 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) { -- cgit From 8ddd0b37555b5e106c0ae228fe4dbea18889ceed Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Thu, 16 Nov 2017 23:15:30 -0600 Subject: Remove tabs, replace with spaces --- src/main/java/gregtech/api/enums/GT_Values.java | 76 ++--- .../gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 322 +++++++++---------- .../common/GT_Worldgen_GT_Ore_SmallPieces.java | 8 +- .../java/gregtech/common/GT_Worldgenerator.java | 356 ++++++++++----------- .../gregtech/common/blocks/GT_TileEntity_Ores.java | 8 +- 5 files changed, 385 insertions(+), 385 deletions(-) (limited to 'src/main/java/gregtech/api/enums/GT_Values.java') diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index a9af1bb266..b2408affe5 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -117,47 +117,47 @@ 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. 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; - /** - * 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. - */ - public static int oreveinMaxSize; - /** + /** + * 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; + /** + * 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. + */ + public static int oreveinMaxSize; + /** * 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; - /** - * Debug parameter for small ore generation. - */ - public static boolean debugSmallOres = false; - /** - * Debug parameter for stones generation. - */ - public static boolean debugStones = 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; + /** + * Debug parameter for small ore generation. + */ + public static boolean debugSmallOres = false; + /** + * Debug parameter for stones generation. + */ + public static boolean debugStones = false; + /** * If you have to give something a World Parameter but there is no World... (Dummy World) */ public static World DW; 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 86d140d6b5..564292451d 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 @@ -36,13 +36,13 @@ public class GT_Worldgen_GT_Ore_Layer public final boolean mNether; public final boolean mEnd; public final boolean mEndAsteroid; - 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 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 final boolean mMoon; //public final boolean mMars; //public final boolean mAsteroid; @@ -59,14 +59,14 @@ public class GT_Worldgen_GT_Ore_Layer //this.mAsteroid = GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "Asteroid", aAsteroid); this.mMinY = ((short) GregTech_API.sWorldgenFile.get(aTextWorldgen + this.mWorldGenName, "MinHeight", aMinY)); 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; + 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))); @@ -88,173 +88,173 @@ public class GT_Worldgen_GT_Ore_Layer GT_Achievements.registerOre(GregTech_API.sGeneratedMaterials[(mSporadicMeta % 1000)], aMinY, aMaxY, aWeight, aOverworld, aNether, aEnd); sWeight += this.mWeight; if(GregTech_API.mImmersiveEngineering && GT_Mod.gregtechproxy.mImmersiveEngineeringRecipes){ - blusunrize.immersiveengineering.api.tool.ExcavatorHandler.addMineral(aName.substring(8, 9).toUpperCase()+aName.substring(9), aWeight, 0.2f, new String[]{"ore"+aPrimary.mName,"ore"+aSecondary.mName,"ore"+aBetween.mName,"ore"+aSporadic.mName}, new float[]{.4f,.4f,.15f,.05f}); + blusunrize.immersiveengineering.api.tool.ExcavatorHandler.addMineral(aName.substring(8, 9).toUpperCase()+aName.substring(9), aWeight, 0.2f, new String[]{"ore"+aPrimary.mName,"ore"+aSecondary.mName,"ore"+aBetween.mName,"ore"+aSporadic.mName}, new float[]{.4f,.4f,.15f,.05f}); } } } public int executeWorldgenChunkified(World aWorld, Random aRandom, String aBiome, int aDimensionType, int aChunkX, int aChunkZ, int aSeedX, int aSeedZ, IChunkProvider aChunkGenerator, IChunkProvider aChunkProvider) { - if( mWorldGenName.equals("NoOresInVein") ) { - if (debugOrevein) GT_Log.out.println( + if( mWorldGenName.equals("NoOresInVein") ) { + if (debugOrevein) GT_Log.out.println( " NoOresInVein" ); - // 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)) { + // 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)) { return WRONG_DIMENSION; } if (!this.mRestrictBiome.equals("None") && !(this.mRestrictBiome.equals(aBiome))) { return WRONG_BIOME; //Not the correct biome for ore mix } - int[] placeCount=new int[4]; + 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 - 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 - if (debugOrevein) { - GT_Log.out.println( - "No X overlap" - ); - } - return NO_OVERLAP; - } - // 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 - 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(). - 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))) ); + // 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 + 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 + if (debugOrevein) { + GT_Log.out.println( + "No X overlap" + ); + } + return NO_OVERLAP; + } + // 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 + 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(). + 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 > 0) ) { - if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) - placeCount[3]++; - } - } - } - if ((placeCount[1]+placeCount[3])==0) { - if (debugOrevein) GT_Log.out.println( - " No ore in bottom layer" + // 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 > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) + placeCount[3]++; + } + } + } + if ((placeCount[1]+placeCount[3])==0) { + if (debugOrevein) 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 - } - 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 > 0) ) { - if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.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 > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate - if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.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 > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { - placeCount[2]++; - } - } - else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta > 0) ) { - if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.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 > 0) ) { - if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate - if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) - placeCount[3]++; - } - } - } - } + return NO_ORE_IN_BOTTOM_LAYER; // Exit early, didn't place anything in the bottom layer + } + 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 > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { // Between are only 1 per vertical column, reduce by 1/2 to compensate + if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mBetweenMeta, false, false)) { + placeCount[2]++; + } + } + else if ( ((aRandom.nextInt(placeZ) == 0) || (aRandom.nextInt(placeX) == 0)) && (this.mPrimaryMeta > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.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 > 0) ) { + if (GT_TileEntity_Ores.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 > 0) ) { // Sporadics are only 1 per vertical column normally, reduce by 1/7 to compensate + if (GT_TileEntity_Ores.setOreBlock(aWorld, tX, level, tZ, this.mSporadicMeta, false, false)) + placeCount[3]++; + } + } + } + } if (debugOrevein) { - String tDimensionName = aWorld.provider.getDimensionName(); + String tDimensionName = aWorld.provider.getDimensionName(); GT_Log.out.println( "Generated Orevein:" + this.mWorldGenName + " Dimension=" + tDimensionName + - " mX="+aChunkX/16+ + " mX="+aChunkX/16+ " mZ="+aChunkZ/16+ " oreseedX="+ aSeedX/16 + - " oreseedZ="+ aSeedZ/16 + + " oreseedZ="+ aSeedZ/16 + " cY="+tMinY+ " locDen=" + localDensity + " Den=" + this.mDensity + @@ -263,8 +263,8 @@ public class GT_Worldgen_GT_Ore_Layer " 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; + } + // Something (at least the bottom layer must have 1 block) must have been placed, return true + return ORE_PLACED; } } 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 35d619dad5..1bb583908f 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 @@ -47,9 +47,9 @@ public class GT_Worldgen_GT_Ore_SmallPieces return false; } int count=0; - + if (this.mMeta > 0) { - int j = Math.max(1, this.mAmount / 2 + aRandom.nextInt(this.mAmount) / 2); + int j = Math.max(1, this.mAmount / 2 + aRandom.nextInt(this.mAmount) / 2); for ( int i = 0; i < j; i++) { GT_TileEntity_Ores.setOreBlock(aWorld, aChunkX + 8 + aRandom.nextInt(16), this.mMinY + aRandom.nextInt(Math.max(1, this.mMaxY - this.mMinY)), aChunkZ + 8 + aRandom.nextInt(16), this.mMeta, true); count++; @@ -59,8 +59,8 @@ public class GT_Worldgen_GT_Ore_SmallPieces GT_Log.out.println( "Small Ore:" + this.mWorldGenName + " @ dim="+aDimensionType+ - " mX="+aChunkX/16+ - " mZ="+aChunkZ/16+ + " mX="+aChunkX/16+ + " mZ="+aChunkZ/16+ " ore="+count ); } diff --git a/src/main/java/gregtech/common/GT_Worldgenerator.java b/src/main/java/gregtech/common/GT_Worldgenerator.java index c8f0be68d2..85fbcae141 100644 --- a/src/main/java/gregtech/common/GT_Worldgenerator.java +++ b/src/main/java/gregtech/common/GT_Worldgenerator.java @@ -45,12 +45,12 @@ implements IWorldGenerator { //private static int gcMaxSize = 400; private static boolean endAsteroids = true; public static List mList = new ArrayList(); - public static HashSet ProcChunks = new HashSet(); - // 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 GT_Worldgen_GT_Ore_Layer noOresInVein = new GT_Worldgen_GT_Ore_Layer( "NoOresInVein", false, 0, 255, 0, 255, 16, false, false, false, false, false, false, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium); - public static Hashtable validOreveins = new Hashtable(1024); + public static HashSet ProcChunks = new HashSet(); + // 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 GT_Worldgen_GT_Ore_Layer noOresInVein = new GT_Worldgen_GT_Ore_Layer( "NoOresInVein", false, 0, 255, 0, 255, 16, false, false, false, false, false, false, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium, Materials.Aluminium); + public static Hashtable validOreveins = new Hashtable(1024); public boolean mIsGenerating = false; - public static final Object listLock = new Object(); + public static final Object listLock = new Object(); //private static boolean gcAsteroids = true; @@ -64,23 +64,23 @@ implements IWorldGenerator { //gcMaxSize = GregTech_API.sWorldgenFile.get("gcasteroids", "GCAsteroidMaxSize", 400); //mGCAsteroidProbability = GregTech_API.sWorldgenFile.get("gcasteroids", "GCAsteroidProbability", 300); GameRegistry.registerWorldGenerator(this, 1073741823); - if (debugWorldGen) { - GT_Log.out.println( - "GT_Worldgenerator created" - ); - } + 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) - { - 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());} - } else { - if (debugWorldGen) {GT_Log.out.println("DUP WorldGen chunk x:" + aX + " z:" + aZ + " SIZE: " + this.mList.size() + " ProcChunks.size(): " + ProcChunks.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, 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());} + } 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; @@ -88,7 +88,7 @@ implements IWorldGenerator { 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)); + this.ProcChunks.remove( ((long)(toRun.mX) << 32) | ((long)(toRun.mZ) & 0x00000000ffffffffL)); synchronized (listLock) { this.mList.remove(0); @@ -117,18 +117,18 @@ implements IWorldGenerator { 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 seedList = new ArrayList(); + // 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 seedList = new ArrayList(); - // aX and aZ are now the by-chunk X and Z for the chunk of interest + // 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; @@ -140,152 +140,152 @@ implements IWorldGenerator { this.mBiome = aBiome; } - 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 - 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 - ); - */ + 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 + 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 + ); + */ - // Search for a valid orevein for this dimension - if( !validOreveins.containsKey(oreveinSeed) ) { - if ( (oreveinPercentageRoll 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) { - int placementAttempts = 0; - boolean oreveinFound = false; - int i; - - for( i = 0; (i < oreveinAttempts) && (!oreveinFound) && (placementAttempts 0) && (GT_Worldgen_GT_Ore_Layer.sList.size() > 0)) { + int placementAttempts = 0; + boolean oreveinFound = false; + int i; + + for( i = 0; (i < oreveinAttempts) && (!oreveinFound) && (placementAttempts 0) && ((tBlock != Blocks.air) || air)) { - if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) { - //Do nothing, stone background is default background. - //Do this comparison first since stone is most common + if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.stone)) { + //Do nothing, stone background is default background. + //Do this comparison first since stone is most common } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.netherrack)) { aMetaData += 1000; } else if (tBlock.isReplaceableOreGen(aWorld, aX, aY, aZ, Blocks.end_stone)) { @@ -78,7 +78,7 @@ public class GT_TileEntity_Ores extends TileEntity implements ITexturedTileEntit } else { aMetaData += 5000; } - } else if (BlockName.equals("tile.igneousStone")) { + } else if (BlockName.equals("tile.igneousStone")) { if (GregTech_API.sBlockOresUb1 != null) { tOreBlock = GregTech_API.sBlockOresUb1; aMetaData += (BlockMeta * 1000); -- cgit From 11ffc12143d6faa3ff8b877c30c6545431243d76 Mon Sep 17 00:00:00 2001 From: Richard Hendricks Date: Mon, 20 Nov 2017 18:41:20 -0600 Subject: Removed oreveinSize to use a hardcoded value for now, until we can do per-dimension setup. Other minor fixes --- src/main/java/gregtech/api/enums/GT_Values.java | 3 +- .../gregtech/common/GT_Worldgen_GT_Ore_Layer.java | 9 +-- .../java/gregtech/common/GT_Worldgen_Stone.java | 88 +--------------------- .../java/gregtech/common/GT_Worldgenerator.java | 29 +++++-- 4 files changed, 29 insertions(+), 100 deletions(-) (limited to 'src/main/java/gregtech/api/enums/GT_Values.java') 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