Package net.xun.lib.common.api.util
Class BlockPosUtils
java.lang.Object
net.xun.lib.common.api.util.BlockPosUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.phys.AABBcreateAABBFromCenter(net.minecraft.core.BlockPos center, double xRadius, double yRadius, double zRadius) Creates an AABB centered at the specified BlockPos with given radii in each axis.static net.minecraft.world.phys.AABBcreateAABBFromCorners(net.minecraft.core.BlockPos corner1, net.minecraft.core.BlockPos corner2) Creates an AABB spanning between two BlockPos corners (inclusive).static booleandoesAABBIntersectBlock(net.minecraft.world.phys.AABB aabb, net.minecraft.core.BlockPos pos) Checks if a BlockPos's corresponding block area intersects with an AABB.static net.minecraft.world.phys.AABBexpandAABB(net.minecraft.world.phys.AABB original, double x, double y, double z) Expands an AABB by specified amounts in each direction.static List<net.minecraft.core.BlockPos> getBlocksInAABB(net.minecraft.world.phys.AABB aabb) Retrieves all BlockPos that intersect with the given AABB.static List<net.minecraft.core.BlockPos> getDisc(net.minecraft.core.BlockPos center, int radius) Generates a 2D circular disc of BlockPos around a center point at the same Y level.static List<net.minecraft.core.BlockPos> getHollowCube(net.minecraft.core.BlockPos center, int radius) Generates positions for a hollow cubic frame around a center point.static Optional<net.minecraft.world.phys.AABB> getIntersectionAABB(net.minecraft.world.phys.AABB a, net.minecraft.world.phys.AABB b) Computes the intersection of two AABBs if they overlap.static List<net.minecraft.core.BlockPos> getSphere(net.minecraft.core.BlockPos center, int radius) Generates a 3D sphere of BlockPos around a center point.static List<net.minecraft.core.BlockPos> getSquare(net.minecraft.core.BlockPos center, int radius) Generates a 2D square of BlockPos around a center point at the same Y level.static net.minecraft.world.phys.AABBgetUnionAABB(net.minecraft.world.phys.AABB a, net.minecraft.world.phys.AABB b) Computes the union AABB that fully contains both input AABBs.static booleanisWithinCube(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos center, int radius) Checks if a position is within a cubic area around a center.static booleanisWithinSphere(net.minecraft.core.BlockPos a, net.minecraft.core.BlockPos b, double radius) Checks if a position is within a spherical radius of another position.static net.minecraft.core.BlockPosmove(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction dir, int steps) Moves a position in a specific direction.
-
Method Details
-
getDisc
public static List<net.minecraft.core.BlockPos> getDisc(net.minecraft.core.BlockPos center, int radius) Generates a 2D circular disc of BlockPos around a center point at the same Y level.- Parameters:
center- The center position of the discradius- The radius of the disc in blocks- Returns:
- List of BlockPos forming a horizontal circular pattern
-
getSquare
public static List<net.minecraft.core.BlockPos> getSquare(net.minecraft.core.BlockPos center, int radius) Generates a 2D square of BlockPos around a center point at the same Y level.- Parameters:
center- The center position of the squareradius- The distance from center to edge in blocks- Returns:
- List of BlockPos forming a horizontal square pattern
-
getSphere
public static List<net.minecraft.core.BlockPos> getSphere(net.minecraft.core.BlockPos center, int radius) Generates a 3D sphere of BlockPos around a center point.- Parameters:
center- The center position of the sphereradius- The radius of the sphere in blocks- Returns:
- List of BlockPos forming a spherical pattern
-
getHollowCube
public static List<net.minecraft.core.BlockPos> getHollowCube(net.minecraft.core.BlockPos center, int radius) Generates positions for a hollow cubic frame around a center point.- Parameters:
center- The center position of the cuberadius- The distance from center to any face in blocks- Returns:
- List of BlockPos forming the surface of a cube
-
isWithinSphere
public static boolean isWithinSphere(net.minecraft.core.BlockPos a, net.minecraft.core.BlockPos b, double radius) Checks if a position is within a spherical radius of another position.- Parameters:
a- Position to checkb- Center position of the sphereradius- Sphere radius in blocks- Returns:
- True if position is within or on the sphere surface
-
isWithinCube
public static boolean isWithinCube(net.minecraft.core.BlockPos pos, net.minecraft.core.BlockPos center, int radius) Checks if a position is within a cubic area around a center.- Parameters:
pos- Position to checkcenter- Center of the cuberadius- Cube radius (distance from center to any face)- Returns:
- True if position is within or on the cube surface
-
move
public static net.minecraft.core.BlockPos move(net.minecraft.core.BlockPos pos, net.minecraft.core.Direction dir, int steps) Moves a position in a specific direction.- Parameters:
pos- Starting positiondir- Direction to movesteps- Number of blocks to move- Returns:
- New position after movement
-
createAABBFromCenter
public static net.minecraft.world.phys.AABB createAABBFromCenter(net.minecraft.core.BlockPos center, double xRadius, double yRadius, double zRadius) Creates an AABB centered at the specified BlockPos with given radii in each axis.- Parameters:
center- The center point of the AABB.xRadius- The radius along the X-axis.yRadius- The radius along the Y-axis.zRadius- The radius along the Z-axis.- Returns:
- A new AABB centered at the given position with the specified radii.
-
createAABBFromCorners
public static net.minecraft.world.phys.AABB createAABBFromCorners(net.minecraft.core.BlockPos corner1, net.minecraft.core.BlockPos corner2) Creates an AABB spanning between two BlockPos corners (inclusive).- Parameters:
corner1- First corner of the AABB.corner2- Second corner of the AABB.- Returns:
- An AABB covering all blocks between the corners, including their edges.
-
getBlocksInAABB
Retrieves all BlockPos that intersect with the given AABB.- Parameters:
aabb- The AABB to check for intersections.- Returns:
- List of BlockPos that intersect the AABB.
-
doesAABBIntersectBlock
public static boolean doesAABBIntersectBlock(net.minecraft.world.phys.AABB aabb, net.minecraft.core.BlockPos pos) Checks if a BlockPos's corresponding block area intersects with an AABB.- Parameters:
aabb- The AABB to check against.pos- The BlockPos to test.- Returns:
- True if the block's AABB intersects the given AABB.
-
expandAABB
public static net.minecraft.world.phys.AABB expandAABB(net.minecraft.world.phys.AABB original, double x, double y, double z) Expands an AABB by specified amounts in each direction.- Parameters:
original- The original AABB.x- Amount to expand along the X-axis (both directions).y- Amount to expand along the Y-axis (both directions).z- Amount to expand along the Z-axis (both directions).- Returns:
- A new expanded AABB.
-
getIntersectionAABB
public static Optional<net.minecraft.world.phys.AABB> getIntersectionAABB(net.minecraft.world.phys.AABB a, net.minecraft.world.phys.AABB b) Computes the intersection of two AABBs if they overlap.- Parameters:
a- First AABB.b- Second AABB.- Returns:
- Optional containing the intersecting AABB, or empty if no overlap.
-
getUnionAABB
public static net.minecraft.world.phys.AABB getUnionAABB(net.minecraft.world.phys.AABB a, net.minecraft.world.phys.AABB b) Computes the union AABB that fully contains both input AABBs.- Parameters:
a- First AABB.b- Second AABB.- Returns:
- A new AABB encompassing both input AABBs.
-