mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Ellipsoid-based region selectors no longer starts primary at (0, 0, 0).
Fixes WORLDEDIT-2968.
This commit is contained in:
parent
7283526123
commit
66a51636a3
@ -41,6 +41,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||||
|
|
||||||
protected EllipsoidRegion region;
|
protected EllipsoidRegion region;
|
||||||
|
protected boolean started = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new selector.
|
* Create a new selector.
|
||||||
@ -113,11 +114,17 @@ public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.Ellipso
|
|||||||
|
|
||||||
region.setCenter(pos.toBlockVector());
|
region.setCenter(pos.toBlockVector());
|
||||||
region.setRadius(new Vector());
|
region.setRadius(new Vector());
|
||||||
|
started = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean selectSecondary(Vector pos) {
|
public boolean selectSecondary(Vector pos) {
|
||||||
|
if (!started) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final Vector diff = pos.subtract(region.getCenter());
|
final Vector diff = pos.subtract(region.getCenter());
|
||||||
final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0));
|
final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0));
|
||||||
region.extendRadius(minRadius);
|
region.extendRadius(minRadius);
|
||||||
@ -153,7 +160,7 @@ public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.Ellipso
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDefined() {
|
public boolean isDefined() {
|
||||||
return region.getRadius().lengthSq() > 0;
|
return started && region.getRadius().lengthSq() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,6 +80,10 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean selectSecondary(Vector pos) {
|
public boolean selectSecondary(Vector pos) {
|
||||||
|
if (!started) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
final double radiusScalar = Math.ceil(pos.distance(region.getCenter()));
|
final double radiusScalar = Math.ceil(pos.distance(region.getCenter()));
|
||||||
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user