1
0
Fork 0

Fix stonecutter warnings (#4315)

This fixes faulty fallthrough mechanisms attempting to register the same recipe more than once in some cases. This fixes the warning spam when entering a world, while keeping the warnings for mods that misuse the Stonecutter API.

Reviewed-on: VoxeLibre/VoxeLibre#4315
Co-authored-by: the-real-herowl <wiktor_t-i@proton.me>
Co-committed-by: the-real-herowl <wiktor_t-i@proton.me>
This commit is contained in:
the-real-herowl 2024-05-24 10:31:27 +00:00 committed by the-real-herowl
parent a499d292f8
commit cb4396d424
1 changed files with 4 additions and 2 deletions

View File

@ -66,13 +66,15 @@ function mcl_stonecutter.register_recipe(input, output, count)
local fallthrough = mcl_stonecutter.registered_recipes[output] local fallthrough = mcl_stonecutter.registered_recipes[output]
if fallthrough then if fallthrough then
for o, c in pairs(fallthrough) do for o, c in pairs(fallthrough) do
mcl_stonecutter.register_recipe(input, o, c * count) if not mcl_stonecutter.registered_recipes[input][o] then
mcl_stonecutter.register_recipe(input, o, c * count)
end
end end
end end
for i, recipes in pairs(mcl_stonecutter.registered_recipes) do for i, recipes in pairs(mcl_stonecutter.registered_recipes) do
for name, c in pairs(recipes) do for name, c in pairs(recipes) do
if name == input then if name == input and not mcl_stonecutter.registered_recipes[i][output] then
mcl_stonecutter.register_recipe(i, output, c * count) mcl_stonecutter.register_recipe(i, output, c * count)
end end
end end