From 0423925e17edde30ebc86a1960f8b24ae2794985 Mon Sep 17 00:00:00 2001 From: dags- Date: Sat, 20 Jun 2020 15:07:22 +0100 Subject: [PATCH] tweaks to bushes --- .../feature/feature/BushFeature.java | 22 ++++++++++++++++--- .../features/shrubs/cold_steppe_bush.json | 2 +- .../features/shrubs/steppe_bush.json | 2 +- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/terraforged/feature/feature/BushFeature.java b/src/main/java/com/terraforged/feature/feature/BushFeature.java index 6d70b7a..32ff7f4 100644 --- a/src/main/java/com/terraforged/feature/feature/BushFeature.java +++ b/src/main/java/com/terraforged/feature/feature/BushFeature.java @@ -67,12 +67,16 @@ public class BushFeature extends Feature { } private boolean place(IWorld world, BlockPos.Mutable center, BlockPos.Mutable pos, Random random, Config config) { - int y = world.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, center.getX(), center.getZ()); + center.setY(world.getHeight(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, center.getX(), center.getZ())); + + if (BlockUtils.isSolid(world, center)) { + return false; + } - center.setY(y); world.setBlockState(center, config.trunk, 2); for (Vec3i neighbour : leaves) { + // randomly skip NESW neighbours if (neighbour.getY() == 0 && random.nextFloat() < config.airChance) { continue; } @@ -83,9 +87,21 @@ public class BushFeature extends Feature { if (!BlockUtils.isSolid(world, pos)) { world.setBlockState(pos, config.leaves, 2); + // randomly place extra leaves below if non-solid + if (neighbour.getY() == 0 && random.nextFloat() < config.leafChance) { + pos.move(Direction.DOWN, 1); + if (!BlockUtils.isSolid(world, pos)) { + world.setBlockState(pos, config.leaves, 2); + } + pos.move(Direction.UP, 1); + } + + // randomly place extra leaves above if (neighbour.getY() == 0 && random.nextFloat() < config.leafChance) { pos.move(Direction.UP, 1); - world.setBlockState(pos, config.leaves, 2); + if (!BlockUtils.isSolid(world, pos)) { + world.setBlockState(pos, config.leaves, 2); + } } } } diff --git a/src/main/resources/data/terraforged/features/shrubs/cold_steppe_bush.json b/src/main/resources/data/terraforged/features/shrubs/cold_steppe_bush.json index 026f2c4..a7953b2 100644 --- a/src/main/resources/data/terraforged/features/shrubs/cold_steppe_bush.json +++ b/src/main/resources/data/terraforged/features/shrubs/cold_steppe_bush.json @@ -35,7 +35,7 @@ "name": "minecraft:count_extra_heightmap", "config": { "count": 0, - "extra_chance": 0.2, + "extra_chance": 0.125, "extra_count": 1 } } diff --git a/src/main/resources/data/terraforged/features/shrubs/steppe_bush.json b/src/main/resources/data/terraforged/features/shrubs/steppe_bush.json index 33b2dc7..c443734 100644 --- a/src/main/resources/data/terraforged/features/shrubs/steppe_bush.json +++ b/src/main/resources/data/terraforged/features/shrubs/steppe_bush.json @@ -37,7 +37,7 @@ "name": "minecraft:count_extra_heightmap", "config": { "count": 0, - "extra_chance": 0.12, + "extra_chance": 0.125, "extra_count": 1 } }