Skip to content

Commit

Permalink
fix: use updated code from @fizzy
Browse files Browse the repository at this point in the history
  • Loading branch information
RitikShah committed Nov 2, 2023
1 parent fc7fbce commit 02b544a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion smithed_libraries/packs/crafter/beet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 6 additions & 16 deletions smithed_libraries/plugins/crafter.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 02b544a

Please sign in to comment.