mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-28 21:56:33 +01:00
Should probably limit the size, also...
If you want to select some cavity, just use `//sel fuzzy` and `//pos1` while standing there
This commit is contained in:
parent
79041d7671
commit
0a3a1c813d
@ -19,6 +19,7 @@ import com.sk89q.worldedit.IncompleteRegionException;
|
|||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
@ -113,6 +114,12 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
try {
|
try {
|
||||||
run.run();
|
run.run();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
while (e.getCause() != null) {
|
||||||
|
e = e.getCause();
|
||||||
|
}
|
||||||
|
if (e instanceof WorldEditException) {
|
||||||
|
sendMessage(BBC.getPrefix() + e.getLocalizedMessage());
|
||||||
|
} else {
|
||||||
FaweException fe = FaweException.get(e);
|
FaweException fe = FaweException.get(e);
|
||||||
if (fe != null) {
|
if (fe != null) {
|
||||||
sendMessage(fe.getMessage());
|
sendMessage(fe.getMessage());
|
||||||
@ -120,6 +127,7 @@ public abstract class FawePlayer<T> extends Metadatable {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
runningCount.decrementAndGet();
|
runningCount.decrementAndGet();
|
||||||
Runnable next = getActions().poll();
|
Runnable next = getActions().poll();
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
|
@ -24,6 +24,7 @@ public class FuzzyRegion extends AbstractRegion {
|
|||||||
private int minX, minY, minZ, maxX, maxY, maxZ;
|
private int minX, minY, minZ, maxX, maxY, maxZ;
|
||||||
private int offsetX, offsetY, offsetZ;
|
private int offsetX, offsetY, offsetZ;
|
||||||
private Extent extent;
|
private Extent extent;
|
||||||
|
private int count = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
minX = minY = minZ = Integer.MAX_VALUE;
|
minX = minY = minZ = Integer.MAX_VALUE;
|
||||||
@ -56,7 +57,7 @@ public class FuzzyRegion extends AbstractRegion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getArea() {
|
public int getArea() {
|
||||||
return set.length();
|
return set.cardinality();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void select(int x, int y, int z) {
|
public void select(int x, int y, int z) {
|
||||||
@ -123,6 +124,9 @@ public class FuzzyRegion extends AbstractRegion {
|
|||||||
|
|
||||||
public void set(int x, int y, int z) throws RegionOperationException{
|
public void set(int x, int y, int z) throws RegionOperationException{
|
||||||
if (populated) {
|
if (populated) {
|
||||||
|
if (++count > 1048576) {
|
||||||
|
throw new RegionOperationException("Selection is too large! (1048576 blocks)");
|
||||||
|
}
|
||||||
x -= offsetX;
|
x -= offsetX;
|
||||||
y -= offsetY;
|
y -= offsetY;
|
||||||
z -= offsetZ;
|
z -= offsetZ;
|
||||||
@ -135,7 +139,7 @@ public class FuzzyRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
set.set(pair(x, y, z), true);
|
set.set(pair(x, y, z), true);
|
||||||
if (x >= 1024 || x <= -1024 || z >= 1024 || z <= -1024) {
|
if (x >= 1024 || x <= -1024 || z >= 1024 || z <= -1024) {
|
||||||
throw new RegionOperationException("Selection is too large!");
|
throw new RegionOperationException("Selection is too large! (1024 blocks wide)");
|
||||||
}
|
}
|
||||||
if (x > maxX) {
|
if (x > maxX) {
|
||||||
maxX = x;
|
maxX = x;
|
||||||
|
@ -342,10 +342,10 @@ public class PlatformManager {
|
|||||||
public void handleBlockInteract(BlockInteractEvent event) {
|
public void handleBlockInteract(BlockInteractEvent event) {
|
||||||
// Create a proxy actor with a potentially different world for
|
// Create a proxy actor with a potentially different world for
|
||||||
// making changes to the world
|
// making changes to the world
|
||||||
Actor actor = createProxyActor(event.getCause());
|
final Actor actor = createProxyActor(event.getCause());
|
||||||
try {
|
try {
|
||||||
final Location location = event.getLocation();
|
final Location location = event.getLocation();
|
||||||
Vector vector = location.toVector();
|
final Vector vector = location.toVector();
|
||||||
|
|
||||||
// At this time, only handle interaction from players
|
// At this time, only handle interaction from players
|
||||||
if (actor instanceof Player) {
|
if (actor instanceof Player) {
|
||||||
@ -362,11 +362,16 @@ public class PlatformManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
final RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
|
FawePlayer<?> fp = FawePlayer.wrap(player);
|
||||||
|
fp.runAction(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
|
if (selector.selectPrimary(location.toVector(), ActorSelectorLimits.forActor(player))) {
|
||||||
selector.explainPrimarySelection(actor, session, vector);
|
selector.explainPrimarySelection(actor, session, vector);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, true, true);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -407,11 +412,16 @@ public class PlatformManager {
|
|||||||
if (!actor.hasPermission("worldedit.selection.pos")) {
|
if (!actor.hasPermission("worldedit.selection.pos")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
final RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
FawePlayer<?> fp = FawePlayer.wrap(player);
|
||||||
|
fp.runAction(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
|
if (selector.selectSecondary(vector, ActorSelectorLimits.forActor(player))) {
|
||||||
selector.explainSecondarySelection(actor, session, vector);
|
selector.explainSecondarySelection(actor, session, vector);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, true, true);
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user