From 779b3ffa69416e9ad2d2c2c3179bcac98af1d0f2 Mon Sep 17 00:00:00 2001 From: Seeloewen Date: Fri, 10 May 2024 01:29:51 +0200 Subject: [PATCH] Add support for datapack version 1.4.5 --- Tools/RIG 24w09a Updater/wndMain.xaml.cs | 29 +++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Tools/RIG 24w09a Updater/wndMain.xaml.cs b/Tools/RIG 24w09a Updater/wndMain.xaml.cs index 0e22022..2aba671 100644 --- a/Tools/RIG 24w09a Updater/wndMain.xaml.cs +++ b/Tools/RIG 24w09a Updater/wndMain.xaml.cs @@ -23,6 +23,9 @@ public partial class MainWindow : Window BackgroundWorker bgwUpdater = new BackgroundWorker(); wndAbout wndAbout; string datapack = ""; + string datapackVersion = "unknown"; + string mcVersion = "unknown"; + string versionBranch = "unknown"; //-- Constructor --// @@ -189,10 +192,24 @@ private string GetSpecificComponent(string fileName, string item) string splashpotion = item.Replace("\"tag\": \"{Potion:\\\"minecraft:", "").Replace("\\\"}\"", "").Replace(" ", ""); return "\"minecraft:potion_contents\": {\n \"potion\": \"minecraft:" + splashpotion + "\"\n }"; case "suspicious_stews.json": - string[] susnbt = item.Replace("\"tag\": \"{Effects:[{EffectId:", "").Replace("EffectDuration:", "").Replace("}]}\"", "").Replace(" ", "").Split(','); - string effect = susnbt[0]; - string duration = susnbt[1]; - return "\"minecraft:suspicious_stew_effects\": [\n {\n \"id\": \"minecraft:" + ConvertEffect(effect) + "\",\n \"duration\": " + duration + "\n }\n ]"; + string effect; + string duration; + + if (datapackVersion == "1.4.5") + { + string[] susnbt = item.Replace("\"tag\": \"{effects:[{id:\\\"minecraft:", "").Replace("duration:", "").Replace("}]}\"", "").Replace(" ", "").Replace("\\\"", "").Split(','); + effect = susnbt[0]; + duration = susnbt[1]; + return "\"minecraft:suspicious_stew_effects\": [\n {\n \"id\": \"minecraft:" + effect + "\",\n \"duration\": " + duration + "\n }\n ]"; + } + else + { + string[] susnbt = item.Replace("\"tag\": \"{Effects:[{EffectId:", "").Replace("EffectDuration:", "").Replace("}]}\"", "").Replace(" ", "").Split(','); + effect = susnbt[0]; + duration = susnbt[1]; + return "\"minecraft:suspicious_stew_effects\": [\n {\n \"id\": \"minecraft:" + ConvertEffect(effect) + "\",\n \"duration\": " + duration + "\n }\n ]"; + } + case "tipped_arrows.json": string tippedarrow = item.Replace("\"tag\": \"{Potion:\\\"minecraft:", "").Replace("\\\"}\"", "").Replace(" ", ""); return "\"minecraft:potion_contents\": {\n \"potion\": \"minecraft:" + tippedarrow + "\"\n }"; @@ -234,10 +251,6 @@ private string ConvertEffect(string effect) private bool CheckDatapackVersion() { //Checks the datapack version to make sure the software is compatible with it - string datapackVersion = "unknown"; - string mcVersion = "unknown"; - string versionBranch = "unknown"; - if (File.Exists($"{tbDatapack.Text}\\Updater.txt")) { //Go through the file to get the variables