Last active
May 14, 2021 22:06
-
-
Save MeinLiX/456a0c43ebb914db2e16c59611bab0d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Parser() | |
{ | |
var src = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); | |
if (src == null) throw new Exception(); | |
src = Path.Combine(src, "..\\..\\..\\assets", "blocks.json"); | |
var blocks = JsonConvert.DeserializeObject<Dictionary<string, Lava.Blocks.json.BlockInfo>>(File.ReadAllText(src)); | |
List<string> b = new List<string>(); | |
foreach (var (name, info) in blocks) | |
{ | |
var blockName = TextCase.ToPascalCase(name.Split(":")[1]); | |
blockName = char.ToUpper(blockName[0]) + blockName.Substring(1); | |
b.Add($"public static {blockName} {blockName} = new {blockName}();\n"); | |
} | |
using (FileStream fs = File.Create(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "..\\..\\..\\..\\newPalette.cs")) | |
{ | |
StringBuilder sb = new StringBuilder(); | |
foreach (var temp in b) | |
sb.Append(temp); | |
byte[] vs = new UTF8Encoding().GetBytes(sb.ToString()); | |
fs.Write(vs, 0, vs.Length); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment