Don't allow placement of vines on ceiling

This commit is contained in:
Wuzzy 2017-03-11 17:04:38 +01:00
parent 7d74916ee4
commit 2635880096

@ -1334,6 +1334,50 @@ minetest.register_node("mcl_core:vine", {
minetest.add_item(pos, oldnode.name)
end
end,
node_placement_prediction = "",
-- Restrict placement of vines
on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type ~= "node" then
-- no interaction possible with entities
return itemstack
end
local under = pointed_thing.under
local node = minetest.get_node(under)
local def = minetest.registered_nodes[node.name]
local groups = def.groups
-- Check special rightclick action of pointed node
if def and def.on_rightclick then
if not placer:get_player_control().sneak then
return def.on_rightclick(under, node, placer, itemstack,
pointed_thing) or itemstack, false
end
end
-- Only allow placement on solid nodes
if (not groups) or (not groups.solid) then
return itemstack
end
local above = pointed_thing.above
-- Vines may not be placed on the ceiling
if under.y > above.y then
return itemstack
end
local idef = itemstack:get_definition()
local success = minetest.item_place_node(itemstack, placer, pointed_thing)
if success then
if idef.sounds and idef.sounds.place then
minetest.sound_play(idef.sounds.place, {pos=above, gain=1})
end
end
return itemstack
end,
_mcl_blast_resistance = 1,
_mcl_hardness = 0.2,
})