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(@NotNull Vector hitPosition)`
Creates a RayTraceResult.
`RayTraceResult(@NotNull Vector hitPosition, @Nullable BlockFace hitBlockFace)`
Creates a RayTraceResult.
`RayTraceResult(@NotNull Vector hitPosition, @Nullable Block hitBlock, @Nullable BlockFace hitBlockFace)`
Creates a RayTraceResult.
`RayTraceResult(@NotNull Vector hitPosition, @Nullable Entity hitEntity)`
Creates a RayTraceResult.
`RayTraceResult(@NotNull Vector hitPosition, @Nullable Entity hitEntity, @Nullable BlockFace hitBlockFace)`
Creates a RayTraceResult.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object obj)`
`@Nullable Block`
`getHitBlock()`
Gets the hit block.
`@Nullable BlockFace`
`getHitBlockFace()`
Gets the hit block face.
`@Nullable Entity`
`getHitEntity()`
Gets the hit entity.
`@NotNull Vector`
`getHitPosition()`
Gets the exact position of the hit.
`int`
`hashCode()`
`String`
`toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### RayTraceResult

public RayTraceResult(@NotNull @NotNull Vector hitPosition)
Creates a RayTraceResult.

Parameters:
  `hitPosition` - the hit position

### RayTraceResult

public RayTraceResult(@NotNull @NotNull Vector hitPosition, @Nullable @Nullable BlockFace hitBlockFace)
Creates a RayTraceResult.

Parameters:
  `hitPosition` - the hit position
  `hitBlockFace` - the hit block face

### RayTraceResult

public RayTraceResult(@NotNull @NotNull Vector hitPosition, @Nullable @Nullable Block hitBlock, @Nullable @Nullable BlockFace hitBlockFace)
Creates a RayTraceResult.

Parameters:
  `hitPosition` - the hit position
  `hitBlock` - the hit block
  `hitBlockFace` - the hit block face

### RayTraceResult

public RayTraceResult(@NotNull @NotNull Vector hitPosition, @Nullable @Nullable Entity hitEntity)
Creates a RayTraceResult.

Parameters:
  `hitPosition` - the hit position
  `hitEntity` - the hit entity

### RayTraceResult

public RayTraceResult(@NotNull @NotNull Vector hitPosition, @Nullable @Nullable Entity hitEntity, @Nullable @Nullable BlockFace hitBlockFace)
Creates a RayTraceResult.

Parameters:
  `hitPosition` - the hit position
  `hitEntity` - the hit entity
  `hitBlockFace` - the hit block face

## Method Details

### getHitPosition

@NotNull public @NotNull Vector getHitPosition()
Gets the exact position of the hit.

Returns:
  a copy of the exact hit position

### getHitBlock

@Nullable public @Nullable Block getHitBlock()
Gets the hit block.

Returns:
  the hit block, or `null` if not available

### getHitBlockFace

@Nullable public @Nullable BlockFace getHitBlockFace()
Gets the hit block face.

Returns:
  the hit block face, or `null` if not available

### getHitEntity

@Nullable public @Nullable Entity getHitEntity()
Gets the hit entity.

Returns:
  the hit entity, or `null` if not available

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`