From 5c13230c4227bdd1137a0afe7a4fcafa3e5270b7 Mon Sep 17 00:00:00 2001 From: mezz Date: Thu, 16 Feb 2017 18:22:28 -0800 Subject: [PATCH] Stop worldgen chunk generation runaway from rubber trees --- .../techreborn/world/RubberTreeGenerator.java | 24 ++++++------------- .../techreborn/world/TechRebornWorldGen.java | 11 ++------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/main/java/techreborn/world/RubberTreeGenerator.java b/src/main/java/techreborn/world/RubberTreeGenerator.java index 346e35bf2..a024a7154 100644 --- a/src/main/java/techreborn/world/RubberTreeGenerator.java +++ b/src/main/java/techreborn/world/RubberTreeGenerator.java @@ -29,27 +29,17 @@ public class RubberTreeGenerator extends WorldGenerator { @Override public boolean generate(World worldIn, Random rand, BlockPos position) { - int x = position.getX(); - int z = position.getZ(); int retries = rand.nextInt(3) + 2; - if (isWorldGen) { - for (int c = 0; c < retries; c++) { - int y = worldIn.getActualHeight() - 1; - while (worldIn.isAirBlock(new BlockPos(x, y, z)) && y > 0) { - y--; - } - if (!growTree(worldIn, rand, x, y + 1, z)) { - retries--; - } - x += rand.nextInt(16) - 8; - z += rand.nextInt(16) - 8; - } - } else { - int y = worldIn.getActualHeight() - 1; + for (int c = 0; c < retries; c++) { + int x = position.getX() + 8 + rand.nextInt(16); + int z = position.getZ() + 8 + rand.nextInt(16); + int y = worldIn.getHeight(x, z) - 1; while (worldIn.isAirBlock(new BlockPos(x, y, z)) && y > 0) { y--; } - return growTree(worldIn, rand, x, y + 1, z); + if (!growTree(worldIn, rand, x, y + 1, z)) { + retries--; + } } return false; diff --git a/src/main/java/techreborn/world/TechRebornWorldGen.java b/src/main/java/techreborn/world/TechRebornWorldGen.java index c9039ca95..b0b4bbc74 100644 --- a/src/main/java/techreborn/world/TechRebornWorldGen.java +++ b/src/main/java/techreborn/world/TechRebornWorldGen.java @@ -268,18 +268,11 @@ public class TechRebornWorldGen implements IWorldGenerator { chance = 1; } if (random.nextInt(chance) == 0) { - int x = (chunkX * 16) + random.nextInt(15); - int z = (chunkZ * 16) + random.nextInt(15); + int x = chunkX * 16; + int z = chunkZ * 16; for (int i = 0; i < config.rubberTreeConfig.clusterSize; i++) { - int y = world.getActualHeight() - 1; - while (world.isAirBlock(new BlockPos(x, y, z)) && y > 0) { - y--; - } treeGenerator.generate(world, random, new BlockPos(x, 72, z)); - x += random.nextInt(16) - 8; - z += random.nextInt(16) - 8; } - } retroGen.markChunk(ChunkCoord.of(chunkX, chunkZ)); }