use of com.sk89q.worldedit.util.nbt.StringBinaryTag in project FastAsyncWorldEdit by IntellectualSites.
the class PaperweightAdapter method fromNativeBinary.
/**
* Converts a WorldEdit-native NBT structure to a NMS structure.
*
* @param foreign structure to convert
* @return non-native structure
*/
@Override
public net.minecraft.nbt.Tag fromNativeBinary(BinaryTag foreign) {
if (foreign == null) {
return null;
}
if (foreign instanceof CompoundBinaryTag) {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
for (String key : ((CompoundBinaryTag) foreign).keySet()) {
tag.put(key, fromNativeBinary(((CompoundBinaryTag) foreign).get(key)));
}
return tag;
} else if (foreign instanceof ByteBinaryTag) {
return net.minecraft.nbt.ByteTag.valueOf(((ByteBinaryTag) foreign).value());
} else if (foreign instanceof ByteArrayBinaryTag) {
return new net.minecraft.nbt.ByteArrayTag(((ByteArrayBinaryTag) foreign).value());
} else if (foreign instanceof DoubleBinaryTag) {
return net.minecraft.nbt.DoubleTag.valueOf(((DoubleBinaryTag) foreign).value());
} else if (foreign instanceof FloatBinaryTag) {
return net.minecraft.nbt.FloatTag.valueOf(((FloatBinaryTag) foreign).value());
} else if (foreign instanceof IntBinaryTag) {
return net.minecraft.nbt.IntTag.valueOf(((IntBinaryTag) foreign).value());
} else if (foreign instanceof IntArrayBinaryTag) {
return new net.minecraft.nbt.IntArrayTag(((IntArrayBinaryTag) foreign).value());
} else if (foreign instanceof LongArrayBinaryTag) {
return new net.minecraft.nbt.LongArrayTag(((LongArrayBinaryTag) foreign).value());
} else if (foreign instanceof ListBinaryTag) {
net.minecraft.nbt.ListTag tag = new net.minecraft.nbt.ListTag();
ListBinaryTag foreignList = (ListBinaryTag) foreign;
for (BinaryTag t : foreignList) {
tag.add(fromNativeBinary(t));
}
return tag;
} else if (foreign instanceof LongBinaryTag) {
return net.minecraft.nbt.LongTag.valueOf(((LongBinaryTag) foreign).value());
} else if (foreign instanceof ShortBinaryTag) {
return net.minecraft.nbt.ShortTag.valueOf(((ShortBinaryTag) foreign).value());
} else if (foreign instanceof StringBinaryTag) {
return net.minecraft.nbt.StringTag.valueOf(((StringBinaryTag) foreign).value());
} else if (foreign instanceof EndBinaryTag) {
return net.minecraft.nbt.EndTag.INSTANCE;
} else {
throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName());
}
}
Aggregations