Skip to content

Commit

Permalink
Cascading lag hunt: Identified all sources of cascading lag (see #40)…
Browse files Browse the repository at this point in the history
…. Fixed soil pits. Removed old WorldGenTallPlant. Fixed clay having old high rainfall threshold for generation, asserted that yes, clay marking plants are working fine.
  • Loading branch information
alcatrazEscapee committed Apr 17, 2019
1 parent dfc767b commit 21ccbfe
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
import static net.dries007.tfc.world.classic.chunkdata.ChunkDataTFC.getRock3;

/**
* todo: this causes cascading world gen!
* todo: fix cascading lag. Priority: medium - low.
* See <a href="https://github.com/TerraFirmaCraft/TerraFirmaCraft/issues/40">issue</a> here.
*/
public class WorldGenFissure implements IWorldGenerator
{
Expand Down Expand Up @@ -62,7 +63,6 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG
BlockPos start = new ChunkPos(chunkX, chunkZ).getBlock(random.nextInt(16) + 8, 0, random.nextInt(16) + 8);
Biome biome = world.getBiome(start);

//noinspection ConstantConditions
if (biome == BiomesTFC.BEACH || biome == BiomesTFC.OCEAN || biome == BiomesTFC.GRAVEL_BEACH || biome == BiomesTFC.LAKE || biome == BiomesTFC.RIVER || biome == BiomesTFC.DEEP_OCEAN)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
import net.dries007.tfc.world.classic.ClimateTFC;
import net.dries007.tfc.world.classic.chunkdata.ChunkDataTFC;

/**
* todo: fix cascading lag. Priority: high
* See <a href="https://github.com/TerraFirmaCraft/TerraFirmaCraft/issues/40">issue</a> here.
*/
@ParametersAreNonnullByDefault
public class WorldGenPlantTFC extends WorldGenerator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@
import net.dries007.tfc.world.classic.WorldTypeTFC;
import net.dries007.tfc.world.classic.chunkdata.ChunkDataTFC;

/**
* todo: make these bigger without causing cascading lag.
* This will require larger re-writes on the scale of oregen
*/
public class WorldGenSoilPits implements IWorldGenerator
{
private static final float CLAY_RAINFALL_THREHOLD = 100f;
private static final int CLAY_CHUNK_RARITY = 30;

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
{
Expand All @@ -50,17 +57,19 @@ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkG

private void generateClay(World world, Random rng, BlockPos start)
{
int radius = rng.nextInt(14) + 2;
// If this has to have a radius that is >= 8, then it needs to be moved to a cascading-lag safe model
// Otherwise, do not change this unless you are prepared to do some fairly large re-writes, similar to how ore gen is handled
int radius = rng.nextInt(6) + 2;
int depth = rng.nextInt(3) + 1;
if (rng.nextInt(30) != 0 || start.getY() > WorldTypeTFC.SEALEVEL + 6) return;
if (rng.nextInt(CLAY_CHUNK_RARITY) != 0 || start.getY() > WorldTypeTFC.SEALEVEL + 6) return;
if (ChunkDataTFC.getRainfall(world, start) < CLAY_RAINFALL_THREHOLD) return;

for (int x = -radius; x <= radius; x++)
{
for (int z = -radius; z <= radius; z++)
{
if (x * x + z * z > radius * radius) continue;
final BlockPos posHorizontal = start.add(x, 0, z);
if (ChunkDataTFC.getRainfall(world, posHorizontal) < 500) continue;

boolean flag = false;
for (int y = -depth; y <= +depth; y++)
Expand Down Expand Up @@ -106,7 +115,9 @@ else if (BlocksTFC.isGrass(current))

private boolean generatePeat(World world, Random rng, BlockPos start)
{
int radius = rng.nextInt(16) + 8;
// If this has to have a radius that is >= 8, then it needs to be moved to a cascading-lag safe model
// Otherwise, do not change this unless you are prepared to do some fairly large re-writes, similar to how ore gen is handled
int radius = rng.nextInt(4) + 4;
byte depth = 2;
boolean flag = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import net.dries007.tfc.world.classic.chunkdata.ChunkDataTFC;

/**
* todo: this causes cascading world gen!
* todo: fix cascading lag. Priority: medium low
* See <a href="https://github.com/TerraFirmaCraft/TerraFirmaCraft/issues/40">issue</a> here.
*/
public class WorldGenSurfaceFissureCluster implements IWorldGenerator
{
Expand Down

This file was deleted.

0 comments on commit 21ccbfe

Please sign in to comment.