commanding-pipeline diff

This commit is contained in:
Jesse Boyd
2019-10-23 05:23:52 +01:00
parent fb91456bdd
commit 2080e9786b
193 changed files with 5449 additions and 3491 deletions

View File

@ -91,6 +91,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
}
protected static int MAX_RANGE = 500;
protected static int DEFAULT_RANGE = 240; // 500 is laggy as the default
protected int range = -1;
private VisualMode visualMode = VisualMode.NONE;
private TargetMode targetMode = TargetMode.TARGET_BLOCK_RANGE;
@ -177,7 +178,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (targetMode != TargetMode.TARGET_BLOCK_RANGE) {
map.put("target", targetMode);
}
if (range != -1 && range != MAX_RANGE) {
if (range != -1 && range != DEFAULT_RANGE) {
map.put("range", range);
}
if (targetOffset != 0) {
@ -408,7 +409,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
* @return the range of the brush in blocks
*/
public int getRange() {
return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE);
return (range < 0) ? DEFAULT_RANGE : Math.min(range, MAX_RANGE);
}
/**

View File

@ -74,8 +74,9 @@ public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
private Location getTarget(Player player) {
Location target;
Mask mask = getTraceMask();
if (this.range > -1) {
target = player.getBlockTrace(getRange(), true, mask);
int range = getRange();
if (range < MAX_RANGE) {
target = player.getBlockTrace(range, true, mask);
} else {
target = player.getBlockTrace(MAX_RANGE, false, mask);
}

View File

@ -26,30 +26,26 @@ import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.util.Location;
public class NavigationWand implements DoubleActionTraceTool {
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.jumpto.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
}
Location pos = player.getSolidBlockTrace(maxDist);
if (pos != null) {
player.findFreePosition(pos);
} else {
player.printError("No block in sight (or too far)!");
}
return true;
}
public enum NavigationWand implements DoubleActionTraceTool {
INSTANCE;
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
}
Location pos = player.getSolidBlockTrace(maxDist);
if (pos != null) {
player.findFreePosition(pos);
} else {
player.printError("No block in sight (or too far)!");
}
return true;
}
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session) {
if (!player.hasPermission("worldedit.navigation.thru.tool")) {
return false;
}
final int maxDist = config.navigationWandMaxDistance;
if (maxDist <= 0) {
return false;
@ -63,6 +59,6 @@ public class NavigationWand implements DoubleActionTraceTool {
@Override
public boolean canUse(Actor actor) {
return true; // skip check here - checked separately for primary/secondary
return actor.hasPermission("worldedit.navigation.jumpto.tool"); // check should be here
}
}

View File

@ -29,7 +29,8 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.RegionSelector;
import com.sk89q.worldedit.util.Location;
public class SelectionWand implements DoubleActionBlockTool {
public enum SelectionWand implements DoubleActionBlockTool {
INSTANCE;
@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {

View File

@ -34,4 +34,4 @@ public class SphereBrush implements Brush {
}
editSession.makeSphere(position, pattern, size, size, size, true);
}
}
}