aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBucketBrigade <138534411+CookieBrigade@users.noreply.github.com>2024-09-15 17:41:39 -0500
committerGitHub <noreply@github.com>2024-09-15 22:41:39 +0000
commit43af160db2e04f06bba3792a11860ee42c3d1947 (patch)
tree5d8e32ceca09e0a494fddb7282f1475a1dde5c3d /src/main
parentb2f39ffd9736eab3c5bf56b54b1e04da1a3df556 (diff)
downloadGT5-Unofficial-43af160db2e04f06bba3792a11860ee42c3d1947.tar.gz
GT5-Unofficial-43af160db2e04f06bba3792a11860ee42c3d1947.tar.bz2
GT5-Unofficial-43af160db2e04f06bba3792a11860ee42c3d1947.zip
Fix for render rotations on antimatter forge (again) and HILE (#3200)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/AntimatterForge.java3
-rw-r--r--src/main/java/goodgenerator/blocks/tileEntity/render/TileAntimatter.java56
-rw-r--r--src/main/java/gregtech/common/tileentities/render/TileEntityLaser.java65
3 files changed, 93 insertions, 31 deletions
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<AntimatterFo
TileAntimatter render = getAntimatterRender();
if (render == null) return;
render.setProtomatterRender(flag);
- render.setRotationFields(getRotation(), getDirection());
+ if (!flag) return;
+ render.setRotationFields(getDirection(), getRotation());
}
public TileAntimatter getAntimatterRender() {
diff --git a/src/main/java/goodgenerator/blocks/tileEntity/render/TileAntimatter.java b/src/main/java/goodgenerator/blocks/tileEntity/render/TileAntimatter.java
index 13494f9234..80b36ab01b 100644
--- a/src/main/java/goodgenerator/blocks/tileEntity/render/TileAntimatter.java
+++ b/src/main/java/goodgenerator/blocks/tileEntity/render/TileAntimatter.java
@@ -9,6 +9,9 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
+import org.joml.AxisAngle4f;
+import org.joml.Matrix4f;
+
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
public class TileAntimatter extends TileEntity {
@@ -97,6 +100,7 @@ public class TileAntimatter extends TileEntity {
}
public void setProtomatterRender(boolean flag) {
+ if (protomatterRender == flag) return;
protomatterRender = flag;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@@ -114,16 +118,48 @@ public class TileAntimatter extends TileEntity {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
- public void setRotationFields(Rotation rotation, ForgeDirection direction) {
- switch (rotation) {
- case NORMAL -> 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);
}
diff --git a/src/main/java/gregtech/common/tileentities/render/TileEntityLaser.java b/src/main/java/gregtech/common/tileentities/render/TileEntityLaser.java
index b719039fe0..dfbb771785 100644
--- a/src/main/java/gregtech/common/tileentities/render/TileEntityLaser.java
+++ b/src/main/java/gregtech/common/tileentities/render/TileEntityLaser.java
@@ -7,6 +7,9 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
+import org.joml.AxisAngle4f;
+import org.joml.Matrix4f;
+
import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
@@ -52,26 +55,48 @@ public class TileEntityLaser extends TileEntity {
}
public void setRotationFields(ForgeDirection direction, Rotation rotation, Flip flip) {
- setRotationAngle(rotation, flip);
- setRotationAxis(direction);
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- }
-
- private void setRotationAngle(Rotation rotation, Flip flip) {
- int invert = (flip == Flip.HORIZONTAL || flip == Flip.VERTICAL) ? 1 : -1;
- switch (rotation) {
- case NORMAL -> rotationAngle = 0;
- case CLOCKWISE -> rotationAngle = 90 * invert;
- case COUNTER_CLOCKWISE -> rotationAngle = -90 * invert;
- case UPSIDE_DOWN -> rotationAngle = 180;
- }
- worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
- }
-
- public void setRotationAxis(ForgeDirection direction) {
- rotAxisX = direction.offsetX;
- rotAxisY = direction.offsetY;
- rotAxisZ = direction.offsetZ;
+ Matrix4f rotationMatrix = new Matrix4f().identity();
+
+ float localAngle = switch (rotation) {
+ case NORMAL -> 0;
+ case CLOCKWISE -> 90;
+ case COUNTER_CLOCKWISE -> -90;
+ case UPSIDE_DOWN -> 180;
+ };
+ localAngle *= (flip == Flip.HORIZONTAL || flip == Flip.VERTICAL) ? 1 : -1;
+ 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;
+ rotAxisX = rotationVector.x;
+ rotAxisY = rotationVector.y;
+ rotAxisZ = rotationVector.z;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}