IntArrayTag.java
net.minecraft.nbt.IntArrayTag
信息
- 全限定名:net.minecraft.nbt.IntArrayTag
- 类型:public final class
- 包:net.minecraft.nbt
- 源码路径:src/main/java/net/minecraft/nbt/IntArrayTag.java
- 起始行号:L10
- 实现:CollectionTag
- 职责:
TODO
字段/常量
-
SELF_SIZE_IN_BYTES- 类型:
int - 修饰符:
private static final - 源码定位:
L11 - 说明:
TODO
- 类型:
-
TYPE- 类型:
TagType<IntArrayTag> - 修饰符:
public static final public public private static public public public - 源码定位:
L12 - 说明:
TODO
- 类型:
-
data- 类型:
int[] - 修饰符:
private - 源码定位:
L50 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public IntArrayTag(int[] data) @ L52
- 构造器名:IntArrayTag
- 源码定位:L52
- 修饰符:public
参数:
- data: int[]
说明:
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<IntArrayTag> getType() @ L75
- 方法名:getType
- 源码定位:L75
- 返回类型:TagType
- 修饰符:public
参数:
- 无
说明:
TODO
public String toString() @ L80
- 方法名:toString
- 源码定位:L80
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
public IntArrayTag copy() @ L87
- 方法名:copy
- 源码定位:L87
- 返回类型:IntArrayTag
- 修饰符: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 int[] getAsIntArray() @ L103
- 方法名:getAsIntArray
- 源码定位:L103
- 返回类型:int[]
- 修饰符:public
参数:
- 无
说明:
TODO
public void accept(TagVisitor visitor) @ L107
- 方法名:accept
- 源码定位:L107
- 返回类型:void
- 修饰符:public
参数:
- visitor: TagVisitor
说明:
TODO
public int size() @ L112
- 方法名:size
- 源码定位:L112
- 返回类型:int
- 修饰符:public
参数:
- 无
说明:
TODO
public IntTag get(int index) @ L117
- 方法名:get
- 源码定位:L117
- 返回类型:IntTag
- 修饰符: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 IntTag remove(int index) @ L141
- 方法名:remove
- 源码定位:L141
- 返回类型:IntTag
- 修饰符:public
参数:
- index: int
说明:
TODO
public void clear() @ L147
- 方法名:clear
- 源码定位:L147
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public Optional<int[]> asIntArray() @ L152
- 方法名:asIntArray
- 源码定位:L152
- 返回类型:Optional<int[]>
- 修饰符:public
参数:
- 无
说明:
TODO
public StreamTagVisitor.ValueResult accept(StreamTagVisitor visitor) @ L157
- 方法名:accept
- 源码定位:L157
- 返回类型:StreamTagVisitor.ValueResult
- 修饰符:public
参数:
- visitor: StreamTagVisitor
说明:
TODO
代码
public final class IntArrayTag implements CollectionTag {
private static final int SELF_SIZE_IN_BYTES = 24;
public static final TagType<IntArrayTag> TYPE = new TagType.VariableSize<IntArrayTag>() {
public IntArrayTag load(DataInput input, NbtAccounter accounter) throws IOException {
return new IntArrayTag(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(24L);
int length = input.readInt();
accounter.accountBytes(4L, length);
int[] data = new int[length];
for (int i = 0; i < length; i++) {
data[i] = input.readInt();
}
return data;
}
@Override
public void skip(DataInput input, NbtAccounter accounter) throws IOException {
input.skipBytes(input.readInt() * 4);
}
@Override
public String getName() {
return "INT[]";
}
@Override
public String getPrettyName() {
return "TAG_Int_Array";
}
};
private int[] data;
public IntArrayTag(int[] data) {
this.data = data;
}
@Override
public void write(DataOutput output) throws IOException {
output.writeInt(this.data.length);
for (int i : this.data) {
output.writeInt(i);
}
}
@Override
public int sizeInBytes() {
return 24 + 4 * this.data.length;
}
@Override
public byte getId() {
return 11;
}
@Override
public TagType<IntArrayTag> getType() {
return TYPE;
}
@Override
public String toString() {
StringTagVisitor visitor = new StringTagVisitor();
visitor.visitIntArray(this);
return visitor.build();
}
public IntArrayTag copy() {
int[] cp = new int[this.data.length];
System.arraycopy(this.data, 0, cp, 0, this.data.length);
return new IntArrayTag(cp);
}
@Override
public boolean equals(Object obj) {
return this == obj ? true : obj instanceof IntArrayTag && Arrays.equals(this.data, ((IntArrayTag)obj).data);
}
@Override
public int hashCode() {
return Arrays.hashCode(this.data);
}
public int[] getAsIntArray() {
return this.data;
}
@Override
public void accept(TagVisitor visitor) {
visitor.visitIntArray(this);
}
@Override
public int size() {
return this.data.length;
}
public IntTag get(int index) {
return IntTag.valueOf(this.data[index]);
}
@Override
public boolean setTag(int index, Tag tag) {
if (tag instanceof NumericTag numeric) {
this.data[index] = numeric.intValue();
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.intValue());
return true;
} else {
return false;
}
}
public IntTag remove(int index) {
int prev = this.data[index];
this.data = ArrayUtils.remove(this.data, index);
return IntTag.valueOf(prev);
}
@Override
public void clear() {
this.data = new int[0];
}
@Override
public Optional<int[]> asIntArray() {
return Optional.of(this.data);
}
@Override
public StreamTagVisitor.ValueResult accept(StreamTagVisitor visitor) {
return visitor.visit(this.data);
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
System.arraycopy()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
IntTag.valueOf()
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
构造调用 - 关联成员:
StringTagVisitor()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置: