3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-24 18:10:08 +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:
TomyLobo 2012-01-03 16:13:50 +01:00
Ursprung 4d708a5003
Commit 3a828c9759
6 geänderte Dateien mit 51 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -407,10 +407,9 @@ public class SelectionCommands {
try {
Region region = session.getSelection(player.getWorld());
region.expand(dir.multiply(change));
region.contract(dir.multiply(change));
region.shift(dir.multiply(change));
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
player.print("Region shifted.");

Datei anzeigen

@ -4,6 +4,7 @@ import java.util.Iterator;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.Vector;
public abstract class AbstractRegion implements Region {
/**
@ -31,4 +32,9 @@ public abstract class AbstractRegion implements Region {
public void setWorld(LocalWorld world) {
this.world = world;
}
public void shift(Vector change) throws RegionOperationException {
expand(change);
contract(change);
}
}

Datei anzeigen

@ -184,8 +184,7 @@ public class CuboidRegion extends AbstractRegion {
}
}
pos1 = pos1.clampY(0, world == null ? 127 : world.getMaxY());
pos2 = pos2.clampY(0, world == null ? 127 : world.getMaxY());
recalculate();
}
/**
@ -236,10 +235,22 @@ public class CuboidRegion extends AbstractRegion {
}
}
recalculate();
}
private void recalculate() {
pos1 = pos1.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.
*

Datei anzeigen

@ -136,6 +136,11 @@ public class EllipsoidRegion extends AbstractRegion {
public void contract(Vector change) {
}
@Override
public void shift(Vector change) throws RegionOperationException {
center = center.add(change);
}
/**
* Get the center.
*

Datei anzeigen

@ -302,6 +302,23 @@ public class Polygonal2DRegion extends AbstractRegion {
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.
*/

Datei anzeigen

@ -88,6 +88,14 @@ public interface Region extends Iterable<BlockVector> {
*/
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,
*