DataSlot .java

net.minecraft.world.inventory.DataSlot (class, 61 lines): members: checkAndClearUpdateFlag, forContainer, standalone, prevValue, shared, set, get.

net.minecraft.world.inventoryclass61 linescommon1.1 KB

API Surface (10)

DataSlot forContainer(final ContainerData container, final int dataId)
int get()
void set(final int value)
DataSlot shared(final int[] storage, final int index)
int get()
void set(final int value)
DataSlot standalone()
int get()
void set(final int value)
boolean checkAndClearUpdateFlag()

Fields & Constants (1)

prevValue

Code Graph: Dependencies (1)

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

Full Source

DataSlot.java61 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.inventory;
2
3
public abstract class DataSlot {
4
	private int prevValue;
5
6
	public static DataSlot forContainer(final ContainerData container, final int dataId) {
7
		return new DataSlot() {
8
			@Override
9
			public int get() {
10
				return container.get(dataId);
11
			}
12
13
			@Override
14
			public void set(final int value) {
15
				container.set(dataId, value);
16
			}
17
		};
18
	}
19
20
	public static DataSlot shared(final int[] storage, final int index) {
21
		return new DataSlot() {
22
			@Override
23
			public int get() {
24
				return storage[index];
25
			}
26
27
			@Override
28
			public void set(final int value) {
29
				storage[index] = value;
30
			}
31
		};
32
	}
33
34
	public static DataSlot standalone() {
35
		return new DataSlot() {
36
			private int value;
37
38
			@Override
39
			public int get() {
40
				return this.value;
41
			}
42
43
			@Override
44
			public void set(final int value) {
45
				this.value = value;
46
			}
47
		};
48
	}
49
50
	public abstract int get();
51
52
	public abstract void set(int value);
53
54
	public boolean checkAndClearUpdateFlag() {
55
		int currentValue = this.get();
56
		boolean result = currentValue != this.prevValue;
57
		this.prevValue = currentValue;
58
		return result;
59
	}
60
}
61

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