Skip to content

Commit 2f3014a

Browse files
committed
even more coverage of recipes n stuff
1 parent d1e8da1 commit 2f3014a

5 files changed

Lines changed: 54 additions & 15 deletions

File tree

src/components/crafting_recipe.py

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,38 @@ def format_crafting_recipe_from_data(context: Context, buffer: List[str], identi
8989
))
9090

9191

92+
def extract_items_from_ingredient(data: Any) -> List[str]:
93+
"""
94+
Recursively extract item/tag names from an ingredient.
95+
Returns a list of item names (e.g., ['minecraft:stone'] or ['#minecraft:planks'])
96+
"""
97+
if 'item' in data:
98+
return [data['item']]
99+
elif 'tag' in data:
100+
return ['#' + data['tag']]
101+
elif 'type' in data and data['type'] in ('tfc:not_rotten', 'tfc:has_trait', 'tfc:lacks_trait'):
102+
# These types wrap another ingredient
103+
if 'ingredient' in data:
104+
return extract_items_from_ingredient(data['ingredient'])
105+
else:
106+
# If no nested ingredient, return empty (just a filter)
107+
return []
108+
elif 'type' in data and (data['type'] == 'tfc:and' or data['type'] == 'neoforge:compound'):
109+
# Recursively extract from all children
110+
items = []
111+
for child in data['children']:
112+
items.extend(extract_items_from_ingredient(child))
113+
return items
114+
elif isinstance(data, list):
115+
items = []
116+
for item in data:
117+
items.extend(extract_items_from_ingredient(item))
118+
return items
119+
else:
120+
# Unknown format, return empty
121+
return []
122+
123+
92124
def format_ingredient(context: Context, data: Any) -> Tuple[str, str | None]:
93125
if 'item' in data:
94126
return item_loader.get_item_image(context, data['item'])
@@ -105,17 +137,23 @@ def format_ingredient(context: Context, data: Any) -> Tuple[str, str | None]:
105137
# Handle any fluid using the fluid bucket image with colorization
106138
return fluid_loader.get_fluid_bucket_image(context, data['fluid'])
107139
elif 'type' in data and (data['type'] == 'tfc:and' or data['type'] == 'neoforge:compound'):
108-
csvstring = ''
109-
for i in data['children']:
110-
if 'item' in i:
111-
csvstring += ',' + str(i['item'])
112-
return item_loader.get_item_image(context, csvstring)
113-
elif isinstance(data, List):
114-
csvstring = ''
115-
for i in data:
116-
if 'item' in i:
117-
csvstring += ',' + str(i['item'])
118-
return item_loader.get_item_image(context, csvstring)
140+
# Extract all item/tag names from children recursively
141+
items = extract_items_from_ingredient(data)
142+
if items:
143+
csvstring = ','.join(items)
144+
return item_loader.get_item_image(context, csvstring)
145+
else:
146+
# Fallback to placeholder
147+
return ('../../_images/placeholder_64.png', None)
148+
elif isinstance(data, list):
149+
# Extract all item/tag names from list recursively
150+
items = extract_items_from_ingredient(data)
151+
if items:
152+
csvstring = ','.join(items)
153+
return item_loader.get_item_image(context, csvstring)
154+
else:
155+
# Fallback to placeholder
156+
return ('../../_images/placeholder_64.png', None)
119157
else:
120158
util.error('Unsupported ingredient: %s' % str(data))
121159

src/components/misc_recipe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
def format_misc_recipe(context: Context, buffer: List[str], identifier: str):
1111
data = context.loader.load_recipe(identifier)
1212
recipe_type = data['type']
13-
if recipe_type == 'tfc:quern':
13+
if recipe_type == 'tfc:quern' or recipe_type == 'firmalife:drying':
1414
format_misc_recipe_from_data(context, buffer, identifier, data)
1515
elif recipe_type == 'tfc:heating':
1616
format_misc_recipe_from_data(context, buffer, identifier, data, result='result_item')

src/loader.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ def __init__(self, tfc_dir: str, output_dir: str, use_mcmeta: bool, use_addons:
1919
self.domains = ['tfc']
2020
if use_mcmeta:
2121
self.loaders += [
22-
('forge', ('forge', 'minecraft', 'c'), mcmeta.load_from_forge),
22+
('forge', ('forge', 'neoforge', 'minecraft', 'c'), mcmeta.load_from_forge),
2323
('minecraft', ('minecraft',), mcmeta.load_from_mc)
2424
]
2525
self.domains += ['forge', 'minecraft']
2626
if use_addons:
2727
for addon in versions.ADDONS:
28-
self.loaders.append((addon.mod_id, (addon.mod_id, 'c', 'tfc', 'minecraft'), make_load_from_addon(addon)))
28+
self.loaders.append((addon.mod_id, (addon.mod_id, 'c', 'tfc', 'neoforge', 'minecraft'), make_load_from_addon(addon)))
2929
self.domains.append(addon.mod_id)
3030

3131
# Load paletted permutation textures from atlas

src/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ def parse_page(context: Context, entry_id: str, buffer: List[str], data: Any, se
354354
'tfc:loom_recipe',
355355
'tfc:anvil_recipe',
356356
'tfc:glassworking_recipe',
357+
'tfc:drying_recipe'
357358
):
358359
try:
359360
misc_recipe.format_misc_recipe(context, buffer, data['recipe'])

src/versions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class OldVersion(NamedTuple):
6868
LANGUAGES = ('en_us', 'ja_jp', 'pt_br', 'ko_kr', 'uk_ua', 'zh_cn', 'zh_hk', 'zh_tw', 'ru_ru')
6969

7070
ADDONS = (
71-
Addon('eerussianguy', 'firmalife', 'v3.0.0', 'firmalife', ['src/main/resources', 'src/generated/resources']),
71+
Addon('eerussianguy', 'firmalife', 'v3.0.1', 'firmalife', ['src/main/resources', 'src/generated/resources']),
7272
Addon('Notenoughmail', 'precision-prospecting', 'v2.0', 'precisionprospecting', ['src/generated/resources', 'src/main/resources']),
7373
)
7474

0 commit comments

Comments
 (0)