From fbe8484b9975e2b68285084936f91fb070c64d6d Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Mon, 18 Oct 2021 15:25:26 +0800 Subject: Fix cycle in class initialization order ExtendedFacing depends on IAlignment being fully initialized to be instantiated as part of its class initializer, which in turn require ExtendedFacing to be fully initialized to complete class initialization. How does this even work before? --- .../tectech/mechanics/alignment/enumerable/ExtendedFacing.java | 6 +++--- .../github/technus/tectech/mechanics/alignment/enumerable/Flip.java | 1 + .../technus/tectech/mechanics/alignment/enumerable/Rotation.java | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java index 04f2a55bd5..8e384e098c 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java +++ b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java @@ -138,9 +138,9 @@ public enum ExtendedFacing { ExtendedFacing(String name) { this.name = name; - direction= Direction.VALUES[ordinal()/(ROTATIONS_COUNT*FLIPS_COUNT)].getForgeDirection(); - rotation=Rotation.VALUES[ordinal()/FLIPS_COUNT-direction.ordinal()*ROTATIONS_COUNT]; - flip=Flip.VALUES[ordinal()%FLIPS_COUNT]; + direction= Direction.VALUES[ordinal()/(Rotation.COUNT*Flip.COUNT)].getForgeDirection(); + rotation=Rotation.VALUES[ordinal()/Flip.COUNT-direction.ordinal()*Rotation.COUNT]; + flip=Flip.VALUES[ordinal()%Flip.COUNT]; ForgeDirection a,b,c; switch (direction){ case DOWN: diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java index 0b85c5197e..400f94f869 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java +++ b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Flip.java @@ -20,6 +20,7 @@ public enum Flip { private final String name; public static final Flip[] VALUES = values(); + public static final int COUNT = VALUES.length; private static final Map NAME_LOOKUP = stream(VALUES).collect(toMap(Flip::getName2, (flip) -> flip)); Flip(int oppositeIn, String nameIn) { diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java index b6cd1aa015..ed4872828a 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java +++ b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/Rotation.java @@ -20,6 +20,7 @@ public enum Rotation { private final String name; public static final Rotation[] VALUES = values(); + public static final int COUNT = VALUES.length; private static final Map NAME_LOOKUP = stream(VALUES).collect(toMap(Rotation::getName2, (rotation) -> rotation)); Rotation(int oppositeIn, String nameIn) { -- cgit