From 5a5a59305a50c89c51a197e3bcc641970dcbf39a Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 2 May 2021 16:37:23 +0200 Subject: [PATCH] Optimize Depth --- .../features/testblock/depthcounter/Depth.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/Depth.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/Depth.java index 1a50ce3f..b8753a34 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/Depth.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/depthcounter/Depth.java @@ -62,7 +62,7 @@ public class Depth { dimensions.setY(Math.abs(dimensions.getY())); dimensions.setZ(Math.abs(dimensions.getZ())); - if (dimensions.getX() != 0 && dimensions.getY() != 0 && dimensions.getZ() != 0) { + if (tntCount > 4 && dimensions.getX() != 0 && dimensions.getY() != 0 && dimensions.getZ() != 0) { RegionUtils.message(region, player -> DepthCounter.getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount)); } @@ -79,7 +79,7 @@ public class Depth { } public boolean update(List blocks) { - long overlappingBlocks = blocks.stream().filter(block -> { + long totalBlastResistanceBroken = blocks.stream().filter(block -> { Vector vector = DepthCounter.blockVector(block.getLocation().toVector()); return vector.getX() >= minVector.getX() && vector.getY() >= minVector.getY() @@ -87,8 +87,10 @@ public class Depth { && vector.getX() <= maxVector.getX() && vector.getY() <= maxVector.getY() && vector.getZ() <= maxVector.getZ(); - }).count(); - if (overlappingBlocks < 4) { + }).filter(block -> block.getType().isBlock()) + .mapToLong(block -> (long) (block.getType().getBlastResistance() * 100)) + .sum(); + if (totalBlastResistanceBroken < 1800) { return false; } lastUpdate = TPSUtils.currentTick.get();