Package org.bukkit.util
Class RayTraceResult
- java.lang.Object
-
- org.bukkit.util.RayTraceResult
-
public class RayTraceResult extends Object
The hit result of a ray trace.Only the hit position is guaranteed to always be available. The availability of the other attributes depends on what got hit and on the context in which the ray trace was performed.
-
-
Constructor Summary
Constructors Constructor Description RayTraceResult(Vector hitPosition)
Creates a RayTraceResult.RayTraceResult(Vector hitPosition, BlockFace hitBlockFace)
Creates a RayTraceResult.RayTraceResult(Vector hitPosition, Block hitBlock, BlockFace hitBlockFace)
Creates a RayTraceResult.RayTraceResult(Vector hitPosition, Entity hitEntity)
Creates a RayTraceResult.RayTraceResult(Vector hitPosition, Entity hitEntity, BlockFace hitBlockFace)
Creates a RayTraceResult.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Block
getHitBlock()
Gets the hit block.BlockFace
getHitBlockFace()
Gets the hit block face.Entity
getHitEntity()
Gets the hit entity.Vector
getHitPosition()
Gets the exact position of the hit.int
hashCode()
String
toString()
-
-
-
Constructor Detail
-
RayTraceResult
public RayTraceResult(@NotNull Vector hitPosition)
Creates a RayTraceResult.- Parameters:
hitPosition
- the hit position
-
RayTraceResult
public RayTraceResult(@NotNull Vector hitPosition, @Nullable BlockFace hitBlockFace)
Creates a RayTraceResult.- Parameters:
hitPosition
- the hit positionhitBlockFace
- the hit block face
-
RayTraceResult
public RayTraceResult(@NotNull Vector hitPosition, @Nullable Block hitBlock, @Nullable BlockFace hitBlockFace)
Creates a RayTraceResult.- Parameters:
hitPosition
- the hit positionhitBlock
- the hit blockhitBlockFace
- the hit block face
-
RayTraceResult
public RayTraceResult(@NotNull Vector hitPosition, @Nullable Entity hitEntity)
Creates a RayTraceResult.- Parameters:
hitPosition
- the hit positionhitEntity
- the hit entity
-
-
Method Detail
-
getHitPosition
@NotNull public Vector getHitPosition()
Gets the exact position of the hit.- Returns:
- a copy of the exact hit position
-
getHitBlock
@Nullable public Block getHitBlock()
Gets the hit block.- Returns:
- the hit block, or
null
if not available
-
getHitBlockFace
@Nullable public BlockFace getHitBlockFace()
Gets the hit block face.- Returns:
- the hit block face, or
null
if not available
-
getHitEntity
@Nullable public Entity getHitEntity()
Gets the hit entity.- Returns:
- the hit entity, or
null
if not available
-
-