From abe2026ffa08ae5d7d2edd59628cb599c1ec3b23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien?= <43724816+Aurelien30000@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:50:53 +0200 Subject: [PATCH] Fix scanner brush height logic & typos (#306) --- .../voxelsniper/brush/type/AbstractBrush.java | 2 +- .../voxelsniper/brush/type/ScannerBrush.java | 25 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/thevoxelbox/voxelsniper/brush/type/AbstractBrush.java b/src/main/java/com/thevoxelbox/voxelsniper/brush/type/AbstractBrush.java index 4a80188c..b662e9f2 100644 --- a/src/main/java/com/thevoxelbox/voxelsniper/brush/type/AbstractBrush.java +++ b/src/main/java/com/thevoxelbox/voxelsniper/brush/type/AbstractBrush.java @@ -109,7 +109,7 @@ public void perform( public int clampY(int y) { int clampedY = y; int minHeight = editSession.getMinY(); - if (clampedY <= minHeight) { + if (clampedY < minHeight) { clampedY = minHeight; } else { int maxHeight = editSession.getMaxY(); diff --git a/src/main/java/com/thevoxelbox/voxelsniper/brush/type/ScannerBrush.java b/src/main/java/com/thevoxelbox/voxelsniper/brush/type/ScannerBrush.java index f24eae2c..70f6be81 100644 --- a/src/main/java/com/thevoxelbox/voxelsniper/brush/type/ScannerBrush.java +++ b/src/main/java/com/thevoxelbox/voxelsniper/brush/type/ScannerBrush.java @@ -99,7 +99,7 @@ private void scan(Snipe snipe, Direction blockFace) { if (blockFace == Direction.NORTH) { // Scan south for (int i = 1; i < this.depth + 1; i++) { if (getBlockType(targetBlock.getX(), clampY(targetBlock.getY()), targetBlock.getZ() + i) == this.checkFor) { - messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.fond", this.checkFor.getId(), i)); + messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.found", this.checkFor.getId(), i)); return; } } @@ -107,7 +107,7 @@ private void scan(Snipe snipe, Direction blockFace) { } else if (blockFace == Direction.SOUTH) { // Scan north for (int i = 1; i < this.depth + 1; i++) { if (getBlockType(targetBlock.getX(), clampY(targetBlock.getY()), targetBlock.getZ() - i) == this.checkFor) { - messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.fond", this.checkFor.getId(), i)); + messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.found", this.checkFor.getId(), i)); return; } } @@ -115,7 +115,7 @@ private void scan(Snipe snipe, Direction blockFace) { } else if (blockFace == Direction.EAST) { // Scan west for (int i = 1; i < this.depth + 1; i++) { if (getBlockType(targetBlock.getX() - i, clampY(targetBlock.getY()), targetBlock.getZ()) == this.checkFor) { - messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.fond", this.checkFor.getId(), i)); + messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.found", this.checkFor.getId(), i)); return; } } @@ -123,30 +123,25 @@ private void scan(Snipe snipe, Direction blockFace) { } else if (blockFace == Direction.WEST) { // Scan east for (int i = 1; i < this.depth + 1; i++) { if (getBlockType(targetBlock.getX() + i, clampY(targetBlock.getY()), targetBlock.getZ()) == this.checkFor) { - messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.fond", this.checkFor.getId(), i)); + messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.found", this.checkFor.getId(), i)); return; } } messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.not-found")); } else if (blockFace == Direction.UP) { // Scan down - for (int i = 1; i < this.depth + 1; i++) { - if ((targetBlock.getY() - i) <= getEditSession().getMinY()) { - break; - } + EditSession editSession = getEditSession(); + for (int i = 1; i < this.depth + 1 && targetBlock.getY() + i >= editSession.getMinY(); i++) { if (getBlockType(targetBlock.getX(), clampY(targetBlock.getY() - i), targetBlock.getZ()) == this.checkFor) { - messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.fond", this.checkFor.getId(), i)); + messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.found", this.checkFor.getId(), i)); return; } } messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.not-found")); } else if (blockFace == Direction.DOWN) { // Scan up - for (int i = 1; i < this.depth + 1; i++) { - EditSession editSession = getEditSession(); - if ((targetBlock.getY() + i) >= editSession.getMaxY()) { - break; - } + EditSession editSession = getEditSession(); + for (int i = 1; i < this.depth + 1 && targetBlock.getY() + i <= editSession.getMaxY(); i++) { if (getBlockType(targetBlock.getX(), clampY(targetBlock.getY() + i), targetBlock.getZ()) == this.checkFor) { - messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.fond", this.checkFor.getId(), i)); + messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.found", this.checkFor.getId(), i)); return; } }