Represents a position of a block in the world

这个类由mod-id为crafttweaker的模组添加. 因此,如果要使用此功能,则需要安装此mod。

如果遇到任何问题(例如强制转换数组),则可能需要导入软件包,因此,最好的方式就是导入包支持。

ZenScript
Copy
crafttweaker.api.util.BlockPos

Constructor #构造函数

Link to constructor-构造函数

ZenScript
Copy
new crafttweaker.api.util.BlockPos(x as int, y as int, z as int);
参数类型描述
参数
x
类型
int
描述
No description provided
参数
y
类型
int
描述
No description provided
参数
z
类型
int
描述
No description provided

Adds two positions together and returns the result.

Returns crafttweaker.api.util.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).add(pos as crafttweaker.api.util.BlockPos);
new BlockPos(0, 1, 2).add(new BlockPos(3, 2, 1));
参数类型描述
参数
类型
crafttweaker.api.util.BlockPos
描述
other position to add

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

Returns crafttweaker.api.util.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).add(x as double, y as double, z as double);
new BlockPos(0, 1, 2).add(50.21, -20.8, -25.2);
参数类型描述
参数
x
类型
double
描述
x value to add
参数
y
类型
double
描述
y value to add
参数
z
类型
double
描述
z value to add

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

Returns crafttweaker.api.util.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).crossProduct(pos as crafttweaker.api.util.BlockPos);
new BlockPos(0, 1, 2).crossProduct(new BlockPos(5, 8, 2););
参数类型描述
参数
类型
crafttweaker.api.util.BlockPos
描述
BlockPos to cross product

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

Returns double

ZenScript
Copy
new BlockPos(0, 1, 2).distanceSq(to as crafttweaker.api.util.BlockPos);
new BlockPos(0, 1, 2).distanceSq(new BlockPos(256, 128, 10););
参数类型描述
参数
to
类型
crafttweaker.api.util.BlockPos
描述
BlockPos to check against

Gets the squared distance of this position to the specified BlockPos

Returns double

ZenScript
Copy
new BlockPos(0, 1, 2).distanceSq(to as crafttweaker.api.util.BlockPos, useCenter as boolean);
new BlockPos(0, 1, 2).distanceSq(new BlockPos(256, 128, 10);, true);
参数类型描述
参数
to
类型
crafttweaker.api.util.BlockPos
描述
BlockPos to check against
参数
useCenter
类型
布尔值
描述
should the center of the coordinate be used? (adds 0.5 to each value)

Gets the squared distance of this position to the specified coordinates

Returns double

ZenScript
Copy
new BlockPos(0, 1, 2).distanceSq(x as double, y as double, z as double, useCenter as boolean);
new BlockPos(0, 1, 2).distanceSq(500.25, 250.75, 100.20, false);
参数类型描述
参数
x
类型
double
描述
x position to check against
参数
y
类型
double
描述
y position to check against
参数
z
类型
double
描述
z position to check against
参数
useCenter
类型
布尔值
描述
should the center of the coordinate be used? (adds 0.5 to each value)

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

Returns: a new BlockPos that is one block lower than this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).down();

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

Returns: a new BlockPos that is one block east of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).east();

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

Returns: a new BlockPos that is n block(s) east of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).east(n as int);
new BlockPos(0, 1, 2).east(2);
参数类型描述
参数
n
类型
int
描述
No description provided

manhattanDistance

Link to manhattandistance

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

返回为int值

ZenScript
Copy
new BlockPos(0, 1, 2).manhattanDistance(other as crafttweaker.api.util.BlockPos);
new BlockPos(0, 1, 2).manhattanDistance(new BlockPos(4, 5, 6));
参数类型描述
参数
other
类型
crafttweaker.api.util.BlockPos
描述
other position to get the distance to

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

Returns: a new BlockPos that is one block north of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).north();

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

Returns: a new BlockPos that is n block(s) north of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).north(n as int);
new BlockPos(0, 1, 2).north(10);
参数类型描述
参数
n
类型
int
描述
No description provided

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

Returns: a new BlockPos that is 1 block offset of this BlockPos

Returns crafttweaker.api.util.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).offset(direction as crafttweaker.api.util.Direction);
new BlockPos(0, 1, 2).offset(<direction:east>);
参数类型描述
参数
direction
类型
crafttweaker.api.util.Direction
描述
No description provided

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

Returns: a new BlockPos that is n block(s) offset of this BlockPos

Returns crafttweaker.api.util.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).offset(direction as crafttweaker.api.util.Direction, n as int);
new BlockPos(0, 1, 2).offset(<direction:south>, 3);
参数类型描述
参数
direction
类型
crafttweaker.api.util.Direction
描述
No description provided
参数
n
类型
int
描述
No description provided

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

Returns: a new BlockPos that is one block south of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).south();

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

Returns: a new BlockPos that is n block(s) south of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).south(n as int);
new BlockPos(0, 1, 2).south(12);
参数类型描述
参数
n
类型
int
描述
No description provided

Subtracts two positions together and returns the result.

Returns crafttweaker.api.util.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).subtract(pos as crafttweaker.api.util.BlockPos);
new BlockPos(0, 1, 2).subtract(new BlockPos(2, 1, 3));
参数类型描述
参数
类型
crafttweaker.api.util.BlockPos
描述
other position to remove

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

Returns: a new BlockPos that is one block higher than this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).up();

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

Returns: a new BlockPos that is n block(s) higher than this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).up(n as int);
new BlockPos(0, 1, 2).up(45);
参数类型描述
参数
n
类型
int
描述
No description provided

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

Returns: a new BlockPos that is one block west of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).west();

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

Returns: a new BlockPos that is n block(s) west of this BlockPos

Returns net.minecraft.util.math.BlockPos

ZenScript
Copy
new BlockPos(0, 1, 2).west(n as int);
new BlockPos(0, 1, 2).west(120);
参数类型描述
参数
n
类型
int
描述
No description provided

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

返回为布尔值

ZenScript
Copy
new BlockPos(0, 1, 2).withinDistance(pos as crafttweaker.api.util.BlockPos, distance as double);
new BlockPos(0, 1, 2).withinDistance(new BlockPos(80, 75, 54);, 10);
参数类型描述
参数
类型
crafttweaker.api.util.BlockPos
描述
BlockPos to check if it is within the distance
参数
distance
类型
double
描述
distance to check within
名称类型可获得可设置
名称
x
类型
int
可获得
true
可设置
false
名称
y
类型
int
可获得
true
可设置
false
名称
z
类型
int
可获得
true
可设置
false

Adds two positions together and returns the result.

ZenScript
Copy
new BlockPos(0, 1, 2) + pos as crafttweaker.api.util.BlockPos
new BlockPos(0, 1, 2) + new BlockPos(3, 2, 1)
参数类型描述
参数
类型
crafttweaker.api.util.BlockPos
描述
other position to add
参数
### SUB

Subtracts two positions together and returns the result.

ZenScript
Copy
new BlockPos(0, 1, 2) - pos as crafttweaker.api.util.BlockPos
new BlockPos(0, 1, 2) - new BlockPos(2, 1, 3)
参数类型描述
参数
类型
crafttweaker.api.util.BlockPos
描述
other position to remove
结果类型是否隐藏
结果类型
long
是否隐藏
false