Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

RayTraceResult

Importing the class

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

script.zs
import crafttweaker.api.util.math.RayTraceResult;

Methods

Gets the distance from this RayTraceResult to the given Entity.

Returns: The distance from this result to the given entity.
Return Type: double

script.zs
// RayTraceResult.distanceTo(entity as MCEntity) as double
myRayTraceResult.distanceTo(event.entity);
ParameterTypeDescription
Parameter
entity
Type
MCEntity
Description
The entity to get the distance to.

Gets the hit vector of this result.

Returns: The hit vector of this result.
Return Type: MCVector3d

script.zs
// RayTraceResult.getHitVec() as MCVector3d
myRayTraceResult.getHitVec();

Gets the type of this RayTraceResult. This can be used to determine if this is a BlockRayTraceResult, an EntityRayTraceResult or if the trace missed.

Returns: The type of this RayTraceResult.
Return Type: RayTraceResultType

script.zs
// RayTraceResult.getType() as RayTraceResultType
myRayTraceResult.getType();

Properties

NameTypeHas GetterHas SetterDescription
Name
hitVec
Type
MCVector3d
Has Getter
true
Has Setter
false
Description
Gets the hit vector of this result.
Name
type
Type
RayTraceResultType
Has Getter
true
Has Setter
false
Description
Gets the type of this RayTraceResult. This can be used to determine if this is a BlockRayTraceResult, an EntityRayTraceResult or if the trace missed.