tweaks to bushes

This commit is contained in:
dags- 2020-06-20 15:07:22 +01:00
parent bc89e7ebb9
commit 0423925e17
3 changed files with 21 additions and 5 deletions

View File

@ -67,12 +67,16 @@ public class BushFeature extends Feature<BushFeature.Config> {
}
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,12 +87,24 @@ public class BushFeature extends Feature<BushFeature.Config> {
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);
if (!BlockUtils.isSolid(world, pos)) {
world.setBlockState(pos, config.leaves, 2);
}
}
}
}
return true;
}

View File

@ -35,7 +35,7 @@
"name": "minecraft:count_extra_heightmap",
"config": {
"count": 0,
"extra_chance": 0.2,
"extra_chance": 0.125,
"extra_count": 1
}
}

View File

@ -37,7 +37,7 @@
"name": "minecraft:count_extra_heightmap",
"config": {
"count": 0,
"extra_chance": 0.12,
"extra_chance": 0.125,
"extra_count": 1
}
}