Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-10 05:20:04 +01:00
Added Region.shift
- Provided a default implementation using expand+contract in AbstractRegion - Overrid the implementation in the subtypes
Dieser Commit ist enthalten in:
Ursprung
4d708a5003
Commit
3a828c9759
@ -407,10 +407,9 @@ public class SelectionCommands {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
region.expand(dir.multiply(change));
|
region.shift(dir.multiply(change));
|
||||||
region.contract(dir.multiply(change));
|
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||||
|
|
||||||
player.print("Region shifted.");
|
player.print("Region shifted.");
|
||||||
|
@ -4,6 +4,7 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
public abstract class AbstractRegion implements Region {
|
public abstract class AbstractRegion implements Region {
|
||||||
/**
|
/**
|
||||||
@ -31,4 +32,9 @@ public abstract class AbstractRegion implements Region {
|
|||||||
public void setWorld(LocalWorld world) {
|
public void setWorld(LocalWorld world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shift(Vector change) throws RegionOperationException {
|
||||||
|
expand(change);
|
||||||
|
contract(change);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,8 +184,7 @@ public class CuboidRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pos1 = pos1.clampY(0, world == null ? 127 : world.getMaxY());
|
recalculate();
|
||||||
pos2 = pos2.clampY(0, world == null ? 127 : world.getMaxY());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,10 +235,22 @@ public class CuboidRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recalculate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recalculate() {
|
||||||
pos1 = pos1.clampY(0, world == null ? 127 : world.getMaxY());
|
pos1 = pos1.clampY(0, world == null ? 127 : world.getMaxY());
|
||||||
pos2 = pos2.clampY(0, world == null ? 127 : world.getMaxY());
|
pos2 = pos2.clampY(0, world == null ? 127 : world.getMaxY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shift(Vector change) throws RegionOperationException {
|
||||||
|
pos1 = pos1.add(change);
|
||||||
|
pos2 = pos2.add(change);
|
||||||
|
|
||||||
|
recalculate();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get position 1.
|
* Get position 1.
|
||||||
*
|
*
|
||||||
|
@ -136,6 +136,11 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
public void contract(Vector change) {
|
public void contract(Vector change) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shift(Vector change) throws RegionOperationException {
|
||||||
|
center = center.add(change);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the center.
|
* Get the center.
|
||||||
*
|
*
|
||||||
|
@ -302,6 +302,23 @@ public class Polygonal2DRegion extends AbstractRegion {
|
|||||||
recalculate();
|
recalculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void shift(Vector change) throws RegionOperationException {
|
||||||
|
final double changeX = change.getX();
|
||||||
|
final double changeY = change.getY();
|
||||||
|
final double changeZ = change.getZ();
|
||||||
|
|
||||||
|
for (int i = 0; i < points.size(); ++i) {
|
||||||
|
BlockVector2D point = points.get(i);
|
||||||
|
points.set(i, new BlockVector2D(point.getX() + changeX, point.getZ() + changeZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
minY += changeY;
|
||||||
|
maxY += changeY;
|
||||||
|
|
||||||
|
recalculate();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if a point is inside this region.
|
* Checks to see if a point is inside this region.
|
||||||
*/
|
*/
|
||||||
|
@ -88,6 +88,14 @@ public interface Region extends Iterable<BlockVector> {
|
|||||||
*/
|
*/
|
||||||
public void contract(Vector change) throws RegionOperationException;
|
public void contract(Vector change) throws RegionOperationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shift the region.
|
||||||
|
*
|
||||||
|
* @param change
|
||||||
|
* @throws RegionOperationException
|
||||||
|
*/
|
||||||
|
public void shift(Vector multiply) throws RegionOperationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true based on whether the region contains the point,
|
* Returns true based on whether the region contains the point,
|
||||||
*
|
*
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren