mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +01:00
Check both above and below in pointed_thing for bonemealing (and pass thru the position as .under), make crimson vines and twisting vines compostable by rightclicking on the composter
This commit is contained in:
parent
cf1325d466
commit
354160e9e6
@ -76,34 +76,39 @@ end
|
|||||||
-- End legacy bone meal API
|
-- End legacy bone meal API
|
||||||
|
|
||||||
mcl_bone_meal.use_bone_meal = function(itemstack, placer, pointed_thing)
|
mcl_bone_meal.use_bone_meal = function(itemstack, placer, pointed_thing)
|
||||||
local pos = pointed_thing.under
|
local positions = {pointed_thing.under, pointed_thing.above}
|
||||||
|
for i = 1,2 do
|
||||||
|
local pos = positions[i]
|
||||||
|
|
||||||
-- Check protection
|
-- Check protection
|
||||||
if mcl_util.check_area_protection(pos, pointed_thing.above, placer) then return false end
|
if mcl_util.check_area_protection(pos, pointed_thing.above, placer) then return false end
|
||||||
|
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local ndef = minetest.registered_nodes[node.name]
|
local ndef = minetest.registered_nodes[node.name]
|
||||||
local success = false
|
local success = false
|
||||||
local consume
|
local consume
|
||||||
|
|
||||||
-- If the pointed node can be bonemealed, let it handle the processing.
|
-- If the pointed node can be bonemealed, let it handle the processing.
|
||||||
if ndef and ndef._on_bone_meal then
|
if ndef and ndef._on_bone_meal then
|
||||||
success = ndef._on_bone_meal(itemstack, placer, pointed_thing)
|
success = ndef._on_bone_meal(itemstack, placer, {under = pos, above = vector.offset(pos, 0, 1, 0)})
|
||||||
consume = true
|
consume = true
|
||||||
else
|
else
|
||||||
-- Otherwise try the legacy API.
|
-- Otherwise try the legacy API.
|
||||||
success = legacy_apply_bone_meal(pointed_thing, placer)
|
success = legacy_apply_bone_meal(pointed_thing, placer)
|
||||||
consume = success
|
consume = success
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Particle effects
|
-- Particle effects
|
||||||
if success then
|
if success then
|
||||||
mcl_bone_meal.add_bone_meal_particle(pos)
|
mcl_bone_meal.add_bone_meal_particle(pos)
|
||||||
end
|
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 and ( not placer or not minetest.is_creative_enabled(placer:get_player_name()) ) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
|
end
|
||||||
|
|
||||||
|
if success then return itemstack end
|
||||||
end
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -161,17 +161,22 @@ minetest.register_node("mcl_crimson:twisting_vines", {
|
|||||||
end,
|
end,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
local above = pointed_thing.above
|
|
||||||
local unode = minetest.get_node(under)
|
local unode = minetest.get_node(under)
|
||||||
|
local unode_def = minetest.registered_nodes[unode.name]
|
||||||
|
|
||||||
|
local above = pointed_thing.above
|
||||||
|
local anode = minetest.get_node(above)
|
||||||
|
local anode_def = minetest.registered_nodes[anode.name]
|
||||||
|
|
||||||
if under.y < above.y then
|
if under.y < above.y then
|
||||||
minetest.set_node(above, {name = "mcl_crimson:twisting_vines"})
|
minetest.set_node(above, {name = "mcl_crimson:twisting_vines"})
|
||||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
else
|
elseif unode_def and unode_def.on_rightclick then
|
||||||
if unode.name == "mcl_crimson:twisting_vines" then
|
return unode_def.on_rightclick(under, unode, placer, itemstack, pointed_thing)
|
||||||
return minetest.registered_nodes[unode.name].on_rightclick(under, unode, placer, itemstack, pointed_thing)
|
elseif anode_def and anode_def.on_rightclick then
|
||||||
end
|
return unode_def.on_rightclick(above, anode, placer, itemstack, pointed_thing)
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
@ -251,17 +256,22 @@ minetest.register_node("mcl_crimson:weeping_vines", {
|
|||||||
end,
|
end,
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
local above = pointed_thing.above
|
|
||||||
local unode = minetest.get_node(under)
|
local unode = minetest.get_node(under)
|
||||||
|
local unode_def = minetest.registered_nodes[unode.name]
|
||||||
|
|
||||||
|
local above = pointed_thing.above
|
||||||
|
local anode = minetest.get_node(above)
|
||||||
|
local anode_def = minetest.registered_nodes[anode.name]
|
||||||
|
|
||||||
if under.y > above.y then
|
if under.y > above.y then
|
||||||
minetest.set_node(above, {name = "mcl_crimson:weeping_vines"})
|
minetest.set_node(above, {name = "mcl_crimson:weeping_vines"})
|
||||||
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
if not minetest.is_creative_enabled(placer:get_player_name()) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
else
|
elseif unode_def and unode_def.on_rightclick then
|
||||||
if unode.name == "mcl_crimson:weeping_vines" then
|
return unode_def.on_rightclick(under, unode, placer, itemstack, pointed_thing)
|
||||||
return minetest.registered_nodes[unode.name].on_rightclick(under, unode, placer, itemstack, pointed_thing)
|
elseif anode_def and anode_def.on_rightclick then
|
||||||
end
|
return unode_def.on_rightclick(above, anode, placer, itemstack, pointed_thing)
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user