internal static JObject CompoundTagSerialize(CompoundTag tag) { JObject json = new JObject(); foreach (KeyValuePair <string, Tag> kv in tag.Tags) { Tag t = kv.Value; if (t is ByteTag) { json.Add(t.Name, new JValue(tag.GetByte(t.Name))); } else if (t is CompoundTag) { json.Add(t.Name, NBTJsonSerializer.CompoundTagSerialize((CompoundTag)t)); } else if (t is DoubleTag) { json.Add(t.Name, new JValue(tag.GetDouble(t.Name))); } else if (t is FloatTag) { json.Add(t.Name, new JValue(tag.GetFloat(t.Name))); } else if (t is IntTag) { json.Add(t.Name, new JValue(tag.GetInt(t.Name))); } else if (t is ListTag) { json.Add(t.Name, new JArray(NBTJsonSerializer.ListTagSerialize((ListTag)t))); } else if (t is LongTag) { json.Add(t.Name, new JValue(tag.GetLong(t.Name))); } else if (t is ShortTag) { json.Add(t.Name, new JValue(tag.GetShort(t.Name))); } else if (t is StringTag) { json.Add(t.Name, new JValue(tag.GetString(t.Name))); } } return(json); }
public void NBTIOTests_ReadRawFileTest() { CompoundTag tag = NBTIO.ReadRawFile(Environment.CurrentDirectory + "\\test.nbt"); tag.GetBool("bool"); tag.GetByte("byte"); tag.GetByteArray("byteArray"); tag.GetShort("short"); tag.GetInt("int"); tag.GetIntArray("intArray"); tag.GetLong("long"); tag.GetLongArray("longArray"); tag.GetFloat("float"); tag.GetDouble("double"); tag.GetList("list"); tag.GetCompound("com"); Console.WriteLine(tag); }