Reliably reset crafting grid when no crafting table is near
This commit is contained in:
parent
637d924ccd
commit
9996c75de5
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user