Stop worldgen chunk generation runaway from rubber trees

This commit is contained in:
mezz 2017-02-16 18:22:28 -08:00
parent 385f28a5b7
commit 5c13230c42
2 changed files with 9 additions and 26 deletions

View file

@ -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;
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--;
}
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;
while (worldIn.isAirBlock(new BlockPos(x, y, z)) && y > 0) {
y--;
}
return growTree(worldIn, rand, x, y + 1, z);
}
return false;

View file

@ -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));
}