From 43af160db2e04f06bba3792a11860ee42c3d1947 Mon Sep 17 00:00:00 2001 From: BucketBrigade <138534411+CookieBrigade@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:41:39 -0500 Subject: Fix for render rotations on antimatter forge (again) and HILE (#3200) --- .../blocks/tileEntity/AntimatterForge.java | 3 +- .../blocks/tileEntity/render/TileAntimatter.java | 56 ++++++++++++++++++---- 2 files changed, 48 insertions(+), 11 deletions(-) (limited to 'src/main/java/goodgenerator') diff --git a/src/main/java/goodgenerator/blocks/tileEntity/AntimatterForge.java b/src/main/java/goodgenerator/blocks/tileEntity/AntimatterForge.java index b078a499a7..f019f8f7cd 100644 --- a/src/main/java/goodgenerator/blocks/tileEntity/AntimatterForge.java +++ b/src/main/java/goodgenerator/blocks/tileEntity/AntimatterForge.java @@ -906,7 +906,8 @@ public class AntimatterForge extends MTEExtendedPowerMultiBlockBase rotationAngle = 0; - case CLOCKWISE -> rotationAngle = 90; - case COUNTER_CLOCKWISE -> rotationAngle = -90; - case UPSIDE_DOWN -> rotationAngle = 180; - } - rotX = direction.offsetX; - rotY = direction.offsetY; - rotZ = direction.offsetZ; + public void setRotationFields(ForgeDirection direction, Rotation rotation) { + Matrix4f rotationMatrix = new Matrix4f().identity(); + + float localAngle = switch (rotation) { + case NORMAL -> 0; + case CLOCKWISE -> 90; + case COUNTER_CLOCKWISE -> -90; + case UPSIDE_DOWN -> 180; + }; + localAngle = (float) Math.toRadians(localAngle); + rotationMatrix.rotate(localAngle, direction.offsetX, direction.offsetY, direction.offsetZ); + + float x = 0, y = 0; + float angle = switch (direction) { + case DOWN -> { + x = 1; + yield 90; + } + case UP -> { + x = 1; + yield -90; + } + case EAST, SOUTH -> { + y = 1; + yield 90; + } + case WEST, NORTH -> { + y = 1; + yield -90; + } + case UNKNOWN -> 0.0F; + }; + angle = (float) Math.toRadians(angle); + rotationMatrix.rotate(angle, x, y, 0); + + AxisAngle4f rotationVector = new AxisAngle4f(); + rotationMatrix.getRotation(rotationVector); + + rotationAngle = rotationVector.angle / (float) Math.PI * 180; + rotX = rotationVector.x; + rotY = rotationVector.y; + rotZ = rotationVector.z; worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } -- cgit