diff --git a/src/main/java/com/jozufozu/flywheel/mixin/matrix/PoseStackMixin.java b/src/main/java/com/jozufozu/flywheel/mixin/matrix/PoseStackMixin.java new file mode 100644 index 000000000..8588b9546 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/mixin/matrix/PoseStackMixin.java @@ -0,0 +1,56 @@ +package com.jozufozu.flywheel.mixin.matrix; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import com.jozufozu.flywheel.util.transform.TransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Quaternion; + +@Mixin(PoseStack.class) +public abstract class PoseStackMixin implements TransformStack { + @Shadow + public abstract void mulPose(Quaternion pQuaternion); + + @Shadow + public abstract void shadow$scale(float factorX, float factorY, float factorZ); + + @Shadow + public abstract void shadow$pushPose(); + + @Shadow + public abstract void shadow$popPose(); + + @Shadow + public abstract void shadow$translate(double x, double y, double z); + + @Override + public TransformStack multiply(Quaternion quaternion) { + mulPose(quaternion); + return this; + } + + @Override + public TransformStack scale(float factorX, float factorY, float factorZ) { + shadow$scale(factorX, factorY, factorZ); + return this; + } + + @Override + public TransformStack pushPose() { + shadow$pushPose(); + return this; + } + + @Override + public TransformStack popPose() { + shadow$popPose(); + return this; + } + + @Override + public TransformStack translate(double x, double y, double z) { + shadow$translate(x, y, z); + return this; + } +} diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java index 5f8604b9e..2fa562ffa 100644 --- a/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java +++ b/src/main/java/com/jozufozu/flywheel/util/transform/MatrixTransformStack.java @@ -15,10 +15,6 @@ public class MatrixTransformStack implements TransformStack { this.internal = internal; } - public static MatrixTransformStack of(PoseStack ms) { - return new MatrixTransformStack(ms); - } - public PoseStack unwrap() { return internal; } @@ -58,13 +54,13 @@ public class MatrixTransformStack implements TransformStack { } @Override - public TransformStack push() { + public TransformStack pushPose() { internal.pushPose(); return this; } @Override - public TransformStack pop() { + public TransformStack popPose() { internal.popPose(); return this; } diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/TStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/TStack.java new file mode 100644 index 000000000..1502fd750 --- /dev/null +++ b/src/main/java/com/jozufozu/flywheel/util/transform/TStack.java @@ -0,0 +1,7 @@ +package com.jozufozu.flywheel.util.transform; + +public interface TStack { + Self pushPose(); + + Self popPose(); +} diff --git a/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java b/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java index 5779b8bfd..da521b69b 100644 --- a/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java +++ b/src/main/java/com/jozufozu/flywheel/util/transform/TransformStack.java @@ -1,7 +1,9 @@ package com.jozufozu.flywheel.util.transform; -public interface TransformStack extends Scale, Translate, Rotate { - TransformStack push(); +import com.mojang.blaze3d.vertex.PoseStack; - TransformStack pop(); +public interface TransformStack extends Scale, Translate, Rotate, TStack { + static TransformStack cast(PoseStack stack) { + return (TransformStack) stack; + } } diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java index 021c5f069..a7e2ff9ae 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartInstance.java @@ -111,12 +111,12 @@ public class MinecartInstance extends EntityInstance int j = entity.getDisplayOffset(); if (contents != null) { - stack.push(); + stack.pushPose(); stack.scale(0.75F); stack.translate(-0.5D, (float)(j - 8) / 16, 0.5D); stack.multiply(Vector3f.YP.rotationDegrees(90)); contents.setTransform(stack.unwrap()); - stack.pop(); + stack.popPose(); } body.setTransform(stack.unwrap()); diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java index a77affd6b..5da600a83 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxInstance.java @@ -24,7 +24,7 @@ public class ShulkerBoxInstance extends TileEntityInstance