From 34abbfb5daced3623e9a2a17da8018042980d758 Mon Sep 17 00:00:00 2001 From: Brady Date: Wed, 7 Jun 2023 17:38:26 -0500 Subject: [PATCH] appease codacy --- .../api/schematic/CylinderSchematic.java | 19 +++++++------ .../api/schematic/SphereSchematic.java | 28 +++++++++++-------- .../baritone/command/defaults/SelCommand.java | 5 ++-- 3 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/api/java/baritone/api/schematic/CylinderSchematic.java b/src/api/java/baritone/api/schematic/CylinderSchematic.java index 3ba8bc9b8..75726348d 100644 --- a/src/api/java/baritone/api/schematic/CylinderSchematic.java +++ b/src/api/java/baritone/api/schematic/CylinderSchematic.java @@ -24,27 +24,30 @@ import net.minecraft.block.state.IBlockState; */ public class CylinderSchematic extends MaskSchematic { - private final double cx, cz, rx, rz; + private final double centerX; + private final double centerZ; + private final double radiusSqX; + private final double radiusSqZ; private final boolean filled; public CylinderSchematic(ISchematic schematic, boolean filled) { super(schematic); - this.cx = schematic.widthX() / 2.0; - this.cz = schematic.lengthZ() / 2.0; - this.rx = this.cx * this.cx; - this.rz = this.cz * this.cz; + this.centerX = schematic.widthX() / 2.0; + this.centerZ = schematic.lengthZ() / 2.0; + this.radiusSqX = this.centerX * this.centerX; + this.radiusSqZ = this.centerZ * this.centerZ; this.filled = filled; } @Override protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { - double dx = Math.abs((x + 0.5) - this.cx); - double dz = Math.abs((z + 0.5) - this.cz); + double dx = Math.abs((x + 0.5) - this.centerX); + double dz = Math.abs((z + 0.5) - this.centerZ); return !this.outside(dx, dz) && (this.filled || outside(dx + 1, dz) || outside(dx, dz + 1)); } private boolean outside(double dx, double dz) { - return dx * dx / this.rx + dz * dz / this.rz > 1; + return dx * dx / this.radiusSqX + dz * dz / this.radiusSqZ > 1; } } diff --git a/src/api/java/baritone/api/schematic/SphereSchematic.java b/src/api/java/baritone/api/schematic/SphereSchematic.java index 0ca987760..1cf0a579f 100644 --- a/src/api/java/baritone/api/schematic/SphereSchematic.java +++ b/src/api/java/baritone/api/schematic/SphereSchematic.java @@ -18,37 +18,41 @@ package baritone.api.schematic; import net.minecraft.block.state.IBlockState; -import net.minecraft.util.math.Vec3d; /** * @author Brady */ public class SphereSchematic extends MaskSchematic { - private final double cx, cy, cz, rx, ry, rz; + private final double centerX; + private final double centerY; + private final double centerZ; + private final double radiusSqX; + private final double radiusSqY; + private final double radiusSqZ; private final boolean filled; public SphereSchematic(ISchematic schematic, boolean filled) { super(schematic); - this.cx = schematic.widthX() / 2.0; - this.cy = schematic.heightY() / 2.0; - this.cz = schematic.lengthZ() / 2.0; - this.rx = this.cx * this.cx; - this.ry = this.cy * this.cy; - this.rz = this.cz * this.cz; + this.centerX = schematic.widthX() / 2.0; + this.centerY = schematic.heightY() / 2.0; + this.centerZ = schematic.lengthZ() / 2.0; + this.radiusSqX = this.centerX * this.centerX; + this.radiusSqY = this.centerY * this.centerY; + this.radiusSqZ = this.centerZ * this.centerZ; this.filled = filled; } @Override protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { - double dx = Math.abs((x + 0.5) - this.cx); - double dy = Math.abs((y + 0.5) - this.cy); - double dz = Math.abs((z + 0.5) - this.cz); + double dx = Math.abs((x + 0.5) - this.centerX); + double dy = Math.abs((y + 0.5) - this.centerY); + double dz = Math.abs((z + 0.5) - this.centerZ); return !this.outside(dx, dy, dz) && (this.filled || outside(dx + 1, dy, dz) || outside(dx, dy + 1, dz) || outside(dx, dy, dz + 1)); } private boolean outside(double dx,double dy, double dz) { - return dx * dx / this.rx + dy * dy / this.ry + dz * dz / this.rz > 1; + return dx * dx / this.radiusSqX + dy * dy / this.radiusSqY + dz * dz / this.radiusSqZ > 1; } } diff --git a/src/main/java/baritone/command/defaults/SelCommand.java b/src/main/java/baritone/command/defaults/SelCommand.java index dcdd05b74..40df5c294 100644 --- a/src/main/java/baritone/command/defaults/SelCommand.java +++ b/src/main/java/baritone/command/defaults/SelCommand.java @@ -388,9 +388,10 @@ public class SelCommand extends Command { return new CylinderSchematic(fill, true); case HCYLINDER: return new CylinderSchematic(fill, false); + default: + // Silent fail + return fill; } - // Silent fail - return fill; } }