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); }
internal static JArray ListTagSerialize(ListTag tag) { JArray json = new JArray(); foreach (Tag t in tag.Tags) { if (t is ByteTag) { json.Add(new JValue(((ByteTag)t).Data)); } else if (t is CompoundTag) { json.Add(NBTJsonSerializer.CompoundTagSerialize((CompoundTag)t)); } else if (t is DoubleTag) { json.Add(new JValue(((DoubleTag)t).Data)); } else if (t is FloatTag) { json.Add(new JValue(((FloatTag)t).Data)); } else if (t is IntTag) { json.Add(new JValue(((IntTag)t).Data)); } else if (t is ListTag) { json.Add(new JArray(NBTJsonSerializer.ListTagSerialize((ListTag)t))); } else if (t is LongTag) { json.Add(new JValue(((LongTag)t).Data)); } else if (t is ShortTag) { json.Add(new JValue(((ShortTag)t).Data)); } else if (t is StringTag) { json.Add(new JValue(((StringTag)t).Data)); } } return(json); }
public static JObject Serialize(CompoundTag tag) { JObject json = NBTJsonSerializer.CompoundTagSerialize(tag); return(json); }