BlockPosHelper
com.jsmacrosce.jsmacros.client.api.helper.world.BlockPosHelper
A block position with integer world coordinates. Movement methods return new positions and leave this position unchanged; directional methods correspond to offset(String, int).
js
const pos = PositionCommon.createBlockPos(10, 64, -3);
Chat.log(`start ${pos.getX()}, ${pos.getY()}, ${pos.getZ()}`);
const up = pos.up();
const upThree = pos.up(3);
Chat.log(`${up} and ${upThree}, while pos is still ${pos}`);
Chat.log(`${pos.north(2)} equals ${pos.offset("north", 2)}`); // true
Chat.log(pos.toPos3D());Constructors
new BlockPosHelper
Wraps the supplied block position, retaining it as the wrapped value.
Parameters:
b: position to wrap
new BlockPosHelper(int x, int y, int z)#Wraps a newly constructed block position from the supplied block coordinates.
Parameters:
x: block x coordinatey: block y coordinatez: block z coordinate
Methods
distanceTo
Returns the Euclidean distance from this block's center to the entity's position.
Parameters:
entity: the entity to get the distance to
Returns: the distance in blocks.
Returns the Euclidean distance between the two block positions, using their integer coordinates without centering either block.
Parameters:
pos: the position to get the distance to
Returns: the distance in blocks.
Returns the Euclidean distance from this block position's low corner to a point.
Parameters:
pos: the point to measure to
Returns: the distance in blocks.
Returns the Euclidean distance from this block position's low corner to the given point.
Parameters:
x: the point's x coordinatey: the point's y coordinatez: the point's z coordinate
Returns: the distance in blocks.
down
Returns the position one block below this one, equivalent to
offset("down").Returns: the position below this one.
Returns a position moved by
distance blocks downward; negative values move upward.Parameters:
distance: the signed distance to move
Returns: the resulting position.
east
Returns the adjacent block to the east (increasing
x); equivalent to offset("east").Returns: the block to the east.
Returns a position moved by
distance blocks to the east (increasing x).Parameters:
distance: the distance to move east
Returns: the position at the requested signed distance east of this one.
equals
getX
Returns the
x coordinate in blocks.Returns: the
x coordinate.getY
Returns the
y coordinate in blocks.Returns: the
y coordinate.getZ
Returns the
z coordinate in blocks.Returns: the
z coordinate.hashCode
hashCode(): int#Returns the hash code delegated from the wrapped position.
Returns: the wrapped position's hash code
north
Returns the position one block north, equivalent to
offset("north"). North is toward decreasing z.Returns: the position to the north.
Returns a position moved
distance blocks north (toward decreasing z).Parameters:
distance: the distance to move north
Returns: the resulting position.
offset
Returns the adjacent position in the named direction. The name must be one of
down, up, north, south, west, or east.Parameters:
direction: one ofdown,up,north,south,westoreast.
Returns: the block offset by the given direction.
Returns a position moved
distance blocks in the named direction; negative distances move in the opposite direction. Direction names are the same as for offset(String).Parameters:
direction: one ofdown,up,north,south,westoreast.distance: the distance to move in the given direction
Returns: the position at the requested signed distance in the given direction.
Returns the position formed by adding the given coordinate offsets to this position.
Parameters:
x: the x offsety: the y offsetz: the z offset
Returns: the block offset by the given values.
south
Returns the adjacent block to the south (increasing
z); equivalent to offset("south").Returns: the block to the south.
Returns a position moved by
distance blocks to the south (increasing z).Parameters:
distance: the distance to move south
Returns: the position at the requested signed distance south of this one.
toNetherCoords
Converts coordinates by integer-dividing
x and z by eight and leaving y unchanged. Negative coordinates therefore truncate toward zero; this does not locate or verify a portal.Returns: the block position converted to the respective nether coordinates.
toOverworldCoords
Converts this position from Nether to Overworld coordinates by multiplying
x and z by eight and leaving y unchanged.Returns: the converted Overworld position.
toPos3D
toString
up
Returns the position one block above this one, equivalent to
offset("up").Returns: the position above this one.
Returns a position moved by
distance blocks upward; negative values move downward.Parameters:
distance: the signed distance to move
Returns: the resulting position.
west
Returns the adjacent block to the west (decreasing
x); equivalent to offset("west").Returns: the block to the west.
Returns a position moved by
distance blocks to the west (decreasing x).Parameters:
distance: the distance to move west
Returns: the position at the requested signed distance west of this one.