Class BlockPos
java.lang.Object
net.minecraft.core.Vec3i
net.minecraft.core.BlockPos
- All Implemented Interfaces:
Comparable<Vec3i>
- Direct Known Subclasses:
BlockPos.MutableBlockPos
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<BlockPos> static final intstatic final intprivate static final longstatic final intprivate static final longprivate static final longstatic final StreamCodec<io.netty.buffer.ByteBuf, BlockPos> private static final intprivate static final intprivate static final intstatic final BlockPosAn immutable BlockPos with zero as all coordinates. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabove()above(int steps) Offset this vector upwards by the given distance.longasLong()static longasLong(int x, int y, int z) atY(int y) below()below(int steps) Offset this vector downwards by the given distance.betweenClosed(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Creates an Iterable that returns all positions in the box specified by the given corners.betweenClosed(BlockPos a, BlockPos b) betweenClosed(AABB box) betweenClosedStream(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) betweenClosedStream(BoundingBox boundingBox) betweenClosedStream(AABB box) betweenCornersInDirection(int firstCornerX, int firstCornerY, int firstCornerZ, int secondCornerX, int secondCornerY, int secondCornerZ, Vec3 direction) betweenCornersInDirection(BlockPos firstCorner, BlockPos secondCorner, Vec3 direction) betweenCornersInDirection(AABB aabb, Vec3 direction) static intbreadthFirstTraversal(BlockPos startPos, int maxDepth, int maxCount, BiConsumer<BlockPos, Consumer<BlockPos>> neighbourProvider, Function<BlockPos, BlockPos.TraversalNodeStatus> nodeProcessor) clampLocationWithin(Vec3 location) static BlockPoscontaining(double x, double y, double z) static BlockPoscontaining(Position pos) Calculate the cross product of this and the given Vectoreast()east(int steps) findClosestMatch(BlockPos startPos, int horizontalSearchRadius, int verticalSearchRadius, Predicate<BlockPos> predicate) static longgetFlatIndex(long neighborBlockNode) static intgetX(long blockNode) static intgetY(long blockNode) static intgetZ(long blockNode) static BlockPosstatic BlockPosmultiply(int scale) mutable()north()north(int steps) static BlockPosof(long blockNode) offset(int x, int y, int z) static longoffset(long blockNode, int stepX, int stepY, int stepZ) static longrandomBetweenClosed(RandomSource random, int limit, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) randomInCube(RandomSource random, int limit, BlockPos center, int sizeToScanInAllDirections) relative(Direction.Axis axis, int steps) Offsets this Vector by the given distance in the specified direction.south()south(int steps) static Iterable<BlockPos.MutableBlockPos> spiralAround(BlockPos center, int radius, Direction firstDirection, Direction secondDirection) squareOutSouthEast(BlockPos from) Deprecated.west()west(int steps) withinManhattan(BlockPos origin, int reachX, int reachY, int reachZ) withinManhattanStream(BlockPos origin, int reachX, int reachY, int reachZ) Returns a stream of positions in a box shape, ordered by closest to furthest.Methods inherited from class Vec3i
closerThan, closerToCenterThan, compareTo, distChessboard, distManhattan, distSqr, distToCenterSqr, distToCenterSqr, distToLowCornerSqr, equals, get, getX, getY, getZ, hashCode, multiply, offsetCodec, setX, setY, setZ, toMutable, toShortString, toString
-
Field Details
-
CODEC
-
STREAM_CODEC
-
ZERO
An immutable BlockPos with zero as all coordinates. -
PACKED_HORIZONTAL_LENGTH
public static final int PACKED_HORIZONTAL_LENGTH -
PACKED_Y_LENGTH
public static final int PACKED_Y_LENGTH -
PACKED_X_MASK
private static final long PACKED_X_MASK -
PACKED_Y_MASK
private static final long PACKED_Y_MASK -
PACKED_Z_MASK
private static final long PACKED_Z_MASK -
Y_OFFSET
private static final int Y_OFFSET- See Also:
-
Z_OFFSET
private static final int Z_OFFSET -
X_OFFSET
private static final int X_OFFSET -
MAX_HORIZONTAL_COORDINATE
public static final int MAX_HORIZONTAL_COORDINATE
-
-
Constructor Details
-
BlockPos
public BlockPos(int x, int y, int z) -
BlockPos
-
-
Method Details
-
offset
-
offset
public static long offset(long blockNode, int stepX, int stepY, int stepZ) -
getX
public static int getX(long blockNode) -
getY
public static int getY(long blockNode) -
getZ
public static int getZ(long blockNode) -
of
-
containing
-
containing
-
min
-
max
-
asLong
public long asLong() -
asLong
public static long asLong(int x, int y, int z) -
getFlatIndex
public static long getFlatIndex(long neighborBlockNode) -
offset
-
getCenter
-
getBottomCenter
-
offset
-
subtract
-
multiply
-
above
-
above
-
below
-
below
-
north
-
north
-
south
-
south
-
west
-
west
-
east
-
east
-
relative
-
relative
-
relative
-
rotate
-
cross
-
atY
-
immutable
-
mutable
-
clampLocationWithin
-
randomInCube
public static Iterable<BlockPos> randomInCube(RandomSource random, int limit, BlockPos center, int sizeToScanInAllDirections) -
squareOutSouthEast
Deprecated. -
randomBetweenClosed
public static Iterable<BlockPos> randomBetweenClosed(RandomSource random, int limit, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) -
withinManhattan
-
findClosestMatch
-
withinManhattanStream
-
betweenClosed
-
betweenClosed
-
betweenClosedStream
-
betweenClosedStream
-
betweenClosedStream
-
betweenClosedStream
-
betweenClosed
public static Iterable<BlockPos> betweenClosed(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) Creates an Iterable that returns all positions in the box specified by the given corners. Coordinates must be in order. e.g. x1 invalid input: '<'= x2. This method usesMutableBlockPosinstead of regular BlockPos, which grants better performance. However, the resulting BlockPos instances can only be used inside the iteration loop (as otherwise the value will change), unlessis called. This method is ideal for searching large areas and only storing a few locations.invalid reference
#toImmutable()- See Also:
-
spiralAround
public static Iterable<BlockPos.MutableBlockPos> spiralAround(BlockPos center, int radius, Direction firstDirection, Direction secondDirection) -
breadthFirstTraversal
public static int breadthFirstTraversal(BlockPos startPos, int maxDepth, int maxCount, BiConsumer<BlockPos, Consumer<BlockPos>> neighbourProvider, Function<BlockPos, BlockPos.TraversalNodeStatus> nodeProcessor) -
betweenCornersInDirection
-
betweenCornersInDirection
-
betweenCornersInDirection
-