From a477c5d20e14168291e6f6e26519b143c6f3296e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 14 Feb 2017 04:46:44 +0100 Subject: [PATCH] Fix dispenser craft bug --- mods/redstone/mcl_dispensers/init.lua | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/mods/redstone/mcl_dispensers/init.lua b/mods/redstone/mcl_dispensers/init.lua index bee73b7b5f..9596888bf6 100644 --- a/mods/redstone/mcl_dispensers/init.lua +++ b/mods/redstone/mcl_dispensers/init.lua @@ -271,7 +271,7 @@ minetest.register_craft({ }) -- 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 local bow, id 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 end end - if bow:get_wear() ~= 0 then + if bow and bow:get_wear() ~= 0 then return "" end end return nil -end) +end -minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) - if itemstack:get_name() == "mcl_dispensers:dispenser" then - 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) +minetest.register_on_craft(check_craft) +minetest.register_craft_predict(check_craft)