Skip to content

Commit

Permalink
Fix scanner brush height logic & typos (IntellectualSites#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurelien30000 authored Oct 4, 2023
1 parent c6ba7a2 commit abe2026
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,54 +99,49 @@ 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;
}
}
messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.not-found"));
} 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;
}
}
messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.not-found"));
} 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;
}
}
messenger.sendMessage(Caption.of("voxelsniper.brush.scanner.not-found"));
} 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;
}
}
Expand Down

0 comments on commit abe2026

Please sign in to comment.