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 classBlockPos.Mutable -
Field Summary
Fields Modifier and Type Field Description private static intBIT_SHIFT_Xprivate static intBIT_SHIFT_Zprivate static longBITS_Xprivate static longBITS_Yprivate static longBITS_Zstatic com.mojang.serialization.Codec<BlockPos>CODECprivate static LoggerLOGGERstatic BlockPosORIGINThe block position which x, y, and z values are all zero.private static intSIZE_BITS_Xstatic intSIZE_BITS_Yprivate static intSIZE_BITS_Z -
Constructor Summary
-
Method Summary
Modifier and Type Method Description BlockPosadd(double x, double y, double z)BlockPosadd(int x, int y, int z)static longadd(long value, int x, int y, int z)BlockPosadd(Vec3i pos)longasLong()static longasLong(int x, int y, int z)BlockPoscrossProduct(Vec3i pos)BlockPosdown()BlockPosdown(int int2)BlockPoseast()BlockPoseast(int distance)static Optional<BlockPos>findClosest(BlockPos pos, int horizontalRange, int verticalRange, Predicate<BlockPos> condition)static BlockPosfromLong(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 throughcountrandom block positions in the given area.static Iterable<BlockPos.Mutable>method_30512(BlockPos blockPos, int int2, Direction direction, Direction direction2)BlockPos.MutablemutableCopy()Returns a mutable copy of this block position.BlockPosnorth()BlockPosnorth(int distance)static longoffset(long value, Direction direction)BlockPosoffset(Direction direction)BlockPosoffset(Direction.Axis axis, int distance)BlockPosoffset(Direction direction, int int2)static longremoveChunkSectionLocalY(long y)BlockPosrotate(BlockRotation rotation)BlockPossouth()BlockPossouth(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)BlockPossubtract(Vec3i pos)BlockPostoImmutable()Returns an immutable block position with the same x, y, and z as this position.static intunpackLongX(long packedPos)static intunpackLongY(long packedPos)static intunpackLongZ(long packedPos)BlockPosup()BlockPosup(int distance)BlockPoswest()BlockPoswest(int distance)BlockPoswithY(int y)Methods inherited from class net.minecraft.util.math.Vec3i
compareTo, equals, getComponentAlongAxis, getManhattanDistance, getSquaredDistance, 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
public 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:
crossProductin classVec3i
-
withY
-
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 throughcountrandom 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- theRandomobject 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)
-