Class BlockPos

java.lang.Object
net.minecraft.core.Vec3i
net.minecraft.core.BlockPos
All Implemented Interfaces:
Comparable<Vec3i>
Direct Known Subclasses:
BlockPos.MutableBlockPos

@Immutable public class BlockPos extends Vec3i
  • Field Details

    • CODEC

      public static final com.mojang.serialization.Codec<BlockPos> CODEC
    • STREAM_CODEC

      public static final StreamCodec<io.netty.buffer.ByteBuf,BlockPos> STREAM_CODEC
    • ZERO

      public static final BlockPos 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 pX, int pY, int pZ)
    • BlockPos

      public BlockPos(Vec3i pVector)
  • Method Details

    • offset

      public static long offset(long pPos, Direction pDirection)
    • offset

      public static long offset(long pPos, int pDx, int pDy, int pDz)
    • getX

      public static int getX(long pPackedPos)
    • getY

      public static int getY(long pPackedPos)
    • getZ

      public static int getZ(long pPackedPos)
    • of

      public static BlockPos of(long pPackedPos)
    • containing

      public static BlockPos containing(double pX, double pY, double pZ)
    • containing

      public static BlockPos containing(Position pPosition)
    • min

      public static BlockPos min(BlockPos pPos1, BlockPos pPos2)
    • max

      public static BlockPos max(BlockPos pPos1, BlockPos pPos2)
    • asLong

      public long asLong()
    • asLong

      public static long asLong(int pX, int pY, int pZ)
    • getFlatIndex

      public static long getFlatIndex(long pPackedPos)
    • offset

      public BlockPos offset(int p_121973_, int p_121974_, int p_121975_)
      Overrides:
      offset in class Vec3i
    • getCenter

      public Vec3 getCenter()
    • getBottomCenter

      public Vec3 getBottomCenter()
    • offset

      public BlockPos offset(Vec3i p_121956_)
      Overrides:
      offset in class Vec3i
    • subtract

      public BlockPos subtract(Vec3i pVector)
      Overrides:
      subtract in class Vec3i
    • multiply

      public BlockPos multiply(int p_175263_)
      Overrides:
      multiply in class Vec3i
    • above

      public BlockPos above()
      Overrides:
      above in class Vec3i
    • above

      public BlockPos above(int p_121972_)
      Description copied from class: Vec3i
      Offset this vector upwards by the given distance.
      Overrides:
      above in class Vec3i
    • below

      public BlockPos below()
      Overrides:
      below in class Vec3i
    • below

      public BlockPos below(int p_122000_)
      Description copied from class: Vec3i
      Offset this vector downwards by the given distance.
      Overrides:
      below in class Vec3i
    • north

      public BlockPos north()
      Overrides:
      north in class Vec3i
    • north

      public BlockPos north(int p_122014_)
      Overrides:
      north in class Vec3i
    • south

      public BlockPos south()
      Overrides:
      south in class Vec3i
    • south

      public BlockPos south(int pDistance)
      Overrides:
      south in class Vec3i
    • west

      public BlockPos west()
      Overrides:
      west in class Vec3i
    • west

      public BlockPos west(int p_122026_)
      Overrides:
      west in class Vec3i
    • east

      public BlockPos east()
      Overrides:
      east in class Vec3i
    • east

      public BlockPos east(int p_122031_)
      Overrides:
      east in class Vec3i
    • relative

      public BlockPos relative(Direction pDirection)
      Overrides:
      relative in class Vec3i
    • relative

      public BlockPos relative(Direction pDirection, int p_121949_)
      Description copied from class: Vec3i
      Offsets this Vector by the given distance in the specified direction.
      Overrides:
      relative in class Vec3i
    • relative

      public BlockPos relative(Direction.Axis p_121943_, int p_121944_)
      Overrides:
      relative in class Vec3i
    • rotate

      public BlockPos rotate(Rotation pRotation)
    • cross

      public BlockPos cross(Vec3i pVector)
      Description copied from class: Vec3i
      Calculate the cross product of this and the given Vector
      Overrides:
      cross in class Vec3i
    • atY

      public BlockPos atY(int pY)
    • immutable

      public BlockPos immutable()
    • mutable

      public BlockPos.MutableBlockPos mutable()
    • clampLocationWithin

      public Vec3 clampLocationWithin(Vec3 pPos)
    • randomInCube

      public static Iterable<BlockPos> randomInCube(RandomSource pRandom, int pAmount, BlockPos pCenter, int pRadius)
    • squareOutSouthEast

      @Deprecated public static Stream<BlockPos> squareOutSouthEast(BlockPos pPos)
      Deprecated.
    • randomBetweenClosed

      public static Iterable<BlockPos> randomBetweenClosed(RandomSource pRandom, int pAmount, int pMinX, int pMinY, int pMinZ, int pMaxX, int pMaxY, int pMaxZ)
    • withinManhattan

      public static Iterable<BlockPos> withinManhattan(BlockPos pPos, int pXSize, int pYSize, int pZSize)
    • findClosestMatch

      public static Optional<BlockPos> findClosestMatch(BlockPos pPos, int pWidth, int pHeight, Predicate<BlockPos> pPosFilter)
    • withinManhattanStream

      public static Stream<BlockPos> withinManhattanStream(BlockPos pPos, int pXSize, int pYSize, int pZSize)
      Returns a stream of positions in a box shape, ordered by closest to furthest. Returns by definition the given position as first element in the stream.
    • betweenClosed

      public static Iterable<BlockPos> betweenClosed(AABB pBox)
    • betweenClosed

      public static Iterable<BlockPos> betweenClosed(BlockPos pFirstPos, BlockPos pSecondPos)
    • betweenClosedStream

      public static Stream<BlockPos> betweenClosedStream(BlockPos pFirstPos, BlockPos pSecondPos)
    • betweenClosedStream

      public static Stream<BlockPos> betweenClosedStream(BoundingBox pBox)
    • betweenClosedStream

      public static Stream<BlockPos> betweenClosedStream(AABB pAabb)
    • betweenClosedStream

      public static Stream<BlockPos> betweenClosedStream(int pMinX, int pMinY, int pMinZ, int pMaxX, int pMaxY, int pMaxZ)
    • betweenClosed

      public static Iterable<BlockPos> betweenClosed(int pX1, int pY1, int pZ1, int pX2, int pY2, int pZ2)
      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 uses MutableBlockPos instead 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), unless
      invalid reference
      #toImmutable()
      is called. This method is ideal for searching large areas and only storing a few locations.
      See Also:
    • spiralAround

      public static Iterable<BlockPos.MutableBlockPos> spiralAround(BlockPos pCenter, int pSize, Direction pRotationDirection, Direction pExpansionDirection)
    • breadthFirstTraversal

      public static int breadthFirstTraversal(BlockPos pStartPos, int pRadius, int pMaxBlocks, BiConsumer<BlockPos,Consumer<BlockPos>> pChildrenGetter, Function<BlockPos,BlockPos.TraversalNodeStatus> pAction)
    • betweenCornersInDirection

      public static Iterable<BlockPos> betweenCornersInDirection(AABB pBoundingBox, Vec3 pDirection)
    • betweenCornersInDirection

      public static Iterable<BlockPos> betweenCornersInDirection(BlockPos pPos1, BlockPos pPos2, Vec3 pDirection)
    • betweenCornersInDirection

      public static Iterable<BlockPos> betweenCornersInDirection(int pX1, int pY1, int pZ1, int pX2, int pY2, int pZ2, Vec3 pDirection)