Add /tracemask. (#474)

Allows setting a mask used for block traces. This allows brush tools to
pass through various materials, such as water (e.g. `/tracemask #solid`
or `/tracemask !air,water`) before starting to build.
By default, a null mask is equivalent to #existing (original behavior).

https://gfycat.com/ImmaculateFrayedCockatiel
This commit is contained in:
wizjany
2019-05-23 21:12:31 -04:00
committed by GitHub
parent d0ef56326a
commit 7b47d9a945
9 changed files with 150 additions and 37 deletions

View File

@ -23,6 +23,7 @@ import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
@ -41,6 +42,7 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import javax.annotation.Nullable;
import java.io.File;
/**
@ -323,13 +325,29 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
@Override
public Location getBlockTrace(int range, boolean useLastBlock) {
TargetBlock tb = new TargetBlock(this, range, 0.2);
return (useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock());
return getBlockTrace(range, useLastBlock, null);
}
@Override
public Location getBlockTraceFace(int range, boolean useLastBlock) {
return getBlockTraceFace(range, useLastBlock, null);
}
@Override
public Location getBlockTrace(int range, boolean useLastBlock, @Nullable Mask stopMask) {
TargetBlock tb = new TargetBlock(this, range, 0.2);
if (stopMask != null) {
tb.setStopMask(stopMask);
}
return (useLastBlock ? tb.getAnyTargetBlock() : tb.getTargetBlock());
}
@Override
public Location getBlockTraceFace(int range, boolean useLastBlock, @Nullable Mask stopMask) {
TargetBlock tb = new TargetBlock(this, range, 0.2);
if (stopMask != null) {
tb.setStopMask(stopMask);
}
return (useLastBlock ? tb.getAnyTargetBlockFace() : tb.getTargetBlockFace());
}