IntTag .java

net.minecraft.nbt.IntTag (record): members: value, Cache, doubleValue, floatValue, shortValue, byteValue, longValue, intValue, valueOf, box, sizeInBytes.

net.minecraft.nbtrecord136 linescommon2.6 KB

Implements

API Surface (21)

IntTag load(final DataInput input, final NbtAccounter accounter)
StreamTagVisitor.ValueResult parse(final DataInput input, final StreamTagVisitor output, final NbtAccounter accounter)
int size()
String getName()
String getPrettyName()
IntTag valueOf(final int i)
void write(final DataOutput output)
int sizeInBytes()
byte getId()
TagType<IntTag> getType()
IntTag copy()
void accept(final TagVisitor visitor)
long longValue()
int intValue()
short shortValue()
byte byteValue()
double doubleValue()
float floatValue()
Number box()
StreamTagVisitor.ValueResult accept(final StreamTagVisitor visitor)
String toString()

Fields & Constants (2)

SELF_SIZE_IN_BYTES
TYPE

String literals (1)

"TAG_Int"

Code Graph: Dependencies (5)

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

Full Source

IntTag.java136 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.nbt;
2
3
import java.io.DataInput;
4
import java.io.DataOutput;
5
import java.io.IOException;
6
7
public record IntTag(int value) implements NumericTag {
8
	private static final int SELF_SIZE_IN_BYTES = 12;
9
	public static final TagType<IntTag> TYPE = new TagType.StaticSize<IntTag>() {
10
		public IntTag load(final DataInput input, final NbtAccounter accounter) throws IOException {
11
			return IntTag.valueOf(readAccounted(input, accounter));
12
		}
13
14
		@Override
15
		public StreamTagVisitor.ValueResult parse(final DataInput input, final StreamTagVisitor output, final NbtAccounter accounter) throws IOException {
16
			return output.visit(readAccounted(input, accounter));
17
		}
18
19
		private static int readAccounted(final DataInput input, final NbtAccounter accounter) throws IOException {
20
			accounter.accountBytes(12L);
21
			return input.readInt();
22
		}
23
24
		@Override
25
		public int size() {
26
			return 4;
27
		}
28
29
		@Override
30
		public String getName() {
31
			return "INT";
32
		}
33
34
		@Override
35
		public String getPrettyName() {
36
			return "TAG_Int";
37
		}
38
	};
39
40
	@Deprecated(forRemoval = true)
41
	public IntTag {
42
	}
43
44
	public static IntTag valueOf(final int i) {
45
		return i >= -128 && i <= 1024 ? IntTag.Cache.cache[i - -128] : new IntTag(i);
46
	}
47
48
	@Override
49
	public void write(final DataOutput output) throws IOException {
50
		output.writeInt(this.value);
51
	}
52
53
	@Override
54
	public int sizeInBytes() {
55
		return 12;
56
	}
57
58
	@Override
59
	public byte getId() {
60
		return 3;
61
	}
62
63
	@Override
64
	public TagType<IntTag> getType() {
65
		return TYPE;
66
	}
67
68
	public IntTag copy() {
69
		return this;
70
	}
71
72
	@Override
73
	public void accept(final TagVisitor visitor) {
74
		visitor.visitInt(this);
75
	}
76
77
	@Override
78
	public long longValue() {
79
		return this.value;
80
	}
81
82
	@Override
83
	public int intValue() {
84
		return this.value;
85
	}
86
87
	@Override
88
	public short shortValue() {
89
		return (short)(this.value & 65535);
90
	}
91
92
	@Override
93
	public byte byteValue() {
94
		return (byte)(this.value & 0xFF);
95
	}
96
97
	@Override
98
	public double doubleValue() {
99
		return this.value;
100
	}
101
102
	@Override
103
	public float floatValue() {
104
		return this.value;
105
	}
106
107
	@Override
108
	public Number box() {
109
		return this.value;
110
	}
111
112
	@Override
113
	public StreamTagVisitor.ValueResult accept(final StreamTagVisitor visitor) {
114
		return visitor.visit(this.value);
115
	}
116
117
	@Override
118
	public String toString() {
119
		StringTagVisitor visitor = new StringTagVisitor();
120
		visitor.visitInt(this);
121
		return visitor.build();
122
	}
123
124
	private static class Cache {
125
		private static final int HIGH = 1024;
126
		private static final int LOW = -128;
127
		private static final IntTag[] cache = new IntTag[1153];
128
129
		static {
130
			for (int i = 0; i < cache.length; i++) {
131
				cache[i] = new IntTag(-128 + i);
132
			}
133
		}
134
	}
135
}
136

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