PositionUtils provides helpers for computing random positions, ground-level searches, distance checks, and direction calculations around entities and world coordinates.
When to use it
You need a random position on the horizontal plane around a center point.
You need a uniformly distributed random point inside a circle, cone, or rectangular strip.
You need to find a ground-level or passable-floor position near an entity or anchor.
You want horizontal (XZ-plane) distance checks that ignore the Y axis.
You need normalized direction vectors or angles between positions.
Quick examples
Random horizontal offset
usingArcanumLib.Geometry;// Random position between 2 and 5 blocks from centervaroffset=PositionUtils.GetRandomHorizontalOffset(center,minDist:2,maxDist:5,rand);
Random point in shape
// Uniform point inside a circle (sqrt sampling, no center clustering)varp=PositionUtils.GetRandomPointInCircle(center,radius:4,rand);// Point inside a cone (sector) — 30° half-angle, pointing eastvarp=PositionUtils.GetRandomPointInCone(apex,newVec3d(1,0,0),radius:5,halfAngleDegrees:30,rand);// Point inside a rectangular strip (line) — 8 long, 2 widevarp=PositionUtils.GetRandomPointInLine(origin,direction,length:8,width:2,rand);
Ground-level search
// Random ground position around an entityif(PositionUtils.TryGetRandomGroundPositionAround(entity,3,8,blockAccessor,rand,outvargroundPos)){// Use groundPos}// Find a passable floor near an anchor Y (feet+head passable, ground solid)if(PositionUtils.TryFindLocalFloor(blockAccessor,pos,anchorY:70,maxDelta:3,outintfeetY)){// Use feetY}
Horizontal distance
doubledist=PositionUtils.HorizontalDistanceTo(player.Pos.XYZ,target.Pos.XYZ);if(PositionUtils.IsWithinHorizontalRange(player.Entity,target.Pos.XYZ,range:12)){// Player is within 12 blocks (ignoring Y)}