diff options
-rw-r--r-- | src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java | 17 | ||||
-rw-r--r-- | src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java | 7 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java index 40cb6c3220..1c44164731 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java +++ b/src/main/java/com/github/technus/tectech/mechanics/alignment/IntegerAxisSwap.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.mechanics.alignment; import com.github.technus.tectech.util.Vec3Impl; +import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; import static com.github.technus.tectech.mechanics.alignment.enumerable.Direction.getAxisVector; @@ -40,6 +41,22 @@ public class IntegerAxisSwap { forFirstAxis.get2()*point.get0()+forSecondAxis.get2()*point.get1()+forThirdAxis.get2()*point.get2() ); } + + public Vec3 translate(Vec3 point){ + return Vec3.createVectorHelper( + forFirstAxis.get0()*point.xCoord +forFirstAxis.get1()*point.yCoord +forFirstAxis.get2()*point.zCoord, + forSecondAxis.get0()*point.xCoord+forSecondAxis.get1()*point.yCoord+forSecondAxis.get2()*point.zCoord, + forThirdAxis.get0()*point.xCoord +forThirdAxis.get1()*point.yCoord +forThirdAxis.get2()*point.zCoord + ); + } + + public Vec3 inverseTranslate(Vec3 point){ + return Vec3.createVectorHelper( + forFirstAxis.get0()*point.xCoord+forSecondAxis.get0()*point.yCoord+forThirdAxis.get0()*point.zCoord, + forFirstAxis.get1()*point.xCoord+forSecondAxis.get1()*point.yCoord+forThirdAxis.get1()*point.zCoord, + forFirstAxis.get2()*point.xCoord+forSecondAxis.get2()*point.yCoord+forThirdAxis.get2()*point.zCoord + ); + } public void translate(int[] point,int[] out){ out[0]=forFirstAxis.get0()*point[0] +forFirstAxis.get1()*point[1] +forFirstAxis.get2()*point[2]; 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 68cc50a5ee..5c8c902484 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 @@ -3,6 +3,7 @@ package com.github.technus.tectech.mechanics.alignment.enumerable; import com.github.technus.tectech.mechanics.alignment.IAlignment; import com.github.technus.tectech.mechanics.alignment.IntegerAxisSwap; import com.github.technus.tectech.util.Vec3Impl; +import net.minecraft.util.Vec3; import net.minecraftforge.common.util.ForgeDirection; import java.util.*; @@ -292,6 +293,9 @@ public enum ExtendedFacing { * @param abcOffset A,B,C offset (facing relative L-->R,U-->D,F-->B) * @return X,Y,Z offset in world */ + public Vec3 getWorldOffset(Vec3 abcOffset) { + return integerAxisSwap.inverseTranslate(abcOffset); + } public Vec3Impl getWorldOffset(Vec3Impl abcOffset) { return integerAxisSwap.inverseTranslate(abcOffset); } @@ -308,6 +312,9 @@ public enum ExtendedFacing { * @param xyzOffset X,Y,Z offset in world * @return A,B,C offset (facing relative L-->R,U-->D,F-->B) */ + public Vec3 getOffsetABC(Vec3 xyzOffset){ + return integerAxisSwap.translate(xyzOffset); + } public Vec3Impl getOffsetABC(Vec3Impl xyzOffset){ return integerAxisSwap.translate(xyzOffset); } |