From b87f708c2871b8b1be36f0c9ec6f44ab715c5d28 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 8 Feb 2022 10:41:06 +0100 Subject: [PATCH] Update CreatingInnerBlocksState Signed-off-by: yoyosource --- .../features/slaves/laufbau/Laufbau.java | 8 +++++ .../states/CreatingInnerBlocksState.java | 29 ++----------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java index d9ba482f..471d58d4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/Laufbau.java @@ -76,6 +76,14 @@ public class Laufbau { } return -Double.compare(o1.volume(), o2.volume()); }); + } else { + elements.sort((o1, o2) -> { + int compared = Double.compare(o1.volume(), o2.volume()); + if (compared != 0) { + return -compared; + } + return -Double.compare(o1.blockData.getMaterial().getBlastResistance(), o2.blockData.getMaterial().getBlastResistance()); + }); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java index f5c1251f..0dd34d87 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/CreatingInnerBlocksState.java @@ -76,16 +76,8 @@ public class CreatingInnerBlocksState implements LaufbauState { for (BlockBoundingBox blockDataWithBoundingBox : elements) { List cuboids = blockDataWithBoundingBox.getCuboidList().stream().map(c -> c.add(point)).collect(Collectors.toList()); - /* - List extendedCuboids = null; - if (cuboids.stream().anyMatch(cuboid -> cuboid.getDy() > 1)) { - extendedCuboids = cuboidList; - } - - */ - boolean isInCuboid = false; - for (Cuboid cuboid : /*extendedCuboids == null ? neededCuboids : extendedCuboids*/ neededCuboids) { + for (Cuboid cuboid : neededCuboids) { if (cuboids.stream().anyMatch(cuboid::intersects)) { isInCuboid = true; break; @@ -93,9 +85,7 @@ public class CreatingInnerBlocksState implements LaufbauState { } if (!isInCuboid) { blockDataWithBoundingBoxList.add(blockDataWithBoundingBox); - if (preferingBlastResistance) { - break; - } + break; } } if (blockDataWithBoundingBoxList.isEmpty()) { @@ -103,21 +93,6 @@ public class CreatingInnerBlocksState implements LaufbauState { } BlockBoundingBox highest = blockDataWithBoundingBoxList.get(0); - - if (!preferingBlastResistance) { - for (BlockBoundingBox blockDataWithBoundingBox : blockDataWithBoundingBoxList) { - if (highest.volume() < blockDataWithBoundingBox.volume()) { - highest = blockDataWithBoundingBox; - } - if (preferingBlastResistance) { - if (highest.blockData.getMaterial().getBlastResistance() < blockDataWithBoundingBox.blockData.getMaterial().getBlastResistance()) { - if (highest.volume() > blockDataWithBoundingBox.volume()) { - highest = blockDataWithBoundingBox; - } - } - } - } - } Location location = new Location(world, point.getX(), point.getY(), point.getZ()); if (!location.getBlock().getType().isAir()) { return;