]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix cooking and fuel crafts with aliases
authorJude Melton-Houghton <jwmhjwmh@gmail.com>
Mon, 9 May 2022 22:21:08 +0000 (18:21 -0400)
committersfan5 <sfan5@live.de>
Tue, 10 May 2022 20:37:05 +0000 (22:37 +0200)
games/devtest/mods/unittests/crafting_prepare.lua
src/craftdef.cpp

index a09734827db79e230bc31b40cd4b9dd3dfbc3ade..5cf5775e014d4a4c7a4699056e21b88f9671aefd 100644 (file)
@@ -31,25 +31,31 @@ minetest.register_craftitem("unittests:steel_ingot", {
        groups = { dummy = 1 },
 })
 
+-- Use aliases in recipes for more complete testing
+
+minetest.register_alias("unittests:steel_ingot_alias", "unittests:steel_ingot")
+minetest.register_alias("unittests:coal_lump_alias", "unittests:coal_lump")
+minetest.register_alias("unittests:iron_lump_alias", "unittests:iron_lump")
+
 -- Recipes for tests: Normal crafting, cooking and fuel
 
 minetest.register_craft({
        output = 'unittests:torch 4',
        recipe = {
-               {'unittests:coal_lump'},
+               {'unittests:coal_lump_alias'},
                {'unittests:stick'},
        }
 })
 
 minetest.register_craft({
        type = "cooking",
-       output = "unittests:steel_ingot",
-       recipe = "unittests:iron_lump",
+       output = "unittests:steel_ingot_alias",
+       recipe = "unittests:iron_lump_alias",
 })
 
 minetest.register_craft({
        type = "fuel",
-       recipe = "unittests:coal_lump",
+       recipe = "unittests:coal_lump_alias",
        burntime = 40,
 })
 
index 21060519839072636a897a13efb31c58645c535b..c05a0cfb75c57984121425015e35c0ffdf7d0563 100644 (file)
@@ -734,7 +734,8 @@ bool CraftDefinitionCooking::check(const CraftInput &input, IGameDef *gamedef) c
        }
 
        // Check the single input item
-       return inputItemMatchesRecipe(input_filtered[0], recipe, gamedef->idef());
+       std::string rec_name = craftGetItemName(recipe, gamedef);
+       return inputItemMatchesRecipe(input_filtered[0], rec_name, gamedef->idef());
 }
 
 CraftOutput CraftDefinitionCooking::getOutput(const CraftInput &input, IGameDef *gamedef) const
@@ -836,7 +837,8 @@ bool CraftDefinitionFuel::check(const CraftInput &input, IGameDef *gamedef) cons
        }
 
        // Check the single input item
-       return inputItemMatchesRecipe(input_filtered[0], recipe, gamedef->idef());
+       std::string rec_name = craftGetItemName(recipe, gamedef);
+       return inputItemMatchesRecipe(input_filtered[0], rec_name, gamedef->idef());
 }
 
 CraftOutput CraftDefinitionFuel::getOutput(const CraftInput &input, IGameDef *gamedef) const