AnimationDefinition.java

net.minecraft.client.animation.AnimationDefinition

信息

  • 全限定名:net.minecraft.client.animation.AnimationDefinition
  • 类型:public record
  • 包:net.minecraft.client.animation
  • 源码路径:src/main/java/net/minecraft/client/animation/AnimationDefinition.java
  • 起始行号:L12
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

  • net.minecraft.client.animation.AnimationDefinition.Builder
    • 类型: class
    • 修饰符: public static
    • 源码定位: L18
    • 说明:

      TODO

构造器

方法

下面的方法块按源码顺序生成。

public KeyframeAnimation bake(ModelPart root) @ L13

  • 方法名:bake
  • 源码定位:L13
  • 返回类型:KeyframeAnimation
  • 修饰符:public

参数:

  • root: ModelPart

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public record AnimationDefinition(float lengthInSeconds, boolean looping, Map<String, List<AnimationChannel>> boneAnimations) {
    public KeyframeAnimation bake(ModelPart root) {
        return KeyframeAnimation.bake(root, this);
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class Builder {
        private final float length;
        private final Map<String, List<AnimationChannel>> animationByBone = Maps.newHashMap();
        private boolean looping;
 
        public static AnimationDefinition.Builder withLength(float lengthInSeconds) {
            return new AnimationDefinition.Builder(lengthInSeconds);
        }
 
        private Builder(float length) {
            this.length = length;
        }
 
        public AnimationDefinition.Builder looping() {
            this.looping = true;
            return this;
        }
 
        public AnimationDefinition.Builder addAnimation(String boneName, AnimationChannel animation) {
            this.animationByBone.computeIfAbsent(boneName, k -> new ArrayList<>()).add(animation);
            return this;
        }
 
        public AnimationDefinition build() {
            return new AnimationDefinition(this.length, this.looping, this.animationByBone);
        }
    }
}

引用的其他类