Package com.sk89q.worldedit.util
Class TargetBlock
java.lang.Object
com.sk89q.worldedit.util.TargetBlock
- Direct Known Subclasses:
MaskedTargetBlock
This class uses an inefficient method to figure out what block a player
is looking towards.
Originally written by toi. It was ported to WorldEdit and trimmed down by sk89q. Thanks to Raphfrk for optimization of toi's original class.
-
Constructor Summary
ConstructorDescriptionTargetBlock
(Player player) Constructor requiring a player, uses default values.TargetBlock
(Player player, int maxDistance, double checkDistance) Constructor requiring a player, max distance and a checking distance.TargetBlock
(Player player, Extent extent, int maxDistance, double checkDistance) -
Method Summary
Modifier and TypeMethodDescriptionReturns any block at the sight.Returns the current block along the line of vision.Get next block.Returns the previous block in the aimed path.Returns the block at the sight.Returns the block at the sight.void
setSolidMask
(Mask solidMask) Set the mask used for determine where to stop solid block traces.void
setStopMask
(Mask stopMask) Set the mask used for determine where to stop traces.
-
Constructor Details
-
TargetBlock
Constructor requiring a player, uses default values.- Parameters:
player
- player to work with
-
TargetBlock
Constructor requiring a player, max distance and a checking distance.- Parameters:
player
- Player to work withmaxDistance
- how far it checks for blockscheckDistance
- how often to check for blocks, the smaller the more precise
-
TargetBlock
-
-
Method Details
-
setStopMask
Set the mask used for determine where to stop traces. Setting to null will restore the default.- Parameters:
stopMask
- the mask used to stop traces
-
setSolidMask
Set the mask used for determine where to stop solid block traces. Setting to null will restore the default.- Parameters:
solidMask
- the mask used to stop solid block traces
-
getAnyTargetBlock
Returns any block at the sight. Returns null if out of range or if no viable target was found. Will try to return the last valid air block it finds.- Returns:
- Block
-
getTargetBlock
Returns the block at the sight. Returns null if out of range or if no viable target was found- Returns:
- Block
-
getSolidTargetBlock
Returns the block at the sight. Returns null if out of range or if no viable target was found- Returns:
- Block
-
getNextBlock
Get next block.- Returns:
- next block position
-
getCurrentBlock
Returns the current block along the line of vision.- Returns:
- block position
-
getPreviousBlock
Returns the previous block in the aimed path.- Returns:
- block position
-
getAnyTargetBlockFace
-
getTargetBlockFace
-