Home Migration Guide Getting Started With Scripts Commands Examples
BracketHandlers

BlockRayTraceResult

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.BlockRayTraceResult;

Extending RayTraceResult

BlockRayTraceResult extends RayTraceResult. That means all methods available in RayTraceResult are also available in BlockRayTraceResult

Methods

Gets the face that was hit.

Returns: The face that was hit.
Return Type: Direction

script.zs
// BlockRayTraceResult.getFace() as Direction
myBlockRayTraceResult.getFace();

Gets the position that was hit.

Returns: The position that was hit.
Return Type: BlockPos

script.zs
// BlockRayTraceResult.getPos() as BlockPos
myBlockRayTraceResult.getPos();

Results if the result is inside of a block.

This is used for scaffolding.

Returns: True if it is inside. False otherwise.
Return Type: boolean

script.zs
// BlockRayTraceResult.isInside() as boolean
myBlockRayTraceResult.isInside();

Returns a new BlockRayTraceResult based on this result with the given face.

Returns: a new BlockRayTraceResult based on this result with the given face.
Return Type: BlockRayTraceResult

script.zs
// BlockRayTraceResult.withFace(newFace as Direction) as BlockRayTraceResult
myBlockRayTraceResult.withFace(MCDirection.north);
ParameterTypeDescription
Parameter
newFace
Type
Direction
Description
The new face.

Returns a new BlockRayTraceResult based on this result with the given position.

Returns: a new BlockRayTraceResult based on this result with the given position.
Return Type: BlockRayTraceResult

script.zs
// BlockRayTraceResult.withPosition(pos as BlockPos) as BlockRayTraceResult
myBlockRayTraceResult.withPosition(new BlockPos(1, 2, 3));
ParameterTypeDescription
Parameter
pos
Type
BlockPos
Description
The new position.

Properties

NameTypeHas GetterHas SetterDescription
Name
face
Type
Direction
Has Getter
true
Has Setter
false
Description
Gets the face that was hit.
Name
inside
Type
boolean
Has Getter
true
Has Setter
false
Description
Results if the result is inside of a block.

This is used for scaffolding.
Name
pos
Type
BlockPos
Has Getter
true
Has Setter
false
Description
Gets the position that was hit.