Class RayTraceResult

java.lang.Object
me.deecaad.core.utils.ray.RayTraceResult
Direct Known Subclasses:
BlockTraceResult, EntityTraceResult

public class RayTraceResult extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    RayTraceResult(@NotNull org.bukkit.util.Vector origin, @NotNull org.bukkit.util.Vector direction, @NotNull HitBox hitBox, @NotNull org.bukkit.block.BlockFace hitFace, @NotNull org.bukkit.block.BlockFace exitFace, double hitMin, double hitMax)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull org.bukkit.block.BlockFace
    Returns the exit face.
    @NotNull org.bukkit.util.Vector
    Returns the exact coordinates that the ray exits the hitbox, in world space.
    @NotNull HitBox
    Returns the that hitbox that was hit.
    @NotNull org.bukkit.block.BlockFace
    Returns the hit face.
    @NotNull org.bukkit.util.Vector
    Returns the exact coordinates that were hit, in world space.
    double
    Returns the distance between the origin and the furthest point of the hitbox.
    double
    Returns the distance between the origin of the ray and the hit location.
    double
    Same as getHitMin(), except this method will always return a positive number.
    org.bukkit.entity.Entity
    Deprecated.
    double
    Returns the distance travelled through the hitbox.
    void
    outlineOnlyHitPosition(org.bukkit.entity.Entity player)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RayTraceResult

      public RayTraceResult(@NotNull @NotNull org.bukkit.util.Vector origin, @NotNull @NotNull org.bukkit.util.Vector direction, @NotNull @NotNull HitBox hitBox, @NotNull @NotNull org.bukkit.block.BlockFace hitFace, @NotNull @NotNull org.bukkit.block.BlockFace exitFace, double hitMin, double hitMax)
  • Method Details

    • getHitBox

      @NotNull public @NotNull HitBox getHitBox()
      Returns the that hitbox that was hit.
      Returns:
      The hitbox.
    • getHitFace

      @NotNull public @NotNull org.bukkit.block.BlockFace getHitFace()
      Returns the hit face. Will be one of:
      • BlockFace.NORTH
      • BlockFace.EAST
      • BlockFace.SOUTH
      • BlockFace.WEST
      • BlockFace.UP
      • BlockFace.DOWN

      Even when the raytrace starts within the hitbox, this will return the hit face as if it were "moved back" before ray tracing. This means that you might want to check getHitMin() and check if it is negative.

      Returns:
      The hit hitface.
    • getExitFace

      @NotNull public @NotNull org.bukkit.block.BlockFace getExitFace()
      Returns the exit face. Will be one of:
      • BlockFace.NORTH
      • BlockFace.EAST
      • BlockFace.SOUTH
      • BlockFace.WEST
      • BlockFace.UP
      • BlockFace.DOWN
      Returns:
      The hit hitface.
    • getHitLocation

      @NotNull public @NotNull org.bukkit.util.Vector getHitLocation()
      Returns the exact coordinates that were hit, in world space.
      Returns:
      The hit location.
    • getExitLocation

      @NotNull public @NotNull org.bukkit.util.Vector getExitLocation()
      Returns the exact coordinates that the ray exits the hitbox, in world space.
      Returns:
      The exit location.
    • getHitMin

      public double getHitMin()
      Returns the distance between the origin of the ray and the hit location. Will return a negative number if the ray spawned within the hitbox.
      Returns:
      The entry wound of the ray hit.
    • getHitMinClamped

      public double getHitMinClamped()
      Same as getHitMin(), except this method will always return a positive number.
      Returns:
      The entry wound of the ray hit (with 0 as a minimum bound).
    • getHitMax

      public double getHitMax()
      Returns the distance between the origin and the furthest point of the hitbox.
      Returns:
      The exit wound of the ray hit.
    • getThroughDistance

      public double getThroughDistance()
      Returns the distance travelled through the hitbox. For a block, this number will not exceed sqrt(2). This method will always return a positive number.
      Returns:
      The distance travelled through the hitbox.
    • outlineOnlyHitPosition

      public void outlineOnlyHitPosition(org.bukkit.entity.Entity player)
    • getLivingEntity

      @Deprecated public org.bukkit.entity.Entity getLivingEntity()
      Deprecated.
    • toString

      public String toString()
      Overrides:
      toString in class Object