diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index a9d815f58..2d2b8a609 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -1142,7 +1142,7 @@ end --- the distance from the start where that node was found, --- the node table if a node was found function mcl_util.trace_nodes(pos, dir, allowed_nodes, limit) - if ( dir ~= -1 ) and ( dir ~= 1 ) then return nil, 0, nil end + if (dir ~= -1) and (dir ~= 1) then return nil, 0, nil end limit = limit or 16 for i = 1,limit do diff --git a/mods/ITEMS/mcl_bone_meal/init.lua b/mods/ITEMS/mcl_bone_meal/init.lua index dd13f6e58..e899ca765 100644 --- a/mods/ITEMS/mcl_bone_meal/init.lua +++ b/mods/ITEMS/mcl_bone_meal/init.lua @@ -13,7 +13,7 @@ local usagehelp = S( mcl_bone_meal = {} --- Bone meal particle api: +-- Bone meal particle API: --- Spawns bone meal particles. -- pos: where the particles spawn @@ -21,9 +21,7 @@ mcl_bone_meal = {} -- details on these parameters. -- function mcl_bone_meal.add_bone_meal_particle(pos, def) - if not def then - def = {} - end + def = def or {} minetest.add_particlespawner({ amount = def.amount or 10, time = def.time or 0.1, @@ -65,8 +63,9 @@ end -- local function legacy_apply_bone_meal(pointed_thing, placer) -- Legacy API support - for _, func in pairs(mcl_bone_meal.bone_meal_callbacks) do - if func(pointed_thing, placer) then + local callbacks = mcl_bone_meal.bone_meal_callbacks + for i = 1,#callbacks do + if callbacks[i](pointed_thing, placer) then return true end end @@ -75,7 +74,7 @@ local function legacy_apply_bone_meal(pointed_thing, placer) end -- End legacy bone meal API -mcl_bone_meal.use_bone_meal = function(itemstack, placer, pointed_thing) +function mcl_bone_meal.use_bone_meal(itemstack, placer, pointed_thing) local positions = {pointed_thing.under, pointed_thing.above} for i = 1,2 do local pos = positions[i] @@ -98,18 +97,19 @@ mcl_bone_meal.use_bone_meal = function(itemstack, placer, pointed_thing) consume = success end - -- Particle effects - if consume then - mcl_bone_meal.add_bone_meal_particle(pos) - end - -- Take the item - if consume and ( not placer or not minetest.is_creative_enabled(placer:get_player_name()) ) then - itemstack:take_item() + if consume then + -- Particle effects + mcl_bone_meal.add_bone_meal_particle(pos) + + if not placer or not minetest.is_creative_enabled(placer:get_player_name()) then + itemstack:take_item() + end + + return itemstack end if success then return itemstack end - if consume then return itemstack end end return itemstack @@ -130,7 +130,8 @@ minetest.register_craftitem("mcl_bone_meal:bone_meal", { -- Use pointed node's on_rightclick function first, if present. if placer and not placer:get_player_control().sneak then if ndef and ndef.on_rightclick then - return ndef.on_rightclick(pos, node, placer, itemstack, pointed_thing) or itemstack + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing) + if new_stack and new_stack ~= itemstack then return new_stack end end end diff --git a/mods/ITEMS/mcl_cocoas/init.lua b/mods/ITEMS/mcl_cocoas/init.lua index 970090a1c..2d1a0efd6 100644 --- a/mods/ITEMS/mcl_cocoas/init.lua +++ b/mods/ITEMS/mcl_cocoas/init.lua @@ -23,7 +23,8 @@ function mcl_cocoas.place(itemstack, placer, pt, plantname) -- Am I right-clicking on something that has a custom on_rightclick set? if placer and not placer:get_player_control().sneak then if def and def.on_rightclick then - return def.on_rightclick(pt.under, node, placer, itemstack) or itemstack + local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pt) + if new_stack and new_stack ~= itemstack then return new_stack end end end diff --git a/mods/ITEMS/mcl_cocoas/mod.conf b/mods/ITEMS/mcl_cocoas/mod.conf index 867636191..fb084f39a 100644 --- a/mods/ITEMS/mcl_cocoas/mod.conf +++ b/mods/ITEMS/mcl_cocoas/mod.conf @@ -1,4 +1,4 @@ name = mcl_cocoas description = Cocoa pods which grow at jungle trees. Does not include cocoa beans. -depends = mcl_sounds, mcl_core -optional_depends = doc \ No newline at end of file +depends = mcl_sounds, mcl_core, mcl_util +optional_depends = doc