From 2fb5ea10083f51dc7e5a7dcdcf96c2aee89fa17f Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 13 Nov 2012 15:05:49 -0500 Subject: [PATCH] Change getLeft to getRotation, around any axis. --- .../net/minecraftforge/common/ForgeDirection.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/common/net/minecraftforge/common/ForgeDirection.java b/common/net/minecraftforge/common/ForgeDirection.java index 948e7b676c..29651b766f 100644 --- a/common/net/minecraftforge/common/ForgeDirection.java +++ b/common/net/minecraftforge/common/ForgeDirection.java @@ -31,7 +31,16 @@ public enum ForgeDirection public final int flag; public static final ForgeDirection[] VALID_DIRECTIONS = {DOWN, UP, NORTH, SOUTH, WEST, EAST}; public static final int[] OPPOSITES = {1, 0, 3, 2, 5, 4, 6}; - public static final int[] TO_LEFT = {0, 1, 5, 4, 3, 2, 6}; + // Left hand rule rotation matrix for all possible axes of rotation + public static final int[][] ROTATION_MATRIX = { + {0, 1, 4, 5, 2, 3, 6}, + {0, 1, 5, 4, 3, 2, 6}, + {5, 4, 2, 3, 0, 1, 6}, + {4, 5, 2, 3, 1, 0, 6}, + {2, 3, 0, 1, 4, 5, 6}, + {3, 2, 1, 0, 4, 5, 6}, + {0, 1, 2, 3, 4, 5, 6}, + }; private ForgeDirection(int x, int y, int z) { @@ -55,8 +64,8 @@ public enum ForgeDirection return getOrientation(OPPOSITES[ordinal()]); } - public ForgeDirection getLeftRotation() + public ForgeDirection getRotation(ForgeDirection axis) { - return getOrientation(TO_LEFT[ordinal()]); + return getOrientation(ROTATION_MATRIX[axis.ordinal()][ordinal()]); } }