From 24fad18bec41b69c9fb517e6a2ad5b007877ff39 Mon Sep 17 00:00:00 2001 From: dags- Date: Fri, 3 Apr 2020 22:00:39 +0100 Subject: [PATCH] better base flattening --- .../terraforged/mod/feature/TerrainHelper.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/TerrainHelper.java b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/TerrainHelper.java index 0aa7fa9..4dcab74 100644 --- a/TerraForgedMod/src/main/java/com/terraforged/mod/feature/TerrainHelper.java +++ b/TerraForgedMod/src/main/java/com/terraforged/mod/feature/TerrainHelper.java @@ -114,10 +114,10 @@ public class TerrainHelper { int level = pieceBounds.minY + piece.getGroundLevelDelta(); if (level > y) { y = raise(pieceBounds, pos.setPos(x, surface, z), level, y, borderRadius); - } else if (level < surface && pieceBounds.getYSize() > 4) { - if (highest == null) { - highest = piece; - } else if (highest.getBoundingBox().maxY < pieceBounds.maxY) { + } + + if (x > pieceBounds.minX && x < pieceBounds.maxX && z > pieceBounds.minZ && z < pieceBounds.maxZ) { + if (highest == null || pieceBounds.minY > highest.getBoundingBox().minY) { highest = piece; } } @@ -134,13 +134,11 @@ public class TerrainHelper { } } - if (highest != null && highest.getBoundingBox().minY < surface) { + if (highest != null) { MutableBoundingBox bounds = highest.getBoundingBox(); - if (x > bounds.minX && x < bounds.maxX && z > bounds.minZ && z < bounds.maxZ) { - for (int dy = bounds.minY + 1; dy <= surface; dy++) { - pos.setPos(dx, dy, dz); - chunk.setBlockState(pos, Blocks.AIR.getDefaultState(), false); - } + for (int dy = bounds.minY + highest.getGroundLevelDelta(); dy <= surface; dy++) { + pos.setPos(dx, dy, dz); + chunk.setBlockState(pos, Blocks.AIR.getDefaultState(), false); } } }