Class BlockPos
- All Implemented Interfaces:
Comparable<Vec3i>
- Direct Known Subclasses:
BlockPos.Mutable
@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.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BlockPos.Mutable
-
Field Summary
Fields Modifier and Type Field 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 Summary
-
Method Summary
Modifier and Type Method 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(int startX, int startY, int startZ, int endX, int endY, int endZ)
static Iterable<BlockPos>
iterate(BlockPos start, BlockPos end)
static Iterable<BlockPos>
iterateOutwards(BlockPos center, int xRange, int yRange, int zRange)
Iterates block positions around thecenter
.static Iterable<BlockPos>
iterateRandomly(Random random, int count, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)
Iterates throughcount
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)
static long
offset(long value, Direction direction)
BlockPos
offset(Direction direction)
BlockPos
offset(Direction.Axis axis, int distance)
BlockPos
offset(Direction direction, int int2)
static long
removeChunkSectionLocalY(long y)
BlockPos
rotate(BlockRotation rotation)
BlockPos
south()
BlockPos
south(int distance)
static Stream<BlockPos>
stream(int startX, int startY, int startZ, int endX, int endY, int endZ)
static Stream<BlockPos>
stream(BlockBox box)
static Stream<BlockPos>
stream(BlockPos start, BlockPos end)
static Stream<BlockPos>
stream(Box box)
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)
Methods inherited from class net.minecraft.util.math.Vec3i
compareTo, equals, getComponentAlongAxis, getManhattanDistance, getSquaredDistance, getSquaredDistance, getSquaredDistance, getX, getY, getZ, hashCode, isWithinDistance, isWithinDistance, setX, setY, setZ, toShortString, toString
-
Field Details
-
CODEC
-
LOGGER
-
ORIGIN
The block position which x, y, and z values are all zero. -
SIZE_BITS_X
private static final int SIZE_BITS_X -
SIZE_BITS_Z
private static final int SIZE_BITS_Z -
SIZE_BITS_Y
private static final int SIZE_BITS_Y -
BITS_X
private static final long BITS_X -
BITS_Y
private static final long BITS_Y -
BITS_Z
private static final long BITS_Z -
BIT_SHIFT_Z
private static final int BIT_SHIFT_Z -
BIT_SHIFT_X
private static final int BIT_SHIFT_X
-
-
Constructor Details
-
BlockPos
public BlockPos(int x, int y, int z) -
BlockPos
public BlockPos(double x, double y, double z) -
BlockPos
-
BlockPos
-
BlockPos
-
-
Method Details
-
offset
-
add
public static long add(long value, int x, int y, int z) -
unpackLongX
public static int unpackLongX(long packedPos) -
unpackLongY
public static int unpackLongY(long packedPos) -
unpackLongZ
public static int unpackLongZ(long packedPos) -
fromLong
-
asLong
public long asLong() -
asLong
public static long asLong(int x, int y, int z) -
removeChunkSectionLocalY
public static long removeChunkSectionLocalY(long y) -
add
-
add
-
add
-
subtract
-
up
-
up
-
down
-
down
-
north
-
north
-
south
-
south
-
west
-
west
-
east
-
east
-
offset
-
offset
-
offset
-
rotate
-
crossProduct
- Overrides:
crossProduct
in classVec3i
-
toImmutable
Returns an immutable block position with the same x, y, and z as this position.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.
-
mutableCopy
Returns a mutable copy of this block position.If this block position is a mutable one, mutation to this block position won't affect the returned position.
-
iterateRandomly
public static Iterable<BlockPos> iterateRandomly(Random random, int count, int minX, int minY, int minZ, int maxX, int maxY, int maxZ)Iterates throughcount
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.
- Parameters:
random
- theRandom
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 positions
-
iterateOutwards
public static Iterable<BlockPos> iterateOutwards(BlockPos center, int xRange, int yRange, int zRange)Iterates block positions around thecenter
. 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.
- Parameters:
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 center
-
findClosest
-
streamOutwards
-
iterate
-
stream
-
stream
-
stream
-
stream
-
iterate
-
method_30512
public static Iterable<BlockPos.Mutable> method_30512(BlockPos blockPos, int int2, Direction direction, Direction direction2)
-