API Surface (2) record AnimationFrame(int index, Optional<Integer> time)
int timeOr(final int defaultFrameTime)
Code Graph: Dependencies (1) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
AnimationFrame.java 31 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.client.resources.metadata.animation;
2
3 import com.mojang.datafixers.util.Either;
4 import com.mojang.serialization.Codec;
5 import com.mojang.serialization.codecs.RecordCodecBuilder;
6 import java.util.Optional;
7 import net.fabricmc.api.EnvType;
8 import net.fabricmc.api.Environment;
9 import net.minecraft.util.ExtraCodecs;
10
11 @Environment(EnvType.CLIENT)
12 public record AnimationFrame(int index, Optional<Integer> time) {
13 public static final Codec<AnimationFrame> FULL_CODEC = RecordCodecBuilder.create(
14 i -> i.group(
15 ExtraCodecs.NON_NEGATIVE_INT.fieldOf("index").forGetter(AnimationFrame::index),
16 ExtraCodecs.POSITIVE_INT.optionalFieldOf("time").forGetter(AnimationFrame::time)
17 )
18 .apply(i, AnimationFrame::new)
19 );
20 public static final Codec<AnimationFrame> CODEC = Codec.either(ExtraCodecs.NON_NEGATIVE_INT, FULL_CODEC)
21 .xmap(either -> either.map(AnimationFrame::new, v -> (AnimationFrame)v), frame -> frame.time.isPresent() ? Either.right(frame) : Either.left(frame.index));
22
23 public AnimationFrame(final int index) {
24 this(index, Optional.empty());
25 }
26
27 public int timeOr(final int defaultFrameTime) {
28 return this.time.orElse(defaultFrameTime);
29 }
30 }
31
Decompiled Minecraft 26.3 source of AnimationFrame (net/minecraft/client/resources/metadata/animation/AnimationFrame.java) with Mojang official mappings, stored verbatim on the site.