From fc58393acca3faf07de1e06d858135b570ed22ec Mon Sep 17 00:00:00 2001 From: Eclipse Date: Wed, 12 Nov 2025 14:03:16 +0000 Subject: [PATCH] Update GeometryMapper to support new model rotation capabilities --- .../mapping/geometry/GeometryMapper.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/rainbow/src/main/java/org/geysermc/rainbow/mapping/geometry/GeometryMapper.java b/rainbow/src/main/java/org/geysermc/rainbow/mapping/geometry/GeometryMapper.java index 5bed958..b2614ed 100644 --- a/rainbow/src/main/java/org/geysermc/rainbow/mapping/geometry/GeometryMapper.java +++ b/rainbow/src/main/java/org/geysermc/rainbow/mapping/geometry/GeometryMapper.java @@ -115,16 +115,23 @@ public class GeometryMapper { // Same as above for inverting the X axis (thanks again Blockbench!!) builder.withPivot(rotation.origin().div(0.0625F, new Vector3f()).sub(CENTRE_OFFSET).mul(-1.0F, 1.0F, 1.0F)); - - // Same as above but for some reason the Z axis too (thanks again, so much, Blockbench!!!) - Vector3f bedrockRotation = switch (rotation.axis()) { - case X -> new Vector3f(-rotation.angle(), 0.0F, 0.0F); - case Y -> new Vector3f(0.0F, rotation.angle(), 0.0F); - case Z -> new Vector3f(0.0F, 0.0F, -rotation.angle()); - }; - builder.withRotation(bedrockRotation); + builder.withRotation(getBedrockRotation(rotation.value())); + // TODO translate rescale property? } return builder; } + + private static Vector3fc getBedrockRotation(BlockElementRotation.RotationValue rotation) { + // Same as in the method above, but for some reason the Z axis too: X and Z axes have to be inverted (thanks again, so much, Blockbench!!!) + return switch (rotation) { + case BlockElementRotation.EulerXYZRotation(float x, float y, float z) -> new Vector3f(-x, y, -z); // TODO check if these angle transformations are right, they should be + case BlockElementRotation.SingleAxisRotation(Direction.Axis axis, float angle) -> switch (axis) { + case X -> new Vector3f(-angle, 0.0F, 0.0F); + case Y -> new Vector3f(0.0F, angle, 0.0F); + case Z -> new Vector3f(0.0F, 0.0F, -angle); + }; + default -> throw new IllegalArgumentException("Don't know how to transform rotation of type " + rotation.getClass() + " to bedrock rotation"); + }; + } }