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.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) public record AnimationDefinition(float lengthInSeconds, boolean looping, Map> boneAnimations) { @Environment(EnvType.CLIENT) public static class Builder { private final float length; private final Map> animationByBone = Maps.>newHashMap(); private boolean looping; public static AnimationDefinition.Builder withLength(float lengthInSeconds) { return new AnimationDefinition.Builder(lengthInSeconds); } private Builder(float lengthInSeconds) { this.length = lengthInSeconds; } public AnimationDefinition.Builder looping() { this.looping = true; return this; } public AnimationDefinition.Builder addAnimation(String bone, AnimationChannel animationChannel) { ((List)this.animationByBone.computeIfAbsent(bone, string -> new ArrayList())).add(animationChannel); return this; } public AnimationDefinition build() { return new AnimationDefinition(this.length, this.looping, this.animationByBone); } } }