diff options
author | Novatux <nathanael.courant@laposte.net> | 2014-01-11 17:23:28 +0100 |
---|---|---|
committer | Novatux <nathanael.courant@laposte.net> | 2014-01-11 17:23:28 +0100 |
commit | e21b29f4227581162490cc70aaf4009118544f97 (patch) | |
tree | 6bec44b3801c6800f8cb8b55e2086a681dbc26cc /builtin | |
parent | 3bbd280336dffc73ef43b2ac93937f320cb32872 (diff) | |
download | minetest-e21b29f4227581162490cc70aaf4009118544f97.tar.gz minetest-e21b29f4227581162490cc70aaf4009118544f97.tar.bz2 minetest-e21b29f4227581162490cc70aaf4009118544f97.zip |
Deepcopy pointed_thing for after_place_node, give it to on_rightclick too.
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/item.lua | 15 | ||||
-rw-r--r-- | builtin/misc_helpers.lua | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/builtin/item.lua b/builtin/item.lua index 35ad9e6e4..8c0c0ed31 100644 --- a/builtin/item.lua +++ b/builtin/item.lua @@ -270,12 +270,18 @@ function minetest.item_place_node(itemstack, placer, pointed_thing, param2) -- Run callback if def.after_place_node then - -- Copy place_to because callback can modify it + -- Deepcopy place_to and pointed_thing because callback can modify it local place_to_copy = {x=place_to.x, y=place_to.y, z=place_to.z} local pointed_thing_copy = { type = pointed_thing.type, - under = pointed_thing.under, - above = pointed_thing.above + under = { + x = pointed_thing.under.x, + y = pointed_thing.under.y, + z = pointed_thing.under.z}, + above = { + x = pointed_thing.above.x, + y = pointed_thing.above.y, + z = pointed_thing.above.z} } if def.after_place_node(place_to_copy, placer, itemstack, pointed_thing_copy) then @@ -317,7 +323,8 @@ function minetest.item_place(itemstack, placer, pointed_thing, param2) local n = minetest.get_node(pointed_thing.under) local nn = n.name if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, placer, itemstack) or itemstack, false + return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, n, + placer, itemstack, pointed_thing) or itemstack, false end end diff --git a/builtin/misc_helpers.lua b/builtin/misc_helpers.lua index 8b2d493b7..097c65865 100644 --- a/builtin/misc_helpers.lua +++ b/builtin/misc_helpers.lua @@ -278,7 +278,7 @@ if minetest then local undef = minetest.registered_nodes[unode.name] if undef and undef.on_rightclick then undef.on_rightclick(pointed_thing.under, node, placer, - itemstack) + itemstack, pointed_thing) return end local pitch = placer:get_look_pitch() |