Prevent minecarts from being placed above air nodes ()

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4888
Reviewed-by: kno10 <kno10@noreply.git.minetest.land>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
This commit is contained in:
teknomunk 2025-01-25 20:15:49 +01:00 committed by the-real-herowl
parent 22ff4d3694
commit 73b675448e

View file

@ -468,12 +468,13 @@ local function register_minecart_craftitem(itemstring, def)
end
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node(pointed_thing.under)
if placer and not placer:get_player_control().sneak then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
local called
itemstack, called = mcl_util.handle_node_rightclick(itemstack, placer, pointed_thing)
if called then return itemstack end
-- Don't place minecarts over air
local below = core.get_node(vector.offset(pointed_thing.above,0,-1,0))
if below.name == "air" then return itemstack end
return mod.place_minecart(itemstack, pointed_thing, placer)
end,