diff --git a/src/main/java/org/geysermc/packgenerator/mapping/animation/AnimationMapper.java b/src/main/java/org/geysermc/packgenerator/mapping/animation/AnimationMapper.java index 2dc184f..1c14d8c 100644 --- a/src/main/java/org/geysermc/packgenerator/mapping/animation/AnimationMapper.java +++ b/src/main/java/org/geysermc/packgenerator/mapping/animation/AnimationMapper.java @@ -7,17 +7,29 @@ import org.joml.Vector3f; import org.joml.Vector3fc; public class AnimationMapper { - private static final Vector3fc POSITION_OFFSET = new Vector3f(0.0F, 13.0F, -3.0F); - private static final Vector3fc ROTATION_OFFSET = new Vector3f(90.0F, -90.0F, 0.0F); + // These aren't perfect... but I spent over 1.5 hours trying to get these. It's good enough for me. + private static final Vector3fc FIRST_PERSON_POSITION_OFFSET = new Vector3f(-7.0F, 22.5F, -7.0F); + private static final Vector3fc FIRST_PERSON_ROTATION_OFFSET = new Vector3f(-22.5F, 50.0F, -32.5F); + + private static final Vector3fc THIRD_PERSON_POSITION_OFFSET = new Vector3f(0.0F, 13.0F, -3.0F); + private static final Vector3fc THIRD_PERSON_ROTATION_OFFSET = new Vector3f(90.0F, -90.0F, 0.0F); public static BedrockAnimationContext mapAnimation(String identifier, String bone, ItemTransforms transforms) { + // I don't think it's possible to display separate animations for left- and right hands + ItemTransform firstPerson = transforms.firstPersonRightHand(); + Vector3f firstPersonPosition = FIRST_PERSON_POSITION_OFFSET.add(firstPerson.translation(), new Vector3f()); + Vector3f firstPersonRotation = FIRST_PERSON_ROTATION_OFFSET.add(firstPerson.rotation(), new Vector3f()); + Vector3f firstPersonScale = new Vector3f(firstPerson.scale()); + ItemTransform thirdPerson = transforms.thirdPersonLeftHand(); - Vector3f thirdPersonPosition = POSITION_OFFSET.add(thirdPerson.translation(), new Vector3f()); - Vector3f thirdPersonRotation = ROTATION_OFFSET.add(-thirdPerson.rotation().x(), thirdPerson.rotation().y(), thirdPerson.rotation().z(), new Vector3f()); + Vector3f thirdPersonPosition = THIRD_PERSON_POSITION_OFFSET.add(thirdPerson.translation(), new Vector3f()); + Vector3f thirdPersonRotation = THIRD_PERSON_ROTATION_OFFSET.add(-thirdPerson.rotation().x(), thirdPerson.rotation().y(), thirdPerson.rotation().z(), new Vector3f()); Vector3f thirdPersonScale = new Vector3f(thirdPerson.scale()); return new BedrockAnimationContext(BedrockAnimation.builder() - .withAnimation(identifier + ".hold_first_person", BedrockAnimation.animation()) + .withAnimation(identifier + ".hold_first_person", BedrockAnimation.animation() + .withLoopMode(BedrockAnimation.LoopMode.LOOP) + .withBone(bone, firstPersonPosition, firstPersonRotation, firstPersonScale)) .withAnimation(identifier + ".hold_third_person", BedrockAnimation.animation() .withLoopMode(BedrockAnimation.LoopMode.LOOP) .withBone(bone, thirdPersonPosition, thirdPersonRotation, thirdPersonScale)) diff --git a/src/main/java/org/geysermc/packgenerator/pack/geometry/BedrockGeometry.java b/src/main/java/org/geysermc/packgenerator/pack/geometry/BedrockGeometry.java index 69289ae..826e377 100644 --- a/src/main/java/org/geysermc/packgenerator/pack/geometry/BedrockGeometry.java +++ b/src/main/java/org/geysermc/packgenerator/pack/geometry/BedrockGeometry.java @@ -19,6 +19,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +// TODO make vectors immutable public record BedrockGeometry(BedrockVersion formatVersion, List definitions) { public static final BedrockVersion FORMAT_VERSION = BedrockVersion.of(1, 21, 0); public static final Vector3f VECTOR3F_ZERO = new Vector3f();