ShortTag.java
net.minecraft.nbt.ShortTag
信息
- 全限定名:net.minecraft.nbt.ShortTag
- 类型:public record
- 包:net.minecraft.nbt
- 源码路径:src/main/java/net/minecraft/nbt/ShortTag.java
- 起始行号:L7
- 实现:NumericTag
- 职责:
TODO
字段/常量
-
SELF_SIZE_IN_BYTES- 类型:
int - 修饰符:
private static final - 源码定位:
L8 - 说明:
TODO
- 类型:
-
TYPE- 类型:
TagType<ShortTag> - 修饰符:
public static final public public private static public public public - 源码定位:
L9 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.nbt.ShortTag.Cache- 类型:
class - 修饰符:
private static - 源码定位:
L125 - 说明:
TODO
- 类型:
构造器
public ShortTag(short value) @ L40
- 构造器名:ShortTag
- 源码定位:L40
- 修饰符:public
参数:
- value: short
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static ShortTag valueOf(short i) @ L45
- 方法名:valueOf
- 源码定位:L45
- 返回类型:ShortTag
- 修饰符:public static
参数:
- i: short
说明:
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<ShortTag> getType() @ L64
- 方法名:getType
- 源码定位:L64
- 返回类型:TagType
- 修饰符:public
参数:
- 无
说明:
TODO
public ShortTag copy() @ L69
- 方法名:copy
- 源码定位:L69
- 返回类型:ShortTag
- 修饰符: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 ShortTag(short value) implements NumericTag {
private static final int SELF_SIZE_IN_BYTES = 10;
public static final TagType<ShortTag> TYPE = new TagType.StaticSize<ShortTag>() {
public ShortTag load(DataInput input, NbtAccounter accounter) throws IOException {
return ShortTag.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 short readAccounted(DataInput input, NbtAccounter accounter) throws IOException {
accounter.accountBytes(10L);
return input.readShort();
}
@Override
public int size() {
return 2;
}
@Override
public String getName() {
return "SHORT";
}
@Override
public String getPrettyName() {
return "TAG_Short";
}
};
@Deprecated(forRemoval = true)
public ShortTag(short value) {
this.value = value;
}
public static ShortTag valueOf(short i) {
return i >= -128 && i <= 1024 ? ShortTag.Cache.cache[i - -128] : new ShortTag(i);
}
@Override
public void write(DataOutput output) throws IOException {
output.writeShort(this.value);
}
@Override
public int sizeInBytes() {
return 10;
}
@Override
public byte getId() {
return 2;
}
@Override
public TagType<ShortTag> getType() {
return TYPE;
}
public ShortTag copy() {
return this;
}
@Override
public void accept(TagVisitor visitor) {
visitor.visitShort(this);
}
@Override
public long longValue() {
return this.value;
}
@Override
public int intValue() {
return this.value;
}
@Override
public short shortValue() {
return this.value;
}
@Override
public byte byteValue() {
return (byte)(this.value & 255);
}
@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.visitShort(this);
return visitor.build();
}
private static class Cache {
private static final int HIGH = 1024;
private static final int LOW = -128;
static final ShortTag[] cache = new ShortTag[1153];
static {
for (int i = 0; i < cache.length; i++) {
cache[i] = new ShortTag((short)(-128 + i));
}
}
}
}引用的其他类
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
StringTagVisitor()
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置: