io.github.karlatemp.mxlib.nbt.NBTBase Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2018-2021 Karlatemp. All rights reserved.
* @author Karlatemp
*
* MXLib/MXLib.mxlib-nbt.main/NBTBase.java
*
* Use of this source code is governed by the MIT license that can be found via the following link.
*
* https://github.com/Karlatemp/MxLib/blob/master/LICENSE
*/
package io.github.karlatemp.mxlib.nbt;
import io.github.karlatemp.mxlib.nbt.visitor.NBTVisitor;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public interface NBTBase {
static NBTBase createTag(byte id) {
switch (id) {
case 0:
return new NBTTagEnd();
case 1:
return new NBTTagByte();
case 2:
return new NBTTagShort();
case 3:
return new NBTTagInt();
case 4:
return new NBTTagLong();
case 5:
return new NBTTagFloat();
case 6:
return new NBTTagDouble();
case 7:
return new NBTTagByteArray();
case 8:
return new NBTTagString();
case 9:
return new NBTTagList();
case 10:
return new NBTTagCompound();
case 11:
return new NBTTagIntArray();
case 12:
return new NBTTagLongArray();
}
return null;
}
void write(DataOutput out) throws IOException;
void load(DataInput input, int depth, NBTReadLimiter limiter) throws IOException;
String toString();
byte getTypeId();
default String asString() {
return toString();
}
NBTBase clone();
default void accept(String name, NBTVisitor visitor) {
}
static String l(int i) {
switch (i) {
case 0:
return "TAG_End";
case 1:
return "TAG_Byte";
case 2:
return "TAG_Short";
case 3:
return "TAG_Int";
case 4:
return "TAG_Long";
case 5:
return "TAG_Float";
case 6:
return "TAG_Double";
case 7:
return "TAG_Byte_Array";
case 8:
return "TAG_String";
case 9:
return "TAG_List";
case 10:
return "TAG_Compound";
case 11:
return "TAG_Int_Array";
case 12:
return "TAG_Long_Array";
case 99:
return "Any Numeric Tag";
default:
return "UNKNOWN";
}
}
}