mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +01:00
Address review comments
This commit is contained in:
parent
6b1aa43238
commit
94d9e4c881
@ -13,7 +13,7 @@ local usagehelp = S(
|
|||||||
|
|
||||||
mcl_bone_meal = {}
|
mcl_bone_meal = {}
|
||||||
|
|
||||||
-- Bone meal particle api:
|
-- Bone meal particle API:
|
||||||
|
|
||||||
--- Spawns bone meal particles.
|
--- Spawns bone meal particles.
|
||||||
-- pos: where the particles spawn
|
-- pos: where the particles spawn
|
||||||
@ -21,9 +21,7 @@ mcl_bone_meal = {}
|
|||||||
-- details on these parameters.
|
-- details on these parameters.
|
||||||
--
|
--
|
||||||
function mcl_bone_meal.add_bone_meal_particle(pos, def)
|
function mcl_bone_meal.add_bone_meal_particle(pos, def)
|
||||||
if not def then
|
def = def or {}
|
||||||
def = {}
|
|
||||||
end
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = def.amount or 10,
|
amount = def.amount or 10,
|
||||||
time = def.time or 0.1,
|
time = def.time or 0.1,
|
||||||
@ -65,8 +63,9 @@ end
|
|||||||
--
|
--
|
||||||
local function legacy_apply_bone_meal(pointed_thing, placer)
|
local function legacy_apply_bone_meal(pointed_thing, placer)
|
||||||
-- Legacy API support
|
-- Legacy API support
|
||||||
for _, func in pairs(mcl_bone_meal.bone_meal_callbacks) do
|
local callbacks = mcl_bone_meal.bone_meal_callbacks
|
||||||
if func(pointed_thing, placer) then
|
for i = 1,#callbacks do
|
||||||
|
if callbacks[i](pointed_thing, placer) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -75,7 +74,7 @@ local function legacy_apply_bone_meal(pointed_thing, placer)
|
|||||||
end
|
end
|
||||||
-- End legacy bone meal API
|
-- 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}
|
local positions = {pointed_thing.under, pointed_thing.above}
|
||||||
for i = 1,2 do
|
for i = 1,2 do
|
||||||
local pos = positions[i]
|
local pos = positions[i]
|
||||||
@ -98,18 +97,19 @@ mcl_bone_meal.use_bone_meal = function(itemstack, placer, pointed_thing)
|
|||||||
consume = success
|
consume = success
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Particle effects
|
|
||||||
if consume then
|
|
||||||
mcl_bone_meal.add_bone_meal_particle(pos)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Take the item
|
-- Take the item
|
||||||
if consume and ( not placer or not minetest.is_creative_enabled(placer:get_player_name()) ) then
|
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()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
if success then return itemstack end
|
if success then return itemstack end
|
||||||
if consume then return itemstack end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
@ -130,7 +130,8 @@ minetest.register_craftitem("mcl_bone_meal:bone_meal", {
|
|||||||
-- Use pointed node's on_rightclick function first, if present.
|
-- Use pointed node's on_rightclick function first, if present.
|
||||||
if placer and not placer:get_player_control().sneak then
|
if placer and not placer:get_player_control().sneak then
|
||||||
if ndef and ndef.on_rightclick 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -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?
|
-- Am I right-clicking on something that has a custom on_rightclick set?
|
||||||
if placer and not placer:get_player_control().sneak then
|
if placer and not placer:get_player_control().sneak then
|
||||||
if def and def.on_rightclick 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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name = mcl_cocoas
|
name = mcl_cocoas
|
||||||
description = Cocoa pods which grow at jungle trees. Does not include cocoa beans.
|
description = Cocoa pods which grow at jungle trees. Does not include cocoa beans.
|
||||||
depends = mcl_sounds, mcl_core
|
depends = mcl_sounds, mcl_core, mcl_util
|
||||||
optional_depends = doc
|
optional_depends = doc
|
Loading…
Reference in New Issue
Block a user