From b6d2af2170d0fa36d9b665958411f5824a302233 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:29:39 +0800 Subject: [PATCH] add new api to check for rotation/flip changes (#24) * add new api to check for rotation/flip changes Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> * add a bit javadoc Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --------- Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../structurelib/alignment/IAlignment.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/gtnewhorizon/structurelib/alignment/IAlignment.java b/src/main/java/com/gtnewhorizon/structurelib/alignment/IAlignment.java index b7f13f58..7bf5ffa4 100644 --- a/src/main/java/com/gtnewhorizon/structurelib/alignment/IAlignment.java +++ b/src/main/java/com/gtnewhorizon/structurelib/alignment/IAlignment.java @@ -190,4 +190,28 @@ default boolean isNewExtendedFacingValid(ExtendedFacing alignment) { return getAlignmentLimits() .isNewExtendedFacingValid(alignment.getDirection(), alignment.getRotation(), alignment.getFlip()); } + + /** + * Check if this object support a flip change, assuming both direction and rotation is not changed. + */ + default boolean isFlipChangeAllowed() { + ExtendedFacing facing = getExtendedFacing(); + for (Flip flip : Flip.VALUES) { + if (flip == getFlip()) continue; + if (isNewExtendedFacingValid(facing.with(flip))) return true; + } + return false; + } + + /** + * Check if this object support a rotation change, assuming both direction and flip is not changed. + */ + default boolean isRotationChangeAllowed() { + ExtendedFacing facing = getExtendedFacing(); + for (Rotation rotation : Rotation.VALUES) { + if (rotation == getRotation()) continue; + if (isNewExtendedFacingValid(facing.with(rotation))) return true; + } + return false; + } }