2025-11-24 22:52:51 +03:00

51 lines
1.5 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* com.google.common.collect.Maps
*/
package net.minecraft.client.animation;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.minecraft.client.animation.AnimationChannel;
import net.minecraft.client.animation.KeyframeAnimation;
import net.minecraft.client.model.geom.ModelPart;
public record AnimationDefinition(float lengthInSeconds, boolean looping, Map<String, List<AnimationChannel>> boneAnimations) {
public KeyframeAnimation bake(ModelPart root) {
return KeyframeAnimation.bake(root, this);
}
public static class Builder {
private final float length;
private final Map<String, List<AnimationChannel>> animationByBone = Maps.newHashMap();
private boolean looping;
public static Builder withLength(float lengthInSeconds) {
return new Builder(lengthInSeconds);
}
private Builder(float length) {
this.length = length;
}
public Builder looping() {
this.looping = true;
return this;
}
public 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);
}
}
}