Merge pull request #2227 from SirJain0/yarn-animation-export

Add Yarn Mapping Export Template for Keyframe Animations
This commit is contained in:
JannisX11 2024-03-24 22:34:42 +01:00 committed by GitHub
commit e96d4b133f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -366,6 +366,34 @@ const AnimationTemplates = {
catmullrom: 'AnimationChannel.Interpolations.CATMULLROM',
},
},
'fabric': {
name: 'Yarn',
file:
`// Save this class in your mod and generate all required imports
/**
* Made with Blockbench %(bb_version)
* Exported for Minecraft version 1.19 or later with Yarn mappings
* @author %(author)
*/
public class %(identifier)Animation {
%(animations)
}`,
animation: `public static final Animation %(name) = Animation.Builder.create(%(length))%(looping)%(channels).build();`,
looping: `.looping()`,
channel: `.addBoneAnimation("%(name)", new Transformation(%(channel_type), %(keyframes)))`,
keyframe_rotation: `new Keyframe(%(time), AnimationHelper.createRotationalVector(%(x), %(y), %(z)), %(interpolation))`,
keyframe_position: `new Keyframe(%(time), AnimationHelper.createTranslationalVector(%(x), %(y), %(z)), %(interpolation))`,
keyframe_scale: `new Keyframe(%(time), AnimationHelper.createScalingVector(%(x), %(y), %(z)), %(interpolation))`,
channel_types: {
rotation: 'Transformation.Targets.ROTATE',
position: 'Transformation.Targets.TRANSLATE',
scale: 'Transformation.Targets.SCALE',
},
interpolations: {
linear: 'Transformation.Interpolations.LINEAR',
catmullrom: 'Transformation.Interpolations.CUBIC',
},
},
get(key, version = Project.modded_entity_version) {
let mapping = Templates.get('animation_template', version);