RaytraceResult

Getting a RaytraceResult

To get a RaytraceResult object you can use the world namespace.

getType(): String

Returns the type of hit from the ray trace result. The type is returned as a string and can be one of the following: MISS, BLOCK, or ENTITY.

getHitVec(): Vec3

Retrieves the hit vector of the ray trace result. This method returns a Vec3Wrapper object representing the precise location where the ray intersected an object.

getEntity(): Entity

Returns an EntityWrapper object if the ray trace hit an entity. If no entity was hit, the behavior of this method may vary based on implementation (could return null or an empty wrapper).

getBlockPos(): BlockPos

Provides the block position if the ray trace hit a block. This method returns a BlockPos object representing the location of the block that was hit.

getSideHit(): String

Returns the side of the block that was hit by the ray trace. The side is returned as a string and can be one of the following: DOWN, UP, NORTH, SOUTH, WEST, EAST, NONE.

See EnumFacing for more info on this

Raytrace Result Types

Raytrace Result TypeDescription

MISS

Indicates no object was hit.

BLOCK

Indicates a block was hit.

ENTITY

Indicates an entity was hit.

Last updated