Skip to content

Commit

Permalink
Add readNbtString to scripting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenny-Hui committed Feb 9, 2025
1 parent 80c7291 commit 3036eb6
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import com.lx862.mtrscripting.api.ScriptingAPI;
import com.lx862.mtrscripting.scripting.util.GraphicsTexture;

import com.mojang.brigadier.exceptions.CommandSyntaxException;
import org.apache.commons.io.IOUtils;
import org.mtr.mapping.holder.CompoundTag;
import vendor.com.lx862.jcm.org.mozilla.javascript.Context;
import vendor.com.lx862.jcm.org.mozilla.javascript.Scriptable;
import org.mtr.mapping.holder.Identifier;
Expand Down Expand Up @@ -188,9 +190,18 @@ public static Font readFont(Identifier identifier) {
ScriptManager.LOGGER.error("[Scripting] Failed to read font:", e);
}
});

return result[0];
}

public static CompoundTag readNbtString(String str) throws CommandSyntaxException {
#if LOADER == "forge"
return new CompoundTag(net.minecraft.nbt.TagParser.parseTag(str));
#else
return new CompoundTag(net.minecraft.nbt.StringNbtReader.parse(str));
#endif
}

public static String getAddonVersion(String modid) {
return ScriptingAPI.getAddonVersion(modid);
}
Expand Down

0 comments on commit 3036eb6

Please sign in to comment.