IntTag.java
net.minecraft.nbt.IntTag
信息
- 全限定名:net.minecraft.nbt.IntTag
- 类型:public record
- 包:net.minecraft.nbt
- 源码路径:src/main/java/net/minecraft/nbt/IntTag.java
- 起始行号:L7
- 实现:NumericTag
- 职责:
TODO
字段/常量
-
SELF_SIZE_IN_BYTES- 类型:
int - 修饰符:
private static final - 源码定位:
L8 - 说明:
TODO
- 类型:
-
TYPE- 类型:
TagType<IntTag> - 修饰符:
public static final public public private static public public public - 源码定位:
L9 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.nbt.IntTag.Cache- 类型:
class - 修饰符:
private static - 源码定位:
L125 - 说明:
TODO
- 类型:
构造器
public IntTag(int value) @ L40
- 构造器名:IntTag
- 源码定位:L40
- 修饰符:public
参数:
- value: int
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static IntTag valueOf(int i) @ L45
- 方法名:valueOf
- 源码定位:L45
- 返回类型:IntTag
- 修饰符:public static
参数:
- i: int
说明:
TODO
public void write(DataOutput output) @ L49
- 方法名:write
- 源码定位:L49
- 返回类型:void
- 修饰符:public
参数:
- output: DataOutput
说明:
TODO
public int sizeInBytes() @ L54
- 方法名:sizeInBytes
- 源码定位:L54
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public byte getId() @ L59
- 方法名:getId
- 源码定位:L59
- 返回类型:byte
- 修饰符:public
参数:
- 无
说明:
TODO
public TagType<IntTag> getType() @ L64
- 方法名:getType
- 源码定位:L64
- 返回类型:TagType
- 修饰符:public
参数:
- 无
说明:
TODO
public IntTag copy() @ L69
- 方法名:copy
- 源码定位:L69
- 返回类型:IntTag
- 修饰符:public
参数:
- 无
说明:
TODO
public void accept(TagVisitor visitor) @ L73
- 方法名:accept
- 源码定位:L73
- 返回类型:void
- 修饰符:public
参数:
- visitor: TagVisitor
说明:
TODO
public long longValue() @ L78
- 方法名:longValue
- 源码定位:L78
- 返回类型:long
- 修饰符:public
参数:
- 无
说明:
TODO
public int intValue() @ L83
- 方法名:intValue
- 源码定位:L83
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public short shortValue() @ L88
- 方法名:shortValue
- 源码定位:L88
- 返回类型:short
- 修饰符:public
参数:
- 无
说明:
TODO
public byte byteValue() @ L93
- 方法名:byteValue
- 源码定位:L93
- 返回类型:byte
- 修饰符:public
参数:
- 无
说明:
TODO
public double doubleValue() @ L98
- 方法名:doubleValue
- 源码定位:L98
- 返回类型:double
- 修饰符:public
参数:
- 无
说明:
TODO
public float floatValue() @ L103
- 方法名:floatValue
- 源码定位:L103
- 返回类型:float
- 修饰符:public
参数:
- 无
说明:
TODO
public Number box() @ L108
- 方法名:box
- 源码定位:L108
- 返回类型:Number
- 修饰符:public
参数:
- 无
说明:
TODO
public StreamTagVisitor.ValueResult accept(StreamTagVisitor visitor) @ L113
- 方法名:accept
- 源码定位:L113
- 返回类型:StreamTagVisitor.ValueResult
- 修饰符:public
参数:
- visitor: StreamTagVisitor
说明:
TODO
public String toString() @ L118
- 方法名:toString
- 源码定位:L118
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public record IntTag(int value) implements NumericTag {
private static final int SELF_SIZE_IN_BYTES = 12;
public static final TagType<IntTag> TYPE = new TagType.StaticSize<IntTag>() {
public IntTag load(DataInput input, NbtAccounter accounter) throws IOException {
return IntTag.valueOf(readAccounted(input, accounter));
}
@Override
public StreamTagVisitor.ValueResult parse(DataInput input, StreamTagVisitor output, NbtAccounter accounter) throws IOException {
return output.visit(readAccounted(input, accounter));
}
private static int readAccounted(DataInput input, NbtAccounter accounter) throws IOException {
accounter.accountBytes(12L);
return input.readInt();
}
@Override
public int size() {
return 4;
}
@Override
public String getName() {
return "INT";
}
@Override
public String getPrettyName() {
return "TAG_Int";
}
};
@Deprecated(forRemoval = true)
public IntTag(int value) {
this.value = value;
}
public static IntTag valueOf(int i) {
return i >= -128 && i <= 1024 ? IntTag.Cache.cache[i - -128] : new IntTag(i);
}
@Override
public void write(DataOutput output) throws IOException {
output.writeInt(this.value);
}
@Override
public int sizeInBytes() {
return 12;
}
@Override
public byte getId() {
return 3;
}
@Override
public TagType<IntTag> getType() {
return TYPE;
}
public IntTag copy() {
return this;
}
@Override
public void accept(TagVisitor visitor) {
visitor.visitInt(this);
}
@Override
public long longValue() {
return this.value;
}
@Override
public int intValue() {
return this.value;
}
@Override
public short shortValue() {
return (short)(this.value & 65535);
}
@Override
public byte byteValue() {
return (byte)(this.value & 0xFF);
}
@Override
public double doubleValue() {
return this.value;
}
@Override
public float floatValue() {
return this.value;
}
@Override
public Number box() {
return this.value;
}
@Override
public StreamTagVisitor.ValueResult accept(StreamTagVisitor visitor) {
return visitor.visit(this.value);
}
@Override
public String toString() {
StringTagVisitor visitor = new StringTagVisitor();
visitor.visitInt(this);
return visitor.build();
}
private static class Cache {
private static final int HIGH = 1024;
private static final int LOW = -128;
static final IntTag[] cache = new IntTag[1153];
static {
for (int i = 0; i < cache.length; i++) {
cache[i] = new IntTag(-128 + i);
}
}
}
}引用的其他类
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
StringTagVisitor()
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置: