Fix dispenser craft bug

This commit is contained in:
Wuzzy 2017-02-14 04:46:44 +01:00
parent fe6cf4de8f
commit a477c5d20e

View File

@ -271,7 +271,7 @@ minetest.register_craft({
}) })
-- Only allow crafting if the bow is intact -- Only allow crafting if the bow is intact
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) local check_craft = function(itemstack, player, old_craft_grid, craft_inv)
if itemstack:get_name() == "mcl_dispensers:dispenser" then if itemstack:get_name() == "mcl_dispensers:dispenser" then
local bow, id local bow, id
for i=1, craft_inv:get_size("craft") do for i=1, craft_inv:get_size("craft") do
@ -282,27 +282,12 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv
break break
end end
end end
if bow:get_wear() ~= 0 then if bow and bow:get_wear() ~= 0 then
return "" return ""
end end
end end
return nil return nil
end) end
minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) minetest.register_on_craft(check_craft)
if itemstack:get_name() == "mcl_dispensers:dispenser" then minetest.register_craft_predict(check_craft)
local bow, id
for i=1, craft_inv:get_size("craft") do
local item = craft_inv:get_stack("craft", i)
if item:get_name() == "mcl_throwing:bow" then
bow = item
id = i
break
end
end
if bow:get_wear() ~= 0 then
return ""
end
end
return nil
end)