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.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Direction;
@ -210,6 +211,17 @@ public interface Player extends Entity, Actor {
*/
Location getBlockTrace(int range, boolean useLastBlock);
/**
* Get the point of the block being looked at. May return null.
* Will return the farthest away block before matching the stop mask if useLastBlock is true and no other block is found.
*
* @param range how far to checks for blocks
* @param useLastBlock try to return the last valid block not matching the stop mask found
* @param stopMask the mask used to determine when to stop tracing
* @return point
*/
Location getBlockTrace(int range, boolean useLastBlock, @Nullable Mask stopMask);
/**
* Get the face that the player is looking at.
*
@ -219,6 +231,16 @@ public interface Player extends Entity, Actor {
*/
Location getBlockTraceFace(int range, boolean useLastBlock);
/**
* Get the face that the player is looking at.
*
* @param range the range
* @param useLastBlock try to return the last valid block not matching the stop mask found
* @param stopMask the mask used to determine when to stop tracing
* @return a face
*/
Location getBlockTraceFace(int range, boolean useLastBlock, @Nullable Mask stopMask);
/**
* Get the point of the block being looked at. May return null.
*