SwingAnimationType .java

net.minecraft.world.item.SwingAnimationType (enum): members: NONE, WHACK, STAB, byName, BY_ID, getId, getSerializedName, name, STREAM_CODEC, CODEC.

net.minecraft.world.itemenum43 linescommon1.4 KB

Implements

API Surface (2)

int getId()
String getSerializedName()

Fields & Constants (5)

BY_ID
CODEC
STREAM_CODEC
id
name

String literals (4)

"none"
"whack"
"stab"
"_,!null->!null;_,null->_"

Code Graph: Dependencies (4)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

SwingAnimationType.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item;
2
3
import io.netty.buffer.ByteBuf;
4
import java.util.function.IntFunction;
5
import net.minecraft.network.codec.ByteBufCodecs;
6
import net.minecraft.network.codec.StreamCodec;
7
import net.minecraft.util.ByIdMap;
8
import net.minecraft.util.StringRepresentable;
9
import org.jetbrains.annotations.Contract;
10
import org.jspecify.annotations.Nullable;
11
12
public enum SwingAnimationType implements StringRepresentable {
13
	NONE(0, "none"),
14
	WHACK(1, "whack"),
15
	STAB(2, "stab");
16
17
	private static final IntFunction<SwingAnimationType> BY_ID = ByIdMap.continuous(SwingAnimationType::getId, values(), ByIdMap.OutOfBoundsStrategy.ZERO);
18
	public static final StringRepresentable.EnumCodec<SwingAnimationType> CODEC = StringRepresentable.fromEnum(SwingAnimationType::values);
19
	public static final StreamCodec<ByteBuf, SwingAnimationType> STREAM_CODEC = ByteBufCodecs.idMapper(BY_ID, SwingAnimationType::getId);
20
	private final int id;
21
	private final String name;
22
23
	SwingAnimationType(final int id, final String name) {
24
		this.id = id;
25
		this.name = name;
26
	}
27
28
	public int getId() {
29
		return this.id;
30
	}
31
32
	@Override
33
	public String getSerializedName() {
34
		return this.name;
35
	}
36
37
	@Contract("_,!null->!null;_,null->_")
38
	public static @Nullable SwingAnimationType byName(final String name, final @Nullable SwingAnimationType defaultAnimation) {
39
		SwingAnimationType result = CODEC.byName(name);
40
		return result != null ? result : defaultAnimation;
41
	}
42
}
43

Decompiled Minecraft 26.3 source of SwingAnimationType (net/minecraft/world/item/SwingAnimationType.java) with Mojang official mappings, stored verbatim on the site.