Skip to content

Commit 75d87ca

Browse files
authored
Fix Rotation in Overlay Render, Multiblock Render Preview and Multiblock Patterns (GregTechCEu#1619)
1 parent cce804e commit 75d87ca

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

src/main/java/com/gregtechceu/gtceu/api/pattern/BlockPattern.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ private BlockPos setActualRelativeOffset(int x, int y, int z, Direction facing,
611611
}
612612
}
613613
if (upwardsFacing == Direction.WEST || upwardsFacing == Direction.EAST) {
614-
int xOffset = upwardsFacing == Direction.WEST ? facing.getClockWise().getStepX() :
614+
int xOffset = upwardsFacing == Direction.EAST ? facing.getClockWise().getStepX() :
615615
facing.getClockWise().getOpposite().getStepX();
616-
int zOffset = upwardsFacing == Direction.WEST ? facing.getClockWise().getStepZ() :
616+
int zOffset = upwardsFacing == Direction.EAST ? facing.getClockWise().getStepZ() :
617617
facing.getClockWise().getOpposite().getStepZ();
618618
int tmp;
619619
if (xOffset == 0) {

src/main/java/com/gregtechceu/gtceu/client/model/WorkableOverlayModel.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,13 @@ public List<BakedQuad> bakeQuads(@Nullable Direction side, Direction frontFacing
150150
if (upwardsFacing.getAxis() == Direction.Axis.Z) {
151151
matrix.rotate(Mth.PI, 0, 0, upwardsFacing.getStepZ());
152152
}
153+
if (frontFacing.getAxisDirection() == Direction.AxisDirection.NEGATIVE) {
154+
matrix.rotate(Mth.PI, 0, 0, 1);
155+
}
153156
}
154157

155158
Quaternionf rot = new Quaternionf().rotationAxis(degree, 0, 0,
156-
frontFacing.getAxisDirection() == Direction.AxisDirection.POSITIVE ? 1 : -1);
159+
frontFacing.getAxisDirection() == Direction.AxisDirection.NEGATIVE ? 1 : -1);
157160

158161
if (frontFacing.getAxisDirection() == Direction.AxisDirection.POSITIVE &&
159162
frontFacing.getAxis() != Direction.Axis.Y) {

src/main/java/com/gregtechceu/gtceu/client/renderer/MultiblockInWorldPreviewRenderer.java

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public static void showPreview(BlockPos pos, MultiblockControllerMachine control
165165
offset = switch (front) {
166166
case NORTH, UP, DOWN -> offset.rotate(Rotation.NONE);
167167
case SOUTH -> offset.rotate(Rotation.CLOCKWISE_180);
168-
case WEST -> offset.rotate(Rotation.COUNTERCLOCKWISE_90);
169-
case EAST -> offset.rotate(Rotation.CLOCKWISE_90);
168+
case EAST -> offset.rotate(Rotation.COUNTERCLOCKWISE_90);
169+
case WEST -> offset.rotate(Rotation.CLOCKWISE_90);
170170
};
171171

172172
Rotation r = up == Direction.NORTH ? Rotation.NONE : up == Direction.EAST ? Rotation.CLOCKWISE_90 :
@@ -217,32 +217,36 @@ public static void showPreview(BlockPos pos, MultiblockControllerMachine control
217217
private static BlockPos rotateByFrontAxis(BlockPos pos, Direction front, Rotation rotation) {
218218
if (front.getAxis() == Direction.Axis.X) {
219219
return switch (rotation) {
220-
default -> pos;
221-
case CLOCKWISE_90 -> new BlockPos(pos.getX(), -front.getAxisDirection().getStep() * pos.getZ(),
222-
-front.getAxisDirection().getStep() * -pos.getY());
223-
case CLOCKWISE_180 -> new BlockPos(pos.getX(), -pos.getY(), -pos.getZ());
224-
case COUNTERCLOCKWISE_90 -> new BlockPos(pos.getX(), front.getAxisDirection().getStep() * pos.getZ(),
225-
-front.getAxisDirection().getStep() * pos.getY());
220+
default -> new BlockPos(-pos.getX(), pos.getY(), -pos.getZ());
221+
case CLOCKWISE_90 -> new BlockPos(-pos.getX(), -front.getAxisDirection().getStep() * pos.getZ(),
222+
front.getAxisDirection().getStep() * -pos.getY());
223+
case CLOCKWISE_180 -> new BlockPos(-pos.getX(), -pos.getY(), pos.getZ());
224+
case COUNTERCLOCKWISE_90 -> new BlockPos(-pos.getX(), front.getAxisDirection().getStep() * pos.getZ(),
225+
front.getAxisDirection().getStep() * pos.getY());
226226
};
227227
} else if (front.getAxis() == Direction.Axis.Y) {
228228
return switch (rotation) {
229-
default -> new BlockPos(-pos.getX(), -front.getAxisDirection().getStep() * pos.getZ(),
230-
-front.getAxisDirection().getStep() * pos.getY());
231-
case CLOCKWISE_90 -> new BlockPos(-front.getAxisDirection().getStep() * pos.getY(),
232-
-front.getAxisDirection().getStep() * pos.getZ(), pos.getX());
233-
case CLOCKWISE_180 -> new BlockPos(pos.getX(), -front.getAxisDirection().getStep() * pos.getZ(),
234-
front.getAxisDirection().getStep() * pos.getY());
235-
case COUNTERCLOCKWISE_90 -> new BlockPos(front.getAxisDirection().getStep() * pos.getY(),
236-
-front.getAxisDirection().getStep() * pos.getZ(), -pos.getX());
229+
default -> new BlockPos(-front.getAxisDirection().getStep() * pos.getX(),
230+
-front.getAxisDirection().getStep() * pos.getZ(),
231+
-pos.getY());
232+
case CLOCKWISE_90 -> new BlockPos(pos.getY(),
233+
-front.getAxisDirection().getStep() * pos.getZ(),
234+
-front.getAxisDirection().getStep() * pos.getX());
235+
case CLOCKWISE_180 -> new BlockPos(front.getAxisDirection().getStep() * pos.getX(),
236+
-front.getAxisDirection().getStep() * pos.getZ(),
237+
pos.getY());
238+
case COUNTERCLOCKWISE_90 -> new BlockPos(-pos.getY(),
239+
-front.getAxisDirection().getStep() * pos.getZ(),
240+
front.getAxisDirection().getStep() * pos.getX());
237241
};
238242
} else if (front.getAxis() == Direction.Axis.Z) {
239243
return switch (rotation) {
240244
default -> pos;
241-
case CLOCKWISE_90 -> new BlockPos(-front.getAxisDirection().getStep() * pos.getY(),
242-
front.getAxisDirection().getStep() * pos.getX(), pos.getZ());
243-
case CLOCKWISE_180 -> new BlockPos(-pos.getX(), -pos.getY(), pos.getZ());
244-
case COUNTERCLOCKWISE_90 -> new BlockPos(-front.getAxisDirection().getStep() * -pos.getY(),
245+
case CLOCKWISE_90 -> new BlockPos(front.getAxisDirection().getStep() * pos.getY(),
245246
-front.getAxisDirection().getStep() * pos.getX(), pos.getZ());
247+
case CLOCKWISE_180 -> new BlockPos(-pos.getX(), -pos.getY(), pos.getZ());
248+
case COUNTERCLOCKWISE_90 -> new BlockPos(front.getAxisDirection().getStep() * -pos.getY(),
249+
front.getAxisDirection().getStep() * pos.getX(), pos.getZ());
246250
};
247251
}
248252
return pos;

0 commit comments

Comments
 (0)