ItemDisplayContext .java

net.minecraft.world.item.ItemDisplayContext (enum): members: NONE, THIRD_PERSON_LEFT_HAND, THIRD_PERSON_RIGHT_HAND, FIRST_PERSON_LEFT_HAND, HEAD, GUI.

net.minecraft.world.itemenum47 linescommon1.3 KB

Implements

API Surface (4)

String getSerializedName()
byte getId()
boolean firstPerson()
boolean leftHand()

Fields & Constants (4)

CODEC
BY_ID
id
name

String literals (9)

"none"
"thirdperson_lefthand"
"thirdperson_righthand"
"firstperson_lefthand"
"firstperson_righthand"
"head"
"ground"
"fixed"
"on_shelf"

Code Graph: Dependencies (2)

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

Full Source

ItemDisplayContext.java47 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.item;
2
3
import com.mojang.serialization.Codec;
4
import java.util.function.IntFunction;
5
import net.minecraft.util.ByIdMap;
6
import net.minecraft.util.StringRepresentable;
7
8
public enum ItemDisplayContext implements StringRepresentable {
9
	NONE(0, "none"),
10
	THIRD_PERSON_LEFT_HAND(1, "thirdperson_lefthand"),
11
	THIRD_PERSON_RIGHT_HAND(2, "thirdperson_righthand"),
12
	FIRST_PERSON_LEFT_HAND(3, "firstperson_lefthand"),
13
	FIRST_PERSON_RIGHT_HAND(4, "firstperson_righthand"),
14
	HEAD(5, "head"),
15
	GUI(6, "gui"),
16
	GROUND(7, "ground"),
17
	FIXED(8, "fixed"),
18
	ON_SHELF(9, "on_shelf");
19
20
	public static final Codec<ItemDisplayContext> CODEC = StringRepresentable.fromEnum(ItemDisplayContext::values);
21
	public static final IntFunction<ItemDisplayContext> BY_ID = ByIdMap.continuous(ItemDisplayContext::getId, values(), ByIdMap.OutOfBoundsStrategy.ZERO);
22
	private final byte id;
23
	private final String name;
24
25
	ItemDisplayContext(final int id, final String name) {
26
		this.name = name;
27
		this.id = (byte)id;
28
	}
29
30
	@Override
31
	public String getSerializedName() {
32
		return this.name;
33
	}
34
35
	public byte getId() {
36
		return this.id;
37
	}
38
39
	public boolean firstPerson() {
40
		return this == FIRST_PERSON_LEFT_HAND || this == FIRST_PERSON_RIGHT_HAND;
41
	}
42
43
	public boolean leftHand() {
44
		return this == FIRST_PERSON_LEFT_HAND || this == THIRD_PERSON_LEFT_HAND;
45
	}
46
}
47

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