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:
teknomunk 2024-04-19 10:31:45 +00:00
parent cf1325d466
commit 354160e9e6
2 changed files with 48 additions and 33 deletions

View file

@ -76,7 +76,9 @@ 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
@ -88,7 +90,7 @@ mcl_bone_meal.use_bone_meal = function(itemstack, placer, pointed_thing)
-- 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.
@ -106,6 +108,9 @@ mcl_bone_meal.use_bone_meal = function(itemstack, placer, pointed_thing)
itemstack:take_item() itemstack:take_item()
end end
if success then return itemstack end
end
return itemstack return itemstack
end end

View file

@ -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,