mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Add convenient constructors in *RegionSelector classes
This commit is contained in:
parent
1fef255d77
commit
77bc49e057
@ -71,6 +71,14 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
region.setPos2(pos2);
|
region.setPos2(pos2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CuboidRegionSelector(LocalWorld world, Vector pos1, Vector pos2) {
|
||||||
|
this(world);
|
||||||
|
this.pos1 = pos1.toBlockVector();
|
||||||
|
this.pos2 = pos2.toBlockVector();
|
||||||
|
region.setPos1(pos1);
|
||||||
|
region.setPos2(pos2);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean selectPrimary(Vector pos) {
|
public boolean selectPrimary(Vector pos) {
|
||||||
if (pos.equals(pos1)) {
|
if (pos.equals(pos1)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -79,6 +79,16 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CylinderRegionSelector(LocalWorld world, Vector2D center, Vector2D radius, int minY, int maxY) {
|
||||||
|
this(world);
|
||||||
|
|
||||||
|
region.setCenter(center);
|
||||||
|
region.setRadius(radius);
|
||||||
|
|
||||||
|
region.setMinimumY(Math.min(minY, maxY));
|
||||||
|
region.setMaximumY(Math.max(minY, maxY));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean selectPrimary(Vector pos) {
|
public boolean selectPrimary(Vector pos) {
|
||||||
if (!region.getCenter().equals(new Vector(0, 0, 0)) && pos.equals(region.getCenter())) {
|
if (!region.getCenter().equals(new Vector(0, 0, 0)) && pos.equals(region.getCenter())) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -70,6 +70,13 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EllipsoidRegionSelector(LocalWorld world, Vector center, Vector radius) {
|
||||||
|
this(world);
|
||||||
|
|
||||||
|
region.setCenter(center);
|
||||||
|
region.setRadius(radius);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean selectPrimary(Vector pos) {
|
public boolean selectPrimary(Vector pos) {
|
||||||
if (pos.equals(region.getCenter()) && region.getRadius().lengthSq() == 0) {
|
if (pos.equals(region.getCenter()) && region.getRadius().lengthSq() == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -48,6 +48,14 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
|||||||
region.setPos2(pos2);
|
region.setPos2(pos2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ExtendingCuboidRegionSelector(LocalWorld world, Vector pos1, Vector pos2) {
|
||||||
|
this(world);
|
||||||
|
pos1 = Vector.getMinimum(pos1, pos2);
|
||||||
|
pos2 = Vector.getMaximum(pos1, pos2);
|
||||||
|
region.setPos1(pos1);
|
||||||
|
region.setPos2(pos2);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean selectPrimary(Vector pos) {
|
public boolean selectPrimary(Vector pos) {
|
||||||
if (pos.equals(pos1) && pos.equals(pos2)) {
|
if (pos.equals(pos1) && pos.equals(pos2)) {
|
||||||
|
@ -45,6 +45,10 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
|||||||
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SphereRegionSelector(LocalWorld world, Vector center, int radius) {
|
||||||
|
super(world, center, new Vector(radius, radius, radius));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean selectSecondary(Vector pos) {
|
public boolean selectSecondary(Vector pos) {
|
||||||
final Vector diff = pos.subtract(region.getCenter());
|
final Vector diff = pos.subtract(region.getCenter());
|
||||||
|
Loading…
Reference in New Issue
Block a user