@Immutable public class BlockPos extends Vec3i
The position is integer-valued.
A block position may be mutable; hence, when using block positions
obtained from other places as map keys, etc., you should call toImmutable()
to obtain an immutable block position.
Modifier and Type | Class and Description |
---|---|
static class |
BlockPos.Mutable |
Modifier and Type | Field and Description |
---|---|
private static int |
BIT_SHIFT_X |
private static int |
BIT_SHIFT_Z |
private static long |
BITS_X |
private static long |
BITS_Y |
private static long |
BITS_Z |
static com.mojang.serialization.Codec<BlockPos> |
CODEC |
private static Logger |
LOGGER |
static BlockPos |
ORIGIN
The block position which x, y, and z values are all zero.
|
private static int |
SIZE_BITS_X |
private static int |
SIZE_BITS_Y |
private static int |
SIZE_BITS_Z |
Constructor and Description |
---|
BlockPos(double x,
double y,
double z) |
BlockPos(int x,
int y,
int z) |
BlockPos(Position pos) |
BlockPos(Vec3d pos) |
BlockPos(Vec3i pos) |
Modifier and Type | Method and Description |
---|---|
BlockPos |
add(double x,
double y,
double z) |
BlockPos |
add(int x,
int y,
int z) |
static long |
add(long value,
int x,
int y,
int z) |
BlockPos |
add(Vec3i pos) |
long |
asLong() |
static long |
asLong(int x,
int y,
int z) |
BlockPos |
crossProduct(Vec3i pos) |
BlockPos |
down() |
BlockPos |
down(int int2) |
BlockPos |
east() |
BlockPos |
east(int distance) |
static Optional<BlockPos> |
findClosest(BlockPos pos,
int horizontalRange,
int verticalRange,
Predicate<BlockPos> condition) |
static BlockPos |
fromLong(long packedPos) |
static Iterable<BlockPos> |
iterate(BlockPos start,
BlockPos end) |
static Iterable<BlockPos> |
iterate(int startX,
int startY,
int startZ,
int endX,
int endY,
int endZ) |
static Iterable<BlockPos> |
iterateOutwards(BlockPos center,
int xRange,
int yRange,
int zRange)
Iterates block positions around the
center . |
static Iterable<BlockPos> |
iterateRandomly(Random random,
int count,
int minX,
int minY,
int minZ,
int maxX,
int maxY,
int maxZ)
Iterates through
count random block positions in the given area. |
static Iterable<BlockPos.Mutable> |
method_30512(BlockPos blockPos,
int int2,
Direction direction,
Direction direction2) |
BlockPos.Mutable |
mutableCopy()
Returns a mutable copy of this block position.
|
BlockPos |
north() |
BlockPos |
north(int distance) |
BlockPos |
offset(Direction.Axis axis,
int distance) |
BlockPos |
offset(Direction direction) |
BlockPos |
offset(Direction direction,
int int2) |
static long |
offset(long value,
Direction direction) |
static long |
removeChunkSectionLocalY(long y) |
BlockPos |
rotate(BlockRotation rotation) |
BlockPos |
south() |
BlockPos |
south(int distance) |
static Stream<BlockPos> |
stream(BlockBox box) |
static Stream<BlockPos> |
stream(BlockPos start,
BlockPos end) |
static Stream<BlockPos> |
stream(Box box) |
static Stream<BlockPos> |
stream(int startX,
int startY,
int startZ,
int endX,
int endY,
int endZ) |
static Stream<BlockPos> |
streamOutwards(BlockPos center,
int maxX,
int maxY,
int maxZ) |
BlockPos |
subtract(Vec3i pos) |
BlockPos |
toImmutable()
Returns an immutable block position with the same x, y, and z as this
position.
|
static int |
unpackLongX(long packedPos) |
static int |
unpackLongY(long packedPos) |
static int |
unpackLongZ(long packedPos) |
BlockPos |
up() |
BlockPos |
up(int distance) |
BlockPos |
west() |
BlockPos |
west(int distance) |
compareTo, equals, getComponentAlongAxis, getManhattanDistance, getSquaredDistance, getSquaredDistance, getSquaredDistance, getX, getY, getZ, hashCode, isWithinDistance, isWithinDistance, setX, setY, setZ, toShortString, toString
public static final com.mojang.serialization.Codec<BlockPos> CODEC
private static final Logger LOGGER
public static final BlockPos ORIGIN
private static final int SIZE_BITS_X
private static final int SIZE_BITS_Z
private static final int SIZE_BITS_Y
private static final long BITS_X
private static final long BITS_Y
private static final long BITS_Z
private static final int BIT_SHIFT_Z
private static final int BIT_SHIFT_X
public BlockPos(int x, int y, int z)
public BlockPos(double x, double y, double z)
public BlockPos(Vec3d pos)
public BlockPos(Position pos)
public BlockPos(Vec3i pos)
public static long offset(long value, Direction direction)
public static long add(long value, int x, int y, int z)
public static int unpackLongX(long packedPos)
public static int unpackLongY(long packedPos)
public static int unpackLongZ(long packedPos)
public static BlockPos fromLong(long packedPos)
public long asLong()
public static long asLong(int x, int y, int z)
public static long removeChunkSectionLocalY(long y)
public BlockPos add(double x, double y, double z)
public BlockPos add(int x, int y, int z)
public BlockPos north()
public BlockPos north(int distance)
public BlockPos south()
public BlockPos south(int distance)
public BlockPos west()
public BlockPos west(int distance)
public BlockPos east()
public BlockPos east(int distance)
public BlockPos offset(Direction.Axis axis, int distance)
public BlockPos rotate(BlockRotation rotation)
public BlockPos crossProduct(Vec3i pos)
crossProduct
in class Vec3i
public BlockPos toImmutable()
This method should be called when a block position is used as map keys as to prevent side effects of mutations of mutable block positions.
public BlockPos.Mutable mutableCopy()
If this block position is a mutable one, mutation to this block position won't affect the returned position.
public static Iterable<BlockPos> iterateRandomly(Random random, int count, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
count
random block positions in the given area.
The iterator yields positions in no specific order. The same position may be returned multiple times by the iterator.
random
- the Random
object used to compute new positionscount
- the number of positions to iterateminX
- the minimum x value for returned positionsminY
- the minimum y value for returned positionsminZ
- the minimum z value for returned positionsmaxX
- the maximum x value for returned positionsmaxY
- the maximum y value for returned positionsmaxZ
- the maximum z value for returned positionspublic static Iterable<BlockPos> iterateOutwards(BlockPos center, int xRange, int yRange, int zRange)
center
. The iteration order
is mainly based on the manhattan distance of the position from the
center.
For the same manhattan distance, the positions are iterated by y offset, from negative to positive. For the same y offset, the positions are iterated by x offset, from negative to positive. For the two positions with the same x and y offsets and the same manhattan distance, the one with a positive z offset is visited first before the one with a negative z offset.
center
- the center of iterationxRange
- the maximum x difference from the centeryRange
- the maximum y difference from the centerzRange
- the maximum z difference from the centerpublic static Optional<BlockPos> findClosest(BlockPos pos, int horizontalRange, int verticalRange, Predicate<BlockPos> condition)
public static Stream<BlockPos> streamOutwards(BlockPos center, int maxX, int maxY, int maxZ)
public static Stream<BlockPos> stream(int startX, int startY, int startZ, int endX, int endY, int endZ)
public static Iterable<BlockPos> iterate(int startX, int startY, int startZ, int endX, int endY, int endZ)
public static Iterable<BlockPos.Mutable> method_30512(BlockPos blockPos, int int2, Direction direction, Direction direction2)