mirror of https://github.com/cabaletta/baritone
appease codacy
This commit is contained in:
parent
0d14bde583
commit
34abbfb5da
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -388,11 +388,12 @@ public class SelCommand extends Command {
|
|||
return new CylinderSchematic(fill, true);
|
||||
case HCYLINDER:
|
||||
return new CylinderSchematic(fill, false);
|
||||
}
|
||||
default:
|
||||
// Silent fail
|
||||
return fill;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum TransformTarget {
|
||||
ALL(sels -> sels, "all", "a"),
|
||||
|
|
Loading…
Reference in New Issue