Brushes target solid blocks

This commit is contained in:
Jesse Boyd 2017-04-21 04:43:27 +10:00
parent 36a093eb5f
commit ac5d5de394
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -34,6 +34,7 @@ import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.TargetBlock;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.annotation.Nullable;
@ -244,7 +245,7 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
public Vector getPosition(EditSession editSession, Player player) {
switch (targetMode) {
case TARGET_BLOCK_RANGE:
return new MutableBlockVector(player.getBlockTrace(getRange(), true));
return new MutableBlockVector(trace(player, getRange(), true));
case FOWARD_POINT_PITCH: {
int d = 0;
Location loc = player.getLocation();
@ -268,15 +269,20 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
}
}
final int distance = (height - y) + 8;
return new MutableBlockVector(player.getBlockTrace(distance, true));
return new MutableBlockVector(trace(player, distance, true));
}
case TARGET_FACE_RANGE:
return new MutableBlockVector(player.getBlockTraceFace(getRange(), true));
return new MutableBlockVector(trace(player, getRange(), true));
default:
return null;
}
}
private Vector trace(Player player, int range, boolean useLastBlock) {
TargetBlock tb = new TargetBlock(player, range, 0.2);
return (useLastBlock ? tb.getSolidTargetBlock() : tb.getTargetBlock());
}
public boolean act(BrushAction action, Platform server, LocalConfiguration config, Player player, LocalSession session) {
switch (action) {
case PRIMARY: