Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-10 05:20:04 +01:00
//sel poly now keeps the previous selection, converting its outline into a polygon if necessary.
This loses some blocks, if anyone cares
Dieser Commit ist enthalten in:
Ursprung
76fd63d64b
Commit
7d503fdc5c
@ -616,7 +616,7 @@ public class SelectionCommands {
|
||||
selector = new ExtendingCuboidRegionSelector(oldSelector);
|
||||
player.print("Cuboid: left click for a starting point, right click to extend");
|
||||
} else if (typeName.equalsIgnoreCase("poly")) {
|
||||
selector = new Polygonal2DRegionSelector(world);
|
||||
selector = new Polygonal2DRegionSelector(oldSelector);
|
||||
player.print("2D polygon selector: Left/right click to add a point.");
|
||||
} else {
|
||||
player.printError("Only 'cuboid', 'extend' and 'poly' are accepted.");
|
||||
|
@ -39,17 +39,17 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
|
||||
protected BlockVector pos1;
|
||||
protected BlockVector pos2;
|
||||
protected CuboidRegion region;
|
||||
|
||||
|
||||
public CuboidRegionSelector(LocalWorld world) {
|
||||
region = new CuboidRegion(world, new Vector(), new Vector());
|
||||
}
|
||||
|
||||
public CuboidRegionSelector() {
|
||||
this((LocalWorld)null);
|
||||
this((LocalWorld) null);
|
||||
}
|
||||
|
||||
public CuboidRegionSelector(RegionSelector oldSelector) {
|
||||
region = new CuboidRegion(oldSelector.getIncompleteRegion().getWorld(), new Vector(), new Vector());
|
||||
this(oldSelector.getIncompleteRegion().getWorld());
|
||||
if (oldSelector instanceof CuboidRegionSelector) {
|
||||
final CuboidRegionSelector cuboidRegionSelector = (CuboidRegionSelector) oldSelector;
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class Polygonal2DRegion implements Region {
|
||||
* Construct the region
|
||||
*/
|
||||
public Polygonal2DRegion() {
|
||||
this(null);
|
||||
this((LocalWorld) null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,6 +84,11 @@ public class Polygonal2DRegion implements Region {
|
||||
recalculate();
|
||||
}
|
||||
|
||||
public Polygonal2DRegion(Polygonal2DRegion region) {
|
||||
this(region.world, region.points, region.minY, region.maxY);
|
||||
hasY = region.hasY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of points.
|
||||
*
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
@ -41,11 +42,44 @@ import com.sk89q.worldedit.cui.SelectionShapeEvent;
|
||||
public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedRegion {
|
||||
protected BlockVector pos1;
|
||||
protected Polygonal2DRegion region;
|
||||
|
||||
|
||||
public Polygonal2DRegionSelector(LocalWorld world) {
|
||||
region = new Polygonal2DRegion(world);
|
||||
}
|
||||
|
||||
public Polygonal2DRegionSelector(RegionSelector oldSelector) {
|
||||
this(oldSelector.getIncompleteRegion().getWorld());
|
||||
if (oldSelector instanceof Polygonal2DRegionSelector) {
|
||||
final Polygonal2DRegionSelector polygonal2DRegionSelector = (Polygonal2DRegionSelector) oldSelector;
|
||||
|
||||
pos1 = polygonal2DRegionSelector.pos1;
|
||||
region = new Polygonal2DRegion(polygonal2DRegionSelector.region);
|
||||
} else {
|
||||
final Region oldRegion;
|
||||
try {
|
||||
oldRegion = oldSelector.getRegion();
|
||||
} catch (IncompleteRegionException e) {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockVector min = oldRegion.getMinimumPoint().toBlockVector();
|
||||
BlockVector max = oldRegion.getMaximumPoint().toBlockVector();
|
||||
|
||||
int minY = min.getBlockY();
|
||||
int maxY = max.getBlockY();
|
||||
|
||||
List<BlockVector2D> points = new ArrayList<BlockVector2D>(4);
|
||||
|
||||
points.add(new BlockVector2D(min.getX(), min.getZ()));
|
||||
points.add(new BlockVector2D(min.getX(), max.getZ()));
|
||||
points.add(new BlockVector2D(max.getX(), max.getZ()));
|
||||
points.add(new BlockVector2D(max.getX(), min.getZ()));
|
||||
|
||||
pos1 = min;
|
||||
region = new Polygonal2DRegion(oldRegion.getWorld(), points, minY, maxY);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean selectPrimary(Vector pos) {
|
||||
if (pos.equals(pos1)) {
|
||||
return false;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren