Add bone meal support for dispenser

This commit is contained in:
Wuzzy 2017-02-14 18:20:54 +01:00
parent 06847c38d2
commit eb9c2efb82
2 changed files with 16 additions and 2 deletions

@ -14,6 +14,7 @@
-- }) -- })
-- Other mods can use these for looping through available colors -- Other mods can use these for looping through available colors
mcl_dye = {}
local dye = {} local dye = {}
dye.basecolors = {"white", "grey", "black", "red", "yellow", "green", "cyan", "blue", "magenta"} 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"} 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 -- Bone Meal
local apply_bone_meal = function(pointed_thing) mcl_dye.apply_bone_meal = function(pointed_thing)
local plant_tab = { local plant_tab = {
"air", "air",
"mcl_core:tallgrass", "mcl_core:tallgrass",
@ -210,7 +211,7 @@ minetest.register_craftitem("mcl_dye:white", {
stack_max = 64, stack_max = 64,
groups = {dye=1, craftitem=1, basecolor_white=1, excolor_white=1, unicolor_white=1}, groups = {dye=1, craftitem=1, basecolor_white=1, excolor_white=1, unicolor_white=1},
on_place = function(itemstack, user, pointed_thing) 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() itemstack:take_item()
end end
return itemstack return itemstack

@ -163,6 +163,19 @@ local dispenserdef = {
inv:set_stack("main", stack_id, stack) inv:set_stack("main", stack_id, stack)
end 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 elseif iname == "mcl_minecarts:minecart" then
-- Place minecart as entity on rail -- Place minecart as entity on rail
if dropnodedef.groups.rail then if dropnodedef.groups.rail then