LongArrayTag.java
net.minecraft.nbt.LongArrayTag
信息
- 全限定名:net.minecraft.nbt.LongArrayTag
- 类型:public final class
- 包:net.minecraft.nbt
- 源码路径:src/main/java/net/minecraft/nbt/LongArrayTag.java
- 起始行号:L10
- 实现:CollectionTag
- 职责:
TODO
字段/常量
-
SELF_SIZE_IN_BYTES- 类型:
int - 修饰符:
private static final - 源码定位:
L11 - 说明:
TODO
- 类型:
-
TYPE- 类型:
TagType<LongArrayTag> - 修饰符:
public static final public public private static public public public - 源码定位:
L12 - 说明:
TODO
- 类型:
-
data- 类型:
long[] - 修饰符:
private - 源码定位:
L50 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public LongArrayTag(long[] data) @ L52
- 构造器名:LongArrayTag
- 源码定位:L52
- 修饰符:public
参数:
- data: long[]
说明:
TODO
方法
下面的方法块按源码顺序生成。
public void write(DataOutput output) @ L56
- 方法名:write
- 源码定位:L56
- 返回类型:void
- 修饰符:public
参数:
- output: DataOutput
说明:
TODO
public int sizeInBytes() @ L65
- 方法名:sizeInBytes
- 源码定位:L65
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public byte getId() @ L70
- 方法名:getId
- 源码定位:L70
- 返回类型:byte
- 修饰符:public
参数:
- 无
说明:
TODO
public TagType<LongArrayTag> getType() @ L75
- 方法名:getType
- 源码定位:L75
- 返回类型:TagType
- 修饰符:public
参数:
- 无
说明:
TODO
public String toString() @ L80
- 方法名:toString
- 源码定位:L80
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public LongArrayTag copy() @ L87
- 方法名:copy
- 源码定位:L87
- 返回类型:LongArrayTag
- 修饰符:public
参数:
- 无
说明:
TODO
public boolean equals(Object obj) @ L93
- 方法名:equals
- 源码定位:L93
- 返回类型:boolean
- 修饰符:public
参数:
- obj: Object
说明:
TODO
public int hashCode() @ L98
- 方法名:hashCode
- 源码定位:L98
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public void accept(TagVisitor visitor) @ L103
- 方法名:accept
- 源码定位:L103
- 返回类型:void
- 修饰符:public
参数:
- visitor: TagVisitor
说明:
TODO
public long[] getAsLongArray() @ L108
- 方法名:getAsLongArray
- 源码定位:L108
- 返回类型:long[]
- 修饰符:public
参数:
- 无
说明:
TODO
public int size() @ L112
- 方法名:size
- 源码定位:L112
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public LongTag get(int index) @ L117
- 方法名:get
- 源码定位:L117
- 返回类型:LongTag
- 修饰符:public
参数:
- index: int
说明:
TODO
public boolean setTag(int index, Tag tag) @ L121
- 方法名:setTag
- 源码定位:L121
- 返回类型:boolean
- 修饰符:public
参数:
- index: int
- tag: Tag
说明:
TODO
public boolean addTag(int index, Tag tag) @ L131
- 方法名:addTag
- 源码定位:L131
- 返回类型:boolean
- 修饰符:public
参数:
- index: int
- tag: Tag
说明:
TODO
public LongTag remove(int index) @ L141
- 方法名:remove
- 源码定位:L141
- 返回类型:LongTag
- 修饰符:public
参数:
- index: int
说明:
TODO
public void clear() @ L147
- 方法名:clear
- 源码定位:L147
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public Optional<long[]> asLongArray() @ L152
- 方法名:asLongArray
- 源码定位:L152
- 返回类型:Optional<long[]>
- 修饰符:public
参数:
- 无
说明:
TODO
public StreamTagVisitor.ValueResult accept(StreamTagVisitor visitor) @ L157
- 方法名:accept
- 源码定位:L157
- 返回类型:StreamTagVisitor.ValueResult
- 修饰符:public
参数:
- visitor: StreamTagVisitor
说明:
TODO
代码
public final class LongArrayTag implements CollectionTag {
private static final int SELF_SIZE_IN_BYTES = 24;
public static final TagType<LongArrayTag> TYPE = new TagType.VariableSize<LongArrayTag>() {
public LongArrayTag load(DataInput input, NbtAccounter accounter) throws IOException {
return new LongArrayTag(readAccounted(input, accounter));
}
@Override
public StreamTagVisitor.ValueResult parse(DataInput input, StreamTagVisitor output, NbtAccounter accounter) throws IOException {
return output.visit(readAccounted(input, accounter));
}
private static long[] readAccounted(DataInput input, NbtAccounter accounter) throws IOException {
accounter.accountBytes(24L);
int length = input.readInt();
accounter.accountBytes(8L, length);
long[] data = new long[length];
for (int i = 0; i < length; i++) {
data[i] = input.readLong();
}
return data;
}
@Override
public void skip(DataInput input, NbtAccounter accounter) throws IOException {
input.skipBytes(input.readInt() * 8);
}
@Override
public String getName() {
return "LONG[]";
}
@Override
public String getPrettyName() {
return "TAG_Long_Array";
}
};
private long[] data;
public LongArrayTag(long[] data) {
this.data = data;
}
@Override
public void write(DataOutput output) throws IOException {
output.writeInt(this.data.length);
for (long i : this.data) {
output.writeLong(i);
}
}
@Override
public int sizeInBytes() {
return 24 + 8 * this.data.length;
}
@Override
public byte getId() {
return 12;
}
@Override
public TagType<LongArrayTag> getType() {
return TYPE;
}
@Override
public String toString() {
StringTagVisitor visitor = new StringTagVisitor();
visitor.visitLongArray(this);
return visitor.build();
}
public LongArrayTag copy() {
long[] cp = new long[this.data.length];
System.arraycopy(this.data, 0, cp, 0, this.data.length);
return new LongArrayTag(cp);
}
@Override
public boolean equals(Object obj) {
return this == obj ? true : obj instanceof LongArrayTag && Arrays.equals(this.data, ((LongArrayTag)obj).data);
}
@Override
public int hashCode() {
return Arrays.hashCode(this.data);
}
@Override
public void accept(TagVisitor visitor) {
visitor.visitLongArray(this);
}
public long[] getAsLongArray() {
return this.data;
}
@Override
public int size() {
return this.data.length;
}
public LongTag get(int index) {
return LongTag.valueOf(this.data[index]);
}
@Override
public boolean setTag(int index, Tag tag) {
if (tag instanceof NumericTag numeric) {
this.data[index] = numeric.longValue();
return true;
} else {
return false;
}
}
@Override
public boolean addTag(int index, Tag tag) {
if (tag instanceof NumericTag numeric) {
this.data = ArrayUtils.add(this.data, index, numeric.longValue());
return true;
} else {
return false;
}
}
public LongTag remove(int index) {
long prev = this.data[index];
this.data = ArrayUtils.remove(this.data, index);
return LongTag.valueOf(prev);
}
@Override
public void clear() {
this.data = new long[0];
}
@Override
public Optional<long[]> asLongArray() {
return Optional.of(this.data);
}
@Override
public StreamTagVisitor.ValueResult accept(StreamTagVisitor visitor) {
return visitor.visit(this.data);
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
System.arraycopy()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
LongTag.valueOf()
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
StringTagVisitor()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置: