@@ -37,13 +37,15 @@ def format_crafting_recipe_from_data(context: Context, buffer: List[str], identi
3737 return format_crafting_recipe_from_data (context , buffer , identifier , data ['recipe' ])
3838 elif recipe_type == 'tfc:advanced_shaped_crafting' :
3939 data ['type' ] = 'minecraft:crafting_shaped'
40- util .require ('stack' in data ['result' ], 'Advanced shaped crafting with complex modifiers: \' %s\' ' % data ['result' ])
41- data ['result' ] = data ['result' ]['stack' ] # Discard modifiers
40+ stack = util .anyof (data ['result' ], 'stack' , 'id' )
41+ util .require (stack is not None , 'Advanced shaped crafting with complex modifiers: \' %s\' ' % data ['result' ])
42+ data ['result' ] = stack # Discard modifiers
4243 return format_crafting_recipe_from_data (context , buffer , identifier , data )
4344 elif recipe_type == 'tfc:advanced_shapeless_crafting' :
4445 data ['type' ] = 'minecraft:crafting_shapeless'
45- util .require ('stack' in data ['result' ], 'Advanced shapeless crafting with complex modifiers: \' %s\' ' % data ['result' ])
46- data ['result' ] = data ['result' ]['stack' ] # Discard modifiers
46+ stack = util .anyof (data ['result' ], 'stack' , 'id' )
47+ util .require (stack is not None , 'Advanced shapeless crafting with complex modifiers: \' %s\' ' % data ['result' ])
48+ data ['result' ] = stack # Discard modifiers
4749 return format_crafting_recipe_from_data (context , buffer , identifier , data )
4850 else :
4951 raise util .error ('Unknown crafting recipe type: %s for recipe %s' % (recipe_type , identifier ))
@@ -87,7 +89,7 @@ def format_crafting_recipe_from_data(context: Context, buffer: List[str], identi
8789 ))
8890
8991
90- def format_ingredient (context : Context , data : Any ) -> Tuple [str , str ]:
92+ def format_ingredient (context : Context , data : Any ) -> Tuple [str , str | None ]:
9193 if 'item' in data :
9294 return item_loader .get_item_image (context , data ['item' ])
9395 elif 'tag' in data :
@@ -99,14 +101,27 @@ def format_ingredient(context: Context, data: Any) -> Tuple[str, str]:
99101 elif 'type' in data and data ['type' ] == 'tfc:fluid_item' :
100102 util .require (data ['fluid_ingredient' ]['ingredient' ] == 'minecraft:water' , 'Unknown `tfc:fluid_item` ingredient: \' %s\' ' % data )
101103 return item_loader .get_item_image (context , 'minecraft:water_bucket' )
104+ elif 'type' in data and data ['type' ] == 'tfc:fluid_content' :
105+ util .require (data ['fluid' ]['fluid' ] == 'minecraft:water' , 'Unknown `tfc:fluid_content` ingredient: \' %s\' ' % data )
106+ return item_loader .get_item_image (context , 'minecraft:water_bucket' )
107+ elif 'type' in data and data ['type' ] == 'tfc:and' :
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 )
102113 elif isinstance (data , List ):
103114 csvstring = ''
104115 for i in data :
105116 if 'item' in i :
106117 csvstring += ',' + str (i ['item' ])
107118 return item_loader .get_item_image (context , csvstring )
108119 else :
109- util .error ('Unsupported ingredient: %s' % data )
120+ util .error ('Unsupported ingredient: %s' % str (data ))
121+
122+ def format_sized_ingredient (context : Context , data : Any ) -> Tuple [Tuple [str , str | Any ], int ]:
123+ ing = format_ingredient (context , data )
124+ return ing , 1 if 'count' not in data else data ['count' ]
110125
111126def format_item_stack (context : Context , data : Any ) -> Tuple [str , str , int ]:
112127 if 'modifiers' in data and 'stack' in data :
0 commit comments