// Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
// 
//     private Edges() {
//         // no instances
//     }
// 
//     public static Vector2i getCorner(BlockAreac rc, Orientation o) {
// 
//         int dx = o.direction().x() + 1; //  [0..2]
//         int dy = o.direction().y() + 1; //  [0..2]
// 
//         int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
//         int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
// 
//         return new Vector2i(x, y);
//     }
// 
//     public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
//         int rx = x - rc.minX();
//         int rz = z - rc.minY();
// 
//         // distance to border along both axes
//         int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
//         int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
// 
//         int dist = Math.min(borderDistX, borderDistZ);
//         return dist;
//     }
// 
//     public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
//         return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
//     }
// 
//     public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
//         int dx = Math.min(x - rc.minX(), rc.maxX() - x);
//         int dy = Math.min(y - rc.minY(), rc.maxY() - y);
//         return dx * dx + dy * dy;
//     }
// 
//     public static Line2f getEdge(BlockAreac rc, Orientation o) {
// 
//         Vector2i p0 = getCorner(rc, o.getRotated(-45));
//         Vector2i p1 = getCorner(rc, o.getRotated(45));
//         return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
//     }
// }


import org.joml.Vector2i;
import org.joml.Vector2ic;
import org.terasology.cities.common.Edges;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;
        int maxY = pos.y() + rotateY(dir, right + width - 1, forward + len - 1);
        return new BlockArea(minX, minY).union(maxX, maxY);
    }

    /**
     * Creates a rectangle that is centered along the current direction.
     * <pre>
     *      x------x
     * o->  |      |
     *      x------x
     * </pre>
     * @param forward the offset along the direction axis
     * @param width the width of the rectangle
     * @param len the length of the rectangle
     * @return the rectangle
     */
    public BlockAreac rectCentered(int forward, int width, int len) {
        return rect(-width / 2, forward, width, len);
    }

    /**
     * @param rc the rectangle to adjust
     * @param left the offset of the left edge
     * @param back the offset of the back edge
     * @param right the offset of the right edge
     * @param forward the offset of the forward edge
     * @return a new rect with adjusted coordinates
     */
    public BlockAreac adjustRect(BlockAreac rc, int left, int back, int right, int forward) {
        Orientation cd = orient.getRotated(45);
// Path: src/main/java/org/terasology/cities/common/Edges.java
// public final class Edges {
// 
//     private Edges() {
//         // no instances
//     }
// 
//     public static Vector2i getCorner(BlockAreac rc, Orientation o) {
// 
//         int dx = o.direction().x() + 1; //  [0..2]
//         int dy = o.direction().y() + 1; //  [0..2]
// 
//         int x = rc.minX() + (rc.getSizeX() - 1) * dx / 2;
//         int y = rc.minY() + (rc.getSizeY() - 1) * dy / 2;
// 
//         return new Vector2i(x, y);
//     }
// 
//     public static int getDistanceToBorder(BlockAreac rc, int x, int z) {
//         int rx = x - rc.minX();
//         int rz = z - rc.minY();
// 
//         // distance to border along both axes
//         int borderDistX = Math.min(rx, rc.getSizeX() - 1 - rx);
//         int borderDistZ = Math.min(rz, rc.getSizeY() - 1 - rz);
// 
//         int dist = Math.min(borderDistX, borderDistZ);
//         return dist;
//     }
// 
//     public static float getDistanceToCorner(BlockAreac rc, int x, int y) {
//         return (float) Math.sqrt(getDistanceToCorner(rc, x, y));
//     }
// 
//     public static int getDistanceToCornerSq(BlockAreac rc, int x, int y) {
//         int dx = Math.min(x - rc.minX(), rc.maxX() - x);
//         int dy = Math.min(y - rc.minY(), rc.maxY() - y);
//         return dx * dx + dy * dy;
//     }
// 
//     public static Line2f getEdge(BlockAreac rc, Orientation o) {
// 
//         Vector2i p0 = getCorner(rc, o.getRotated(-45));
//         Vector2i p1 = getCorner(rc, o.getRotated(45));
//         return new Line2f(p0.x(), p0.y(), p1.x(), p1.y());
//     }
// }


// Path: src/main/java/org/terasology/cities/bldg/gen/Turtle.java
import org.joml.Vector2i;
import org.joml.Vector2ic;
import org.terasology.cities.common.Edges;
import org.terasology.commonworld.Orientation;
import org.terasology.engine.world.block.BlockArea;
import org.terasology.engine.world.block.BlockAreac;

        int maxY = pos.y() + rotateY(dir, right + width - 1, forward + len - 1);
        return new BlockArea(minX, minY).union(maxX, maxY);
    }

    /**
     * Creates a rectangle that is centered along the current direction.
     * <pre>
     *      x------x
     * o->  |      |
     *      x------x
     * </pre>
     * @param forward the offset along the direction axis
     * @param width the width of the rectangle
     * @param len the length of the rectangle
     * @return the rectangle
     */
    public BlockAreac rectCentered(int forward, int width, int len) {
        return rect(-width / 2, forward, width, len);
    }

    /**
     * @param rc the rectangle to adjust
     * @param left the offset of the left edge
     * @param back the offset of the back edge
     * @param right the offset of the right edge
     * @param forward the offset of the forward edge
     * @return a new rect with adjusted coordinates
     */
    public BlockAreac adjustRect(BlockAreac rc, int left, int back, int right, int forward) {
        Orientation cd = orient.getRotated(45);
        Vector2i max = Edges.getCorner(rc, cd);