Class BlockPosUtil

java.lang.Object
com.minecolonies.api.util.BlockPosUtil

public final class BlockPosUtil extends Object
Utility methods for BlockPos.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final BiPredicate<net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos>
    Selects a double air position
    static final List<net.minecraft.core.Direction>
    All directions.
    static final net.minecraft.core.BlockPos
    Hopefully future proof safe zero pos
    static final BiPredicate<net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos>
    Selects a solid position with air above
  • Method Summary

    Modifier and Type
    Method
    Description
    calcDirection(@NotNull net.minecraft.core.BlockPos building, @NotNull net.minecraft.core.BlockPos pos)
    Calculates the direction a position is from the building.
    static net.minecraft.core.Direction
    directionFromDelta(int x, int y, int z)
    Calculate a direction from a given delta.
    static double
    dist(int x1, int y1, int z1, int x2, int y2, int z2)
    Euclidean distance
    static double
    dist(net.minecraft.core.BlockPos pos, int x2, int y2, int z2)
    Euclidean distance
    static double
    dist(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos pos2)
    Euclidean distance
    static int
    distManhattan(int x1, int y1, int z1, int x2, int y2, int z2)
    Manhatten distance
    static int
    distManhattan(net.minecraft.core.BlockPos pos, int x2, int y2, int z2)
    Manhatten distance
    static int
    distManhattan(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos pos2)
    Manhatten distance
    static int
    distSqr(int x1, int y1, int z1, int x2, int y2, int z2)
    Square distance
    static int
    distSqr(net.minecraft.core.BlockPos pos, int x2, int y2, int z2)
    Square distance
    static int
    distSqr(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos pos2)
    Square distance
    static boolean
    equals(int x1, int y1, int z1, int x2, int y2, int z2)
     
    static boolean
    equals(@NotNull net.minecraft.core.BlockPos coords, int x, int y, int z)
    Returns whether a chunk coordinate is equals to (x, y, z).
    static boolean
    equals(net.minecraft.core.BlockPos pos1, net.minecraft.core.BlockPos pos2)
     
    static net.minecraft.core.BlockPos
    findAround(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos start, int verticalRange, int horizontalRange, BiPredicate<net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos> predicate)
    Returns the first air position near the given start.
    static net.minecraft.core.BlockPos
    findLand(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.Level world)
    this checks that you are not in the air or underground.
    static net.minecraft.core.BlockPos
    findSpawnPosAround(net.minecraft.world.level.Level worldReader, net.minecraft.core.BlockPos start)
    Finds a spawn pos around the given startpos with two air blocks
    static @NotNull net.minecraft.core.BlockPos
    fromEntity(@NotNull net.minecraft.world.entity.Entity entity)
    Returns the Chunk Coordinate created from an entity.
    static net.minecraft.world.level.block.Block
    getBlock(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos coords)
    Returns the block at a specific chunk coordinate.
    static List<net.minecraft.world.item.ItemStack>
    getBlockDrops(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos coords, int fortune, net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity)
    Returns a list of drops possible mining a specific block with specific fortune level.
    static @Nullable net.minecraft.core.BlockPos
    getBlockPosOfString(@NotNull String inputText)
    Try to parse a blockPos of an input string.
    static net.minecraft.world.level.block.state.BlockState
    getBlockState(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos coords)
    Returns the metadata of a block at a specific chunk coordinate.
    static net.minecraft.world.level.levelgen.structure.BoundingBox
    getChunkAlignedBB(net.minecraft.core.BlockPos pos, int chunkRadius)
    Returns a radial bounding box aligned to chunk boundaries.
    static double
    getDistance(net.minecraft.core.BlockPos pos1, net.minecraft.core.BlockPos pos2)
    Gets the actual distance in blocks between two positions
    static long
    getDistance2D(@NotNull net.minecraft.core.BlockPos block1, @NotNull net.minecraft.core.BlockPos block2)
    X+Z Distance between two BlockPos.
    static long
    getDistanceSquared(@NotNull net.minecraft.core.BlockPos block1, @NotNull net.minecraft.core.BlockPos block2)
    Squared distance between two BlockPos.
    static long
    getDistanceSquared2D(@NotNull net.minecraft.core.BlockPos block1, @NotNull net.minecraft.core.BlockPos block2)
    2D Squared distance between two BlockPos.
    static net.minecraft.core.Direction
    getFacing(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos neighbor)
    Calculate in which direction a pos is facing.
    static @NotNull net.minecraft.core.BlockPos
    getFloor(@NotNull net.minecraft.core.BlockPos position, @NotNull net.minecraft.world.level.Level world)
    Calculates the floor level.
    static @Nullable net.minecraft.core.BlockPos
    getFloor(net.minecraft.core.BlockPos.MutableBlockPos position, int depth, @NotNull net.minecraft.world.level.Level world)
    Calculates the floor level.
    static net.minecraft.core.BlockPos
    getFurthestCorner(net.minecraft.core.BlockPos startPos, net.minecraft.core.BlockPos boxStart, net.minecraft.core.BlockPos boxEnd)
    Get the furthest corner from a pos.
    static int
    getMaxDistance2D(@NotNull net.minecraft.core.BlockPos block1, @NotNull net.minecraft.core.BlockPos block2)
    Maximum of x/z distance between two blocks.
    static net.minecraft.core.BlockPos
    getRandomPosAround(net.minecraft.core.BlockPos center, int distance)
    Searches a random direction.
    static net.minecraft.core.BlockPos
    getRandomPosition(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos currentPosition, net.minecraft.core.BlockPos def, int minDist, int maxDist)
    Gets a random position within a certain range for wandering around.
    static net.minecraft.core.BlockPos
    getRandomPosition(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos currentPosition, net.minecraft.core.BlockPos def, int minDist, int maxDist, boolean load)
    Gets a random position within a certain range for wandering around.
    static @NotNull String
    getString(@NotNull net.minecraft.core.BlockPos position)
    Returns a string representation of the block position for use in GUIs and chats.
    static net.minecraft.world.level.block.entity.BlockEntity
    getTileEntity(@NotNull net.minecraft.world.level.Level world, @NotNull net.minecraft.core.BlockPos pos)
    Returns the tile entity at a specific chunk coordinate.
    static double
    getValidHeight(@NotNull net.minecraft.world.phys.Vec3 position, @NotNull net.minecraft.world.level.Level world)
    Returns the right height for the given position (ground block).
    static net.minecraft.core.Direction
    getXZFacing(int pos1X, int pos1Z, int pos2X, int pos2Z)
    Get facing from x,y
    static net.minecraft.core.Direction
    getXZFacing(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos neighbor)
    Calculate in which direction a pos is facing.
    static boolean
    isInArea(net.minecraft.core.BlockPos cornerA, net.minecraft.core.BlockPos cornerB, net.minecraft.core.BlockPos location)
    Check if a location is within an area.
    static @NotNull net.minecraft.core.BlockPos
    read(@NotNull net.minecraft.nbt.CompoundTag compound, String name)
    Reads Chunk Coordinates from an NBT Compound with a specific tag name.
    static @NotNull net.minecraft.core.BlockPos
    readFromListNBT(@NotNull net.minecraft.nbt.ListTag tagList, int index)
    Reads a Chunk Coordinate from a tag list.
    static @Nullable net.minecraft.core.BlockPos
    readOrNull(@NotNull net.minecraft.nbt.CompoundTag compound, @NotNull String name)
    Reads chunk coordinates from a CompoundTag, but returns null if zero or absent.
    static List<net.minecraft.core.BlockPos>
    readPosListFromNBT(net.minecraft.nbt.CompoundTag compoundNBT, String tagname)
    Reads a list of block positions from NBT
    static void
    set(net.minecraft.core.BlockPos.MutableBlockPos pos, @NotNull net.minecraft.core.BlockPos newPos)
    Create a method for using a BlockPos.
    static boolean
    setBlock(@NotNull net.minecraft.world.level.Level worldIn, @NotNull net.minecraft.core.BlockPos coords, net.minecraft.world.level.block.state.BlockState state, int flag)
    Sets a block in the world, with specific metadata and flags.
    static net.minecraft.nbt.CompoundTag
    write(@NotNull net.minecraft.nbt.CompoundTag compound, String name, @NotNull net.minecraft.core.BlockPos pos)
    Writes a Chunk Coordinate to an NBT compound, with a specific tag name.
    static @NotNull net.minecraft.nbt.CompoundTag
    writeOptional(@NotNull net.minecraft.nbt.CompoundTag compound, @NotNull String name, @Nullable net.minecraft.core.BlockPos value)
    Writes a chunk coordinate to a CompoundTag, but only if not null.
    static void
    writePosListToNBT(net.minecraft.nbt.CompoundTag compoundNBT, String tagname, List<net.minecraft.core.BlockPos> positions)
    Write a list of positions to a compound
    static void
    writeToListNBT(@NotNull net.minecraft.nbt.ListTag tagList, @NotNull net.minecraft.core.BlockPos pos)
    Write a compound with chunk coordinate to a tag list.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HORIZONTAL_DIRS

      public static final List<net.minecraft.core.Direction> HORIZONTAL_DIRS
      All directions.
    • SAFE_ZERO

      public static final net.minecraft.core.BlockPos SAFE_ZERO
      Hopefully future proof safe zero pos
    • SOLID_AIR_POS_SELECTOR

      public static final BiPredicate<net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos> SOLID_AIR_POS_SELECTOR
      Selects a solid position with air above
    • DOUBLE_AIR_POS_SELECTOR

      public static final BiPredicate<net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos> DOUBLE_AIR_POS_SELECTOR
      Selects a double air position
  • Method Details

    • write

      public static net.minecraft.nbt.CompoundTag write(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound, String name, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Writes a Chunk Coordinate to an NBT compound, with a specific tag name.
      Parameters:
      compound - Compound to write to.
      name - Name of the tag.
      pos - Coordinates to write to NBT.
      Returns:
      the resulting compound.
    • writeOptional

      @NotNull public static @NotNull net.minecraft.nbt.CompoundTag writeOptional(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound, @NotNull @NotNull String name, @Nullable @Nullable net.minecraft.core.BlockPos value)
      Writes a chunk coordinate to a CompoundTag, but only if not null.
      Parameters:
      compound - Compound to write to.
      name - Name of the tag.
      value - Coordinates to write; if null, the tag is not written.
      Returns:
      the resulting compound.
    • getRandomPosAround

      public static net.minecraft.core.BlockPos getRandomPosAround(net.minecraft.core.BlockPos center, int distance)
      Searches a random direction.
      Returns:
      a tuple of two directions.
    • getRandomPosition

      public static net.minecraft.core.BlockPos getRandomPosition(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos currentPosition, net.minecraft.core.BlockPos def, int minDist, int maxDist)
      Gets a random position within a certain range for wandering around.
      Parameters:
      world - the world.
      currentPosition - the current position.
      def - the default position if none was found.
      minDist - the minimum distance of the pos.
      maxDist - the maximum distance.
      Returns:
      the BlockPos.
    • getRandomPosition

      public static net.minecraft.core.BlockPos getRandomPosition(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos currentPosition, net.minecraft.core.BlockPos def, int minDist, int maxDist, boolean load)
      Gets a random position within a certain range for wandering around.
      Parameters:
      world - the world.
      currentPosition - the current position.
      def - the default position if none was found.
      minDist - the minimum distance of the pos.
      maxDist - the maximum distance.
      load - whether chunks should get loaded if needed
      Returns:
      the BlockPos.
    • read

      @NotNull public static @NotNull net.minecraft.core.BlockPos read(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound, String name)
      Reads Chunk Coordinates from an NBT Compound with a specific tag name.
      Parameters:
      compound - Compound to read data from.
      name - Tag name to read data from.
      Returns:
      Chunk coordinates read from the compound.
    • readOrNull

      @Nullable public static @Nullable net.minecraft.core.BlockPos readOrNull(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound, @NotNull @NotNull String name)
      Reads chunk coordinates from a CompoundTag, but returns null if zero or absent.
      Parameters:
      compound - Compound to read data from.
      name - Tag name to read data from.
      Returns:
      Chunk coordinates read from the compound, or null if it was zero or absent.
    • writeToListNBT

      public static void writeToListNBT(@NotNull @NotNull net.minecraft.nbt.ListTag tagList, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Write a compound with chunk coordinate to a tag list.
      Parameters:
      tagList - Tag list to write compound with chunk coordinates to.
      pos - Coordinate to write to the tag list.
    • writePosListToNBT

      public static void writePosListToNBT(net.minecraft.nbt.CompoundTag compoundNBT, String tagname, List<net.minecraft.core.BlockPos> positions)
      Write a list of positions to a compound
      Parameters:
      compoundNBT - compound to save the list on
      tagname - key to save the list on
      positions - block positions to write
    • readPosListFromNBT

      public static List<net.minecraft.core.BlockPos> readPosListFromNBT(net.minecraft.nbt.CompoundTag compoundNBT, String tagname)
      Reads a list of block positions from NBT
      Parameters:
      compoundNBT - compound the list is in
      tagname - key of the list
      Returns:
      list of block positions
    • readFromListNBT

      @NotNull public static @NotNull net.minecraft.core.BlockPos readFromListNBT(@NotNull @NotNull net.minecraft.nbt.ListTag tagList, int index)
      Reads a Chunk Coordinate from a tag list.
      Parameters:
      tagList - Tag list to read compound with chunk coordinate from.
      index - Index in the tag list where the required chunk coordinate is.
      Returns:
      Chunk coordinate read from the tag list.
    • getBlockPosOfString

      @Nullable public static @Nullable net.minecraft.core.BlockPos getBlockPosOfString(@NotNull @NotNull String inputText)
      Try to parse a blockPos of an input string.
      Parameters:
      inputText - the string to parse.
      Returns:
      the blockPos if able to.
    • getString

      @NotNull public static @NotNull String getString(@NotNull @NotNull net.minecraft.core.BlockPos position)
      Returns a string representation of the block position for use in GUIs and chats.
      Parameters:
      position - The position of the string to be returned
      Returns:
      The string representation of the block position
    • findLand

      public static net.minecraft.core.BlockPos findLand(net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.Level world)
      this checks that you are not in the air or underground. If so it will look up and down for a good landing spot before TP.
      Parameters:
      blockPos - for the current block LOC.
      world - the world to search in.
      Returns:
      blockPos to be used for the TP.
    • getValidHeight

      public static double getValidHeight(@NotNull @NotNull net.minecraft.world.phys.Vec3 position, @NotNull @NotNull net.minecraft.world.level.Level world)
      Returns the right height for the given position (ground block).
      Parameters:
      position - Current position of the entity.
      world - the world object.
      Returns:
      Ground level at (position.x, position.z).
    • getDistanceSquared

      public static long getDistanceSquared(@NotNull @NotNull net.minecraft.core.BlockPos block1, @NotNull @NotNull net.minecraft.core.BlockPos block2)
      Squared distance between two BlockPos.
      Parameters:
      block1 - position one.
      block2 - position two.
      Returns:
      squared distance.
    • getDistance2D

      public static long getDistance2D(@NotNull @NotNull net.minecraft.core.BlockPos block1, @NotNull @NotNull net.minecraft.core.BlockPos block2)
      X+Z Distance between two BlockPos.
      Parameters:
      block1 - position one.
      block2 - position two.
      Returns:
      X+Z distance
    • getMaxDistance2D

      public static int getMaxDistance2D(@NotNull @NotNull net.minecraft.core.BlockPos block1, @NotNull @NotNull net.minecraft.core.BlockPos block2)
      Maximum of x/z distance between two blocks.
      Parameters:
      block1 - position one.
      block2 - position two.
      Returns:
      X or Z distance
    • getDistance

      public static double getDistance(net.minecraft.core.BlockPos pos1, net.minecraft.core.BlockPos pos2)
      Gets the actual distance in blocks between two positions
      Parameters:
      pos1 - Blockpos 1
      pos2 - Blockpos 2
      Returns:
      distance in blocks.
    • getDistanceSquared2D

      public static long getDistanceSquared2D(@NotNull @NotNull net.minecraft.core.BlockPos block1, @NotNull @NotNull net.minecraft.core.BlockPos block2)
      2D Squared distance between two BlockPos.
      Parameters:
      block1 - position one.
      block2 - position two.
      Returns:
      2D squared distance.
    • distManhattan

      public static int distManhattan(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos pos2)
      Manhatten distance
    • distManhattan

      public static int distManhattan(net.minecraft.core.BlockPos pos, int x2, int y2, int z2)
      Manhatten distance
    • distManhattan

      public static int distManhattan(int x1, int y1, int z1, int x2, int y2, int z2)
      Manhatten distance
    • distSqr

      public static int distSqr(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos pos2)
      Square distance
    • distSqr

      public static int distSqr(net.minecraft.core.BlockPos pos, int x2, int y2, int z2)
      Square distance
    • distSqr

      public static int distSqr(int x1, int y1, int z1, int x2, int y2, int z2)
      Square distance
    • dist

      public static double dist(net.minecraft.core.BlockPos pos, int x2, int y2, int z2)
      Euclidean distance
    • dist

      public static double dist(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos pos2)
      Euclidean distance
    • dist

      public static double dist(int x1, int y1, int z1, int x2, int y2, int z2)
      Euclidean distance
    • getChunkAlignedBB

      public static net.minecraft.world.level.levelgen.structure.BoundingBox getChunkAlignedBB(net.minecraft.core.BlockPos pos, int chunkRadius)
      Returns a radial bounding box aligned to chunk boundaries. Note that the Y coordinate is also aligned to chunk-like sizes; this does not return full world height. (It also might return Y coordinates outside the world limits, so clip before using if needed.)
      Parameters:
      pos - A position inside the center chunk.
      chunkRadius - 0 for one chunk, 1 for nine chunks, etc.
      Returns:
      The specified bounding box.
    • getTileEntity

      public static net.minecraft.world.level.block.entity.BlockEntity getTileEntity(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Returns the tile entity at a specific chunk coordinate.
      Parameters:
      world - World the tile entity is in.
      pos - Coordinates of the tile entity.
      Returns:
      Tile entity at the given coordinates.
    • getBlockDrops

      public static List<net.minecraft.world.item.ItemStack> getBlockDrops(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos coords, int fortune, net.minecraft.world.item.ItemStack stack, net.minecraft.world.entity.LivingEntity entity)
      Returns a list of drops possible mining a specific block with specific fortune level.
      Parameters:
      world - World the block is in.
      coords - Coordinates of the block.
      fortune - Level of fortune on the pickaxe.
      stack - the tool.
      Returns:
      List of ItemStack with possible drops.
    • getBlock

      public static net.minecraft.world.level.block.Block getBlock(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos coords)
      Returns the block at a specific chunk coordinate.
      Parameters:
      world - World the block is in.
      coords - Coordinates of the block.
      Returns:
      Block at the given coordinates.
    • getBlockState

      public static net.minecraft.world.level.block.state.BlockState getBlockState(@NotNull @NotNull net.minecraft.world.level.Level world, @NotNull @NotNull net.minecraft.core.BlockPos coords)
      Returns the metadata of a block at a specific chunk coordinate.
      Parameters:
      world - World the block is in.
      coords - Coordinates of the block.
      Returns:
      Metadata of the block at the given coordinates.
    • setBlock

      public static boolean setBlock(@NotNull @NotNull net.minecraft.world.level.Level worldIn, @NotNull @NotNull net.minecraft.core.BlockPos coords, net.minecraft.world.level.block.state.BlockState state, int flag)
      Sets a block in the world, with specific metadata and flags.
      Parameters:
      worldIn - World the block needs to be set in.
      coords - Coordinate to place block.
      state - BlockState to be placed.
      flag - Flag to set.
      Returns:
      True if block is placed, otherwise false.
    • set

      public static void set(@NotNull net.minecraft.core.BlockPos.MutableBlockPos pos, @NotNull @NotNull net.minecraft.core.BlockPos newPos)
      Create a method for using a BlockPos.
      Parameters:
      newPos - The new position to set.
    • equals

      public static boolean equals(@NotNull @NotNull net.minecraft.core.BlockPos coords, int x, int y, int z)
      Returns whether a chunk coordinate is equals to (x, y, z).
      Parameters:
      coords - Chunk Coordinate (point 1).
      x - x-coordinate (point 2).
      y - y-coordinate (point 2).
      z - z-coordinate (point 2).
      Returns:
      True when coordinates are equal, otherwise false.
    • equals

      public static boolean equals(int x1, int y1, int z1, int x2, int y2, int z2)
    • equals

      public static boolean equals(net.minecraft.core.BlockPos pos1, net.minecraft.core.BlockPos pos2)
    • fromEntity

      @NotNull public static @NotNull net.minecraft.core.BlockPos fromEntity(@NotNull @NotNull net.minecraft.world.entity.Entity entity)
      Returns the Chunk Coordinate created from an entity.
      Parameters:
      entity - Entity to create chunk coordinates from.
      Returns:
      Chunk Coordinates created from the entity.
    • getFloor

      @NotNull public static @NotNull net.minecraft.core.BlockPos getFloor(@NotNull @NotNull net.minecraft.core.BlockPos position, @NotNull @NotNull net.minecraft.world.level.Level world)
      Calculates the floor level.
      Parameters:
      position - input position.
      world - the world the position is in.
      Returns:
      returns BlockPos position with air above.
    • getFloor

      @Nullable public static @Nullable net.minecraft.core.BlockPos getFloor(@NotNull net.minecraft.core.BlockPos.MutableBlockPos position, int depth, @NotNull @NotNull net.minecraft.world.level.Level world)
      Calculates the floor level.
      Parameters:
      position - input position.
      depth - the iteration depth.
      world - the world the position is in.
      Returns:
      returns BlockPos position with air above.
    • getFacing

      public static net.minecraft.core.Direction getFacing(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos neighbor)
      Calculate in which direction a pos is facing.
      Parameters:
      pos - the pos.
      neighbor - the block its facing.
      Returns:
      the directions its facing.
    • getXZFacing

      public static net.minecraft.core.Direction getXZFacing(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos neighbor)
      Calculate in which direction a pos is facing. Ignoring y.
      Parameters:
      pos - the pos.
      neighbor - the block its facing.
      Returns:
      the directions its facing.
    • getXZFacing

      public static net.minecraft.core.Direction getXZFacing(int pos1X, int pos1Z, int pos2X, int pos2Z)
      Get facing from x,y
      Parameters:
      pos1X - start-x
      pos1Z - start-z
      pos2X - end-x
      pos2Z - end-z
      Returns:
      the horizontal direction or "up" if it faces neither.
    • directionFromDelta

      public static net.minecraft.core.Direction directionFromDelta(int x, int y, int z)
      Calculate a direction from a given delta.
      Parameters:
      x - the delta x.
      y - the delta y.
      z - the delta z.
      Returns:
      the direction.
    • calcDirection

      public static BlockPosUtil.DirectionResult calcDirection(@NotNull @NotNull net.minecraft.core.BlockPos building, @NotNull @NotNull net.minecraft.core.BlockPos pos)
      Calculates the direction a position is from the building.
      Parameters:
      building - the building.
      pos - the position.
      Returns:
      a text component describing the direction.
    • findAround

      public static net.minecraft.core.BlockPos findAround(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos start, int verticalRange, int horizontalRange, BiPredicate<net.minecraft.world.level.BlockGetter,net.minecraft.core.BlockPos> predicate)
      Returns the first air position near the given start. Advances vertically first then horizontally
      Parameters:
      start - start position
      verticalRange - vertical search range
      horizontalRange - horizontal search range
      predicate - check predicate for the right block
      Returns:
      position or null
    • findSpawnPosAround

      public static net.minecraft.core.BlockPos findSpawnPosAround(net.minecraft.world.level.Level worldReader, net.minecraft.core.BlockPos start)
      Finds a spawn pos around the given startpos with two air blocks
      Parameters:
      worldReader - blockreader
      start - startpos
      Returns:
    • getFurthestCorner

      public static net.minecraft.core.BlockPos getFurthestCorner(net.minecraft.core.BlockPos startPos, net.minecraft.core.BlockPos boxStart, net.minecraft.core.BlockPos boxEnd)
      Get the furthest corner from a pos.
      Parameters:
      startPos - the startpos.
      boxStart - the box start.
      boxEnd - the box end.
      Returns:
      the furthest corner.
    • isInArea

      public static boolean isInArea(net.minecraft.core.BlockPos cornerA, net.minecraft.core.BlockPos cornerB, net.minecraft.core.BlockPos location)
      Check if a location is within an area.
      Parameters:
      cornerA - the first corner.
      cornerB - the second corner.
      location - the location to check for.
      Returns:
      true if so.