diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index 3252e62d3..6688e86ad 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -438,6 +438,7 @@ local function get_tooltip(item, groups, cooktime, burntime) end local function get_recipe_fs(data, iY, player) + mcl_inventory.reset_craft_grid(player) local fs = {} local recipe = data.recipes[data.rnum] local width = recipe.width @@ -618,6 +619,7 @@ local function get_recipe_fs(data, iY, player) end local function make_formspec(name) + mcl_inventory.reset_craft_grid(minetest.get_player_by_name(name)) local data = player_data[name] local iY = data.iX - 5 local ipp = data.iX * iY diff --git a/mods/HUD/mcl_inventory/init.lua b/mods/HUD/mcl_inventory/init.lua index fb74029d2..13b1cc167 100644 --- a/mods/HUD/mcl_inventory/init.lua +++ b/mods/HUD/mcl_inventory/init.lua @@ -166,6 +166,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) end end) +function mcl_inventory.reset_craft_grid(player) + local inv = player:get_inventory() + if inv:get_size("craft") > 4 and not mcl_crafting_table.has_crafting_table(player) then + return_fields(player, "craft") + inv:set_width("craft", 2) + inv:set_size("craft", 4) + end +end + +minetest.register_craft_predict(function(itemstack, player, old_craft_grid, inv) + mcl_inventory.reset_craft_grid(player) +end) function mcl_inventory.update_inventory_formspec(player) set_inventory(player)