Refactor default recipe clearing part 2

This commit is contained in:
gabriel1379 2024-04-08 11:01:31 +02:00
parent 06ca0371ea
commit 03d62da9c9
1 changed files with 64 additions and 57 deletions

View File

@ -8,6 +8,69 @@ function technic.register_compressor_recipe(data)
technic.register_recipe("compressing", data)
end
-- Defuse the default recipes, since we have
-- the compressor to take over in a more realistic manner.
local crafts_to_clear = {
"default:desert_sand",
"default:sand",
"default:silver_sand",
}
local dependent_crafts_to_clear = {
everness = {
"everness:coral_sand",
"everness:coral_forest_deep_ocean_sand",
"everness:coral_white_sand",
"everness:crystal_sand",
"everness:cursed_sand",
"everness:cursed_lands_deep_ocean_sand",
"everness:crystal_forest_deep_ocean_sand",
"everness:mineral_sand",
},
nether = {
"nether:brick",
"nether:brick_compressed",
},
}
-- Add dependent recipes to main collection of
-- recipes to be cleared if their mods are used.
for dependency, crafts in pairs(dependent_crafts_to_clear) do
if minetest.get_modpath(dependency) then
for _, craft_entry in ipairs(crafts) do
table.insert(crafts_to_clear, craft_entry)
end
end
end
-- Clear recipes
for _, craft_name in ipairs(crafts_to_clear) do
is_regular = string.sub(craft_name, 1, 7) ~= "nether:"
if is_regular then
-- Regular compression recipes use 2x2 shape.
shaped_recipe = {
{craft_name, craft_name},
{craft_name, craft_name},
}
else
-- Nether's compression recipes use 3x3 shape.
shaped_recipe = {
{craft_name, craft_name, craft_name},
{craft_name, craft_name, craft_name},
{craft_name, craft_name, craft_name},
}
end
minetest.clear_craft({
type = "shaped",
recipe = shaped_recipe,
})
end
--
-- Compile compressor recipes
--
local recipes = {
{"default:snowblock", "default:ice"},
{"default:sand 2", "default:sandstone"},
@ -48,63 +111,7 @@ for dependency, recipes_to_add in pairs(dependent_recipes) do
end
end
-- Defuse the default sandstone recipes, since we have
-- the compressor to take over in a more realistic manner.
local crafts_to_clear = {
"default:desert_sand",
"default:sand",
"default:silver_sand",
}
local dependent_crafts_to_clear = {
everness = {
"everness:coral_sand",
"everness:coral_forest_deep_ocean_sand",
"everness:coral_white_sand",
"everness:crystal_sand",
"everness:cursed_sand",
"everness:cursed_lands_deep_ocean_sand",
"everness:crystal_forest_deep_ocean_sand",
"everness:mineral_sand",
},
nether = {
"nether:brick",
"nether:brick_compressed",
},
}
for dependency, crafts in pairs(dependent_crafts_to_clear) do
if minetest.get_modpath(dependency) then
for _, craft_entry in ipairs(crafts) do
table.insert(crafts_to_clear, craft_entry)
end
end
end
for _, craft_name in ipairs(crafts_to_clear) do
is_regular = string.sub(craft_name, 1, 7) ~= "nether:"
if is_regular then
-- Regular compression recipes use 2x2 shape.
shaped_recipe = {
{craft_name, craft_name},
{craft_name, craft_name},
}
else
-- Nether's compression recipes use 3x3 shape.
shaped_recipe = {
{craft_name, craft_name, craft_name},
{craft_name, craft_name, craft_name},
{craft_name, craft_name, craft_name},
}
end
minetest.clear_craft({
type = "shaped",
recipe = shaped_recipe,
})
end
-- Register compressor recipes
for _, data in pairs(recipes) do
technic.register_compressor_recipe({input = {data[1]}, output = data[2]})
end