diff --git a/smithed_libraries/packs/crafter/beet.yaml b/smithed_libraries/packs/crafter/beet.yaml index f192491..d08e118 100644 --- a/smithed_libraries/packs/crafter/beet.yaml +++ b/smithed_libraries/packs/crafter/beet.yaml @@ -2,7 +2,7 @@ extend: "@smithed_libraries/common.yaml" id: smithed.crafter name: Smithed Crafter -version: "0.3.0" +version: "0.3.1" description: Native Library for Smithed author: TheNuclearNexus diff --git a/smithed_libraries/plugins/crafter.py b/smithed_libraries/plugins/crafter.py index 7b7cf1c..2b4d758 100644 --- a/smithed_libraries/plugins/crafter.py +++ b/smithed_libraries/plugins/crafter.py @@ -1,21 +1,11 @@ -import requests from beet import Context, ItemTag -def cache_item_list(ctx: Context, cache_identifier: str): - url = f"https://raw.githubusercontent.com/misode/mcmeta/{ctx.minecraft_version}-registries/item/data.json" - r = requests.get(url) - if not r.ok: - raise Exception(f"Failed to get {url}") - data = r.json() - ctx.cache.json[cache_identifier] = data - - def beet_default(ctx: Context): - cache_identifier = f"item_list@{ctx.minecraft_version}" - if cache_identifier not in ctx.cache.json: - cache_item_list(ctx, cache_identifier) + cache = ctx.cache["smithed_crafter"] + + all_items_url = f"https://raw.githubusercontent.com/misode/mcmeta/{ctx.minecraft_version}-registries/item/data.json" + all_items = ItemTag(source_path=cache.download(all_items_url)) + all_items.data = {"values": all_items.data} - ctx.data.item_tags["smithed.crafter:all"] = ItemTag( - {"values": ctx.cache.json[cache_identifier]} - ) + ctx.generate("smithed.crafter:all", all_items)