From eb9c2efb82f26b527b1bbc4b8feafc3e5f9b5042 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 14 Feb 2017 18:20:54 +0100 Subject: [PATCH] Add bone meal support for dispenser --- mods/mcl_dye/init.lua | 5 +++-- mods/redstone/mcl_dispensers/init.lua | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mods/mcl_dye/init.lua b/mods/mcl_dye/init.lua index 313933fc0..fd15df96b 100644 --- a/mods/mcl_dye/init.lua +++ b/mods/mcl_dye/init.lua @@ -14,6 +14,7 @@ -- }) -- Other mods can use these for looping through available colors +mcl_dye = {} local dye = {} dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} dye.excolors = {"white", "lightgrey", "grey", "darkgrey", "black", "red", "orange", "yellow", "lime", "green", "aqua", "cyan", "sky_blue", "blue", "violet", "magenta", "red_violet"} @@ -98,7 +99,7 @@ end -- Bone Meal -local apply_bone_meal = function(pointed_thing) +mcl_dye.apply_bone_meal = function(pointed_thing) local plant_tab = { "air", "mcl_core:tallgrass", @@ -210,7 +211,7 @@ minetest.register_craftitem("mcl_dye:white", { stack_max = 64, groups = {dye=1, craftitem=1, basecolor_white=1, excolor_white=1, unicolor_white=1}, on_place = function(itemstack, user, pointed_thing) - if(apply_bone_meal(pointed_thing) and not minetest.setting_getbool("creative_mode")) then + if(mcl_dye.apply_bone_meal(pointed_thing) and not minetest.setting_getbool("creative_mode")) then itemstack:take_item() end return itemstack diff --git a/mods/redstone/mcl_dispensers/init.lua b/mods/redstone/mcl_dispensers/init.lua index 75174edea..91f3ecbcc 100644 --- a/mods/redstone/mcl_dispensers/init.lua +++ b/mods/redstone/mcl_dispensers/init.lua @@ -163,6 +163,19 @@ local dispenserdef = { inv:set_stack("main", stack_id, stack) end + elseif iname == "mcl_dye:white" then + -- Apply bone meal, if possible + if dropnode.name == "air" then + pointed_thing = { above = droppos, under = { x=droppos.x, y=droppos.y-1, z=droppos.z } } + else + pointed_thing = { above = pos, under = droppos } + end + local success = mcl_dye.apply_bone_meal(pointed_thing) + if success then + stack:take_item() + inv:set_stack("main", stack_id, stack) + end + elseif iname == "mcl_minecarts:minecart" then -- Place minecart as entity on rail if dropnodedef.groups.rail then