BlockPos

Represents a position of a block in the world

This class was added by a mod with mod-id crafttweaker. So you need to have this mod installed if you want to use this feature.

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.

import crafttweaker.api.util.BlockPos;

Constructors

new BlockPos(x as int, y as int, z as int) as BlockPos
ParameterTypeDescription
xintNo description provided
yintNo description provided
zintNo description provided

Casters

Result typeIs Implicit
longfalse
stringtrue

Methods

add

Adds two positions together and returns the result.

Return Type: BlockPos

BlockPos.add(pos as BlockPos) as BlockPos
new BlockPos(0, 1, 2).add(new BlockPos(3, 2, 1));
ParameterTypeDescription
posBlockPosother position to add

Adds the given values to this position, and returns a new position with the new values.

Return Type: BlockPos

BlockPos.add(x as double, y as double, z as double) as BlockPos
new BlockPos(0, 1, 2).add(50.21, -20.8, -25.2);
ParameterTypeDescription
xdoublex value to add
ydoubley value to add
zdoublez value to add

Adds the given values to this position, and returns a new position with the new values.

Return Type: BlockPos

BlockPos.add(x as int, y as int, z as int) as BlockPos
new BlockPos(0, 1, 2).add(50, -20, -25);
ParameterTypeDescription
xintx value to add
yinty value to add
zintz value to add

crossProduct

Creates a new BlockPos based on the cross product of this position, and the given position

Return Type: BlockPos

BlockPos.crossProduct(pos as BlockPos) as BlockPos
new BlockPos(0, 1, 2).crossProduct(new BlockPos(5, 8, 2););
ParameterTypeDescription
posBlockPosBlockPos to cross product

distanceSq

Gets the squared distance of this position to the specified BlockPos, using the center of the BlockPos

Return Type: double

BlockPos.distanceSq(to as BlockPos) as double
new BlockPos(0, 1, 2).distanceSq(new BlockPos(256, 128, 10););
ParameterTypeDescription
toBlockPosBlockPos to check against

Gets the squared distance of this position to the specified BlockPos

Return Type: double

BlockPos.distanceSq(to as BlockPos, useCenter as boolean) as double
new BlockPos(0, 1, 2).distanceSq(new BlockPos(256, 128, 10);, true);
ParameterTypeDescription
toBlockPosBlockPos to check against
useCenterbooleanshould the center of the coordinate be used? (adds 0.5 to each value)

Gets the squared distance of this position to the specified coordinates

Return Type: double

BlockPos.distanceSq(x as double, y as double, z as double, useCenter as boolean) as double
new BlockPos(0, 1, 2).distanceSq(500.25, 250.75, 100.20, false);
ParameterTypeDescription
xdoublex position to check against
ydoubley position to check against
zdoublez position to check against
useCenterbooleanshould the center of the coordinate be used? (adds 0.5 to each value)

down

Creates a new BlockPos based on this BlockPos that is one block lower than this BlockPos

Return Type: BlockPos

BlockPos.down() as BlockPos
new BlockPos(0, 1, 2).down();

Creates a new BlockPos based on this BlockPos that is n block(s) lower than this BlockPos

Return Type: BlockPos

BlockPos.down(n as int) as BlockPos
ParameterTypeDescription
nintNo Description Provided

east

Creates a new BlockPos based on this BlockPos that is one block east of this BlockPos

Return Type: BlockPos

BlockPos.east() as BlockPos
new BlockPos(0, 1, 2).east();

Creates a new BlockPos based on this BlockPos that is n block(s) east of this BlockPos

Return Type: BlockPos

BlockPos.east(n as int) as BlockPos
new BlockPos(0, 1, 2).east(2);
ParameterTypeDescription
nintNo Description Provided

manhattanDistance

Gets the Manhattan Distance of this pos compared to a different position

Return Type: int

BlockPos.manhattanDistance(other as BlockPos) as int
new BlockPos(0, 1, 2).manhattanDistance(new BlockPos(4, 5, 6));
ParameterTypeDescription
otherBlockPosother position to get the distance to

north

Creates a new BlockPos based on this BlockPos that is one block north of this BlockPos

Return Type: BlockPos

BlockPos.north() as BlockPos
new BlockPos(0, 1, 2).north();

Creates a new BlockPos based on this BlockPos that is n block(s) north of this BlockPos

Return Type: BlockPos

BlockPos.north(n as int) as BlockPos
new BlockPos(0, 1, 2).north(10);
ParameterTypeDescription
nintNo Description Provided

offset

Creates a new BlockPos based on this BlockPos that is one block offset of this BlockPos based on the given Direction

Return Type: BlockPos

BlockPos.offset(direction as Direction) as BlockPos
new BlockPos(0, 1, 2).offset(<direction:east>);
ParameterTypeDescription
directionDirectionNo Description Provided

Creates a new BlockPos based on this BlockPos that is n block(s) offset of this BlockPos based on the given Direction

Return Type: BlockPos

BlockPos.offset(direction as Direction, n as int) as BlockPos
new BlockPos(0, 1, 2).offset(<direction:south>, 3);
ParameterTypeDescription
directionDirectionNo Description Provided
nintNo Description Provided

south

Creates a new BlockPos based on this BlockPos that is one block south of this BlockPos

Return Type: BlockPos

BlockPos.south() as BlockPos
new BlockPos(0, 1, 2).south();

Creates a new BlockPos based on this BlockPos that is n block(s) south of this BlockPos

Return Type: BlockPos

BlockPos.south(n as int) as BlockPos
new BlockPos(0, 1, 2).south(12);
ParameterTypeDescription
nintNo Description Provided

subtract

Subtracts two positions together and returns the result.

Return Type: BlockPos

BlockPos.subtract(pos as BlockPos) as BlockPos
new BlockPos(0, 1, 2).subtract(new BlockPos(2, 1, 3));
ParameterTypeDescription
posBlockPosother position to remove

up

Creates a new BlockPos based on this BlockPos that is one block higher than this BlockPos

Return Type: BlockPos

BlockPos.up() as BlockPos
new BlockPos(0, 1, 2).up();

Creates a new BlockPos based on this BlockPos that is n block(s) higher than this BlockPos

Return Type: BlockPos

BlockPos.up(n as int) as BlockPos
new BlockPos(0, 1, 2).up(45);
ParameterTypeDescription
nintNo Description Provided

west

Creates a new BlockPos based on this BlockPos that is one block west of this BlockPos

Return Type: BlockPos

BlockPos.west() as BlockPos
new BlockPos(0, 1, 2).west();

Creates a new BlockPos based on this BlockPos that is n block(s) west of this BlockPos

Return Type: BlockPos

BlockPos.west(n as int) as BlockPos
new BlockPos(0, 1, 2).west(120);
ParameterTypeDescription
nintNo Description Provided

withinDistance

Checks if the given BlockPos is within the specified distance of this BlockPos (this uses the middle of the BlockPos)

Return Type: boolean

BlockPos.withinDistance(pos as BlockPos, distance as double) as boolean
new BlockPos(0, 1, 2).withinDistance(new BlockPos(80, 75, 54);, 10);
ParameterTypeDescription
posBlockPosBlockPos to check if it is within the distance
distancedoubledistance to check within

Properties

NameTypeHas GetterHas Setter
xinttruefalse
yinttruefalse
zinttruefalse