diff --git a/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java b/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java index 1cb4de5b..91c84555 100644 --- a/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java +++ b/src/main/java/codechicken/lib/gui/modular/lib/Constraints.java @@ -90,6 +90,11 @@ public static void center(ConstrainedGeometry element, ConstrainedGeometry element.constrain(LEFT, midPoint(centerOn.get(LEFT), centerOn.get(RIGHT), () -> element.xSize() / -2)); } + public static void center(ConstrainedGeometry element, ConstrainedGeometry centerOn, double xOffset, double yOffset) { + element.constrain(TOP, midPoint(centerOn.get(TOP), centerOn.get(BOTTOM), () -> (element.ySize() / -2) + yOffset)); + element.constrain(LEFT, midPoint(centerOn.get(LEFT), centerOn.get(RIGHT), () -> (element.xSize() / -2) + xOffset)); + } + /** * Constrain the specified element to a position inside the specified targetElement. * See the following image for an example of what each LayoutPos does: