From 67ddc252aa84e94239a32d110dffafcf75215c9d Mon Sep 17 00:00:00 2001 From: mezz Date: Fri, 24 Jun 2016 16:50:01 -0700 Subject: [PATCH] Stop Balsa leaves from generating infinitely downwards --- .../arboriculture/worldgen/WorldGenBalsa.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java index 63b1d02a4..034591dd4 100755 --- a/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java +++ b/src/main/java/forestry/arboriculture/worldgen/WorldGenBalsa.java @@ -10,18 +10,14 @@ ******************************************************************************/ package forestry.arboriculture.worldgen; -import javax.annotation.Nonnull; -import java.util.Collections; import java.util.List; import java.util.Random; -import java.util.Set; - -import net.minecraft.util.EnumFacing; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; import forestry.api.world.ITreeGenData; import forestry.core.worldgen.WorldGenHelper; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public class WorldGenBalsa extends WorldGenTree { @@ -31,7 +27,8 @@ public class WorldGenBalsa extends WorldGenTree { @Override protected void generateLeaves(World world, Random rand, TreeBlockTypeLeaf leaf, List branchEnds, BlockPos startPos) { - BlockPos.MutableBlockPos leafCenter = new BlockPos.MutableBlockPos(startPos.add(0, height, 0)); + BlockPos topPos = startPos.add(0, height + 1, 0); + BlockPos.MutableBlockPos leafCenter = new BlockPos.MutableBlockPos(topPos); float leafRadius = (girth - 1.0f) / 2.0f; WorldGenHelper.addBlock(world, leafCenter, leaf, WorldGenHelper.EnumReplaceMode.AIR); @@ -44,7 +41,7 @@ public class WorldGenBalsa extends WorldGenTree { leafCenter.move(EnumFacing.DOWN); } - while (leafCenter.getY() > 6) { + while (leafCenter.getY() > topPos.getY() - 6) { WorldGenHelper.generateCylinderFromPos(world, leaf, leafCenter, leafRadius + girth, 1, WorldGenHelper.EnumReplaceMode.SOFT); leafCenter.move(EnumFacing.DOWN); }