Class TargetBlock

java.lang.Object
com.sk89q.worldedit.util.TargetBlock
Direct Known Subclasses:
MaskedTargetBlock

public class TargetBlock extends Object
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 Details

    • TargetBlock

      public TargetBlock(Player player)
      Constructor requiring a player, uses default values.
      Parameters:
      player - player to work with
    • TargetBlock

      public TargetBlock(Player player, int maxDistance, double checkDistance)
      Constructor requiring a player, max distance and a checking distance.
      Parameters:
      player - Player to work with
      maxDistance - how far it checks for blocks
      checkDistance - how often to check for blocks, the smaller the more precise
    • TargetBlock

      public TargetBlock(Player player, Extent extent, int maxDistance, double checkDistance)
  • Method Details

    • setStopMask

      public void setStopMask(@Nullable Mask stopMask)
      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

      public void setSolidMask(@Nullable Mask solidMask)
      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

      public Location 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

      public Location getTargetBlock()
      Returns the block at the sight. Returns null if out of range or if no viable target was found
      Returns:
      Block
    • getSolidTargetBlock

      public Location getSolidTargetBlock()
      Returns the block at the sight. Returns null if out of range or if no viable target was found
      Returns:
      Block
    • getNextBlock

      public Location getNextBlock()
      Get next block.
      Returns:
      next block position
    • getCurrentBlock

      public Location getCurrentBlock()
      Returns the current block along the line of vision.
      Returns:
      block position
    • getPreviousBlock

      public Location getPreviousBlock()
      Returns the previous block in the aimed path.
      Returns:
      block position
    • getAnyTargetBlockFace

      public Location getAnyTargetBlockFace()
    • getTargetBlockFace

      public Location getTargetBlockFace()