Fix cooking and fuel crafts with aliases

master
Jude Melton-Houghton 2022-05-09 18:21:08 -04:00 committed by sfan5
parent 4fb4991f5e
commit d17d7eba14
2 changed files with 14 additions and 6 deletions

View File

@ -31,25 +31,31 @@ minetest.register_craftitem("unittests:steel_ingot", {
groups = { dummy = 1 }, 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 -- Recipes for tests: Normal crafting, cooking and fuel
minetest.register_craft({ minetest.register_craft({
output = 'unittests:torch 4', output = 'unittests:torch 4',
recipe = { recipe = {
{'unittests:coal_lump'}, {'unittests:coal_lump_alias'},
{'unittests:stick'}, {'unittests:stick'},
} }
}) })
minetest.register_craft({ minetest.register_craft({
type = "cooking", type = "cooking",
output = "unittests:steel_ingot", output = "unittests:steel_ingot_alias",
recipe = "unittests:iron_lump", recipe = "unittests:iron_lump_alias",
}) })
minetest.register_craft({ minetest.register_craft({
type = "fuel", type = "fuel",
recipe = "unittests:coal_lump", recipe = "unittests:coal_lump_alias",
burntime = 40, burntime = 40,
}) })

View File

@ -734,7 +734,8 @@ bool CraftDefinitionCooking::check(const CraftInput &input, IGameDef *gamedef) c
} }
// Check the single input item // 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 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 // 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 CraftOutput CraftDefinitionFuel::getOutput(const CraftInput &input, IGameDef *gamedef) const