mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-23 03:56:15 +00:00
Core - Add McMeta.cs
This commit is contained in:
29
PckStudio.Core/IO/Java/McMeta.cs
Normal file
29
PckStudio.Core/IO/Java/McMeta.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace PckStudio.Core.IO.Java
|
||||
{
|
||||
public class McMeta : Dictionary<string, JObject>
|
||||
{
|
||||
private McMeta(Dictionary<string, JObject> type) : base(type)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Contains(string name) => ContainsKey(name);
|
||||
|
||||
public static McMeta LoadMcMeta(string mcMetaJson)
|
||||
{
|
||||
JObject a = JObject.Parse(mcMetaJson);
|
||||
Dictionary<string, JObject> types = new Dictionary<string, JObject>();
|
||||
foreach (KeyValuePair<string, JToken> item in a)
|
||||
{
|
||||
types.Add(item.Key, item.Value.ToObject<JObject>());
|
||||
}
|
||||
return new McMeta(types);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
PckStudio.Core/IO/Java/McPack.cs
Normal file
18
PckStudio.Core/IO/Java/McPack.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PckStudio.Core.IO.Java
|
||||
{
|
||||
public struct McPack
|
||||
{
|
||||
[JsonIgnore]
|
||||
public Image Icon;
|
||||
|
||||
[JsonProperty("pack_format")]
|
||||
public int Format;
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
using System.Drawing;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PckStudio.Core.IO.Java
|
||||
{
|
||||
public struct McPackmeta
|
||||
{
|
||||
[JsonProperty("pack")]
|
||||
public McPack Pack;
|
||||
public struct McPack
|
||||
{
|
||||
[JsonIgnore]
|
||||
public Image Icon;
|
||||
|
||||
[JsonIgnore]
|
||||
public int Format => _format;
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description;
|
||||
|
||||
[JsonProperty("pack_format")]
|
||||
private int _format;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user