Always return the leftover ItemStack for on_place and on_rightclick
authorTim <t4im@users.noreply.github.com>
Fri, 1 Jul 2016 20:43:02 +0000 (22:43 +0200)
committerparamat <mat.gregory@virginmedia.com>
Sat, 9 Jul 2016 15:32:41 +0000 (16:32 +0100)
mods/beds/api.lua
mods/boats/init.lua
mods/default/nodes.lua
mods/doors/init.lua
mods/farming/api.lua
mods/flowers/init.lua

index 53d4e488fe1d4cd76a4265af7bf4fa96940479c8..d640a311118782001f01ec78217ccf8257cf384b 100644 (file)
@@ -91,8 +91,9 @@ function beds.register_bed(name, def)
                        destruct_bed(pos, 1)
                end,
 
-               on_rightclick = function(pos, node, clicker)
+               on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
                        beds.on_rightclick(pos, clicker)
+                       return itemstack
                end,
 
                on_rotate = function(pos, node, user, mode, new_param2)
index 0097a57a46e0f8fdf7e961cc3e645e129ab3a7d4..db8258bce0b4018674664864e03d87cd8fa6c521 100644 (file)
@@ -224,10 +224,10 @@ minetest.register_craftitem("boats:boat", {
 
        on_place = function(itemstack, placer, pointed_thing)
                if pointed_thing.type ~= "node" then
-                       return
+                       return itemstack
                end
                if not is_water(pointed_thing.under) then
-                       return
+                       return itemstack
                end
                pointed_thing.under.y = pointed_thing.under.y + 0.5
                minetest.add_entity(pointed_thing.under, "boats:boat")
index bfc0898ed865d0c72539a459c616eebd56ea0d78..86d5565c51dfe614aab6198c36000b0067769334 100644 (file)
@@ -1612,7 +1612,7 @@ minetest.register_node("default:chest_locked", {
                        " takes " .. stack:get_name()  ..
                        " from locked chest at " .. minetest.pos_to_string(pos))
        end,
-       on_rightclick = function(pos, node, clicker)
+       on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
                local meta = minetest.get_meta(pos)
                if has_locked_chest_privilege(meta, clicker) then
                        minetest.show_formspec(
@@ -1621,6 +1621,7 @@ minetest.register_node("default:chest_locked", {
                                get_locked_chest_formspec(pos)
                        )
                end
+               return itemstack
        end,
        on_blast = function() end,
 })
index f21381fe637b469224cc43601e177bb65ec97c2d..1c20e0b446af3abc23c49e7cea3f4a89e118aa76 100644 (file)
@@ -373,8 +373,9 @@ function doors.register(name, def)
                sounds = { def.sound_close, def.sound_open },
        }
 
-       def.on_rightclick = function(pos, node, clicker)
+       def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
                _doors.door_toggle(pos, clicker)
+               return itemstack
        end
        def.after_dig_node = function(pos, node, meta, digger)
                minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
@@ -547,8 +548,9 @@ function doors.register_trapdoor(name, def)
                return meta:get_string("doors_owner") == pn
        end
 
-       def.on_rightclick = function(pos, node, clicker)
+       def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
                _doors.trapdoor_toggle(pos, clicker)
+               return itemstack
        end
 
        -- Common trapdoor configuration
@@ -681,12 +683,13 @@ function doors.register_fencegate(name, def)
                connect_sides = {"left", "right"},
                groups = def.groups,
                sounds = def.sounds,
-               on_rightclick = function(pos, clicker)
+               on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
                        local node = minetest.get_node(pos)
                        local node_def = minetest.registered_nodes[node.name]
                        minetest.swap_node(pos, {name = node_def.gate, param2 = node.param2})
                        minetest.sound_play(node_def.sound, {pos = pos, gain = 0.3,
                                max_hear_distance = 8})
+                       return itemstack
                end,
                selection_box = {
                        type = "fixed",
index 966910f6c2bfee5bb6d88f10fea396fa9e75a463..69c6769b00c4e798c7d294689fcd691508542c47 100644 (file)
@@ -133,10 +133,10 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
        local pt = pointed_thing
        -- check if pointing at a node
        if not pt then
-               return
+               return itemstack
        end
        if pt.type ~= "node" then
-               return
+               return itemstack
        end
 
        local under = minetest.get_node(pt.under)
@@ -153,25 +153,25 @@ farming.place_seed = function(itemstack, placer, pointed_thing, plantname)
 
        -- return if any of the nodes is not registered
        if not minetest.registered_nodes[under.name] then
-               return
+               return itemstack
        end
        if not minetest.registered_nodes[above.name] then
-               return
+               return itemstack
        end
 
        -- check if pointing at the top of the node
        if pt.above.y ~= pt.under.y+1 then
-               return
+               return itemstack
        end
 
        -- check if you can replace the node above the pointed node
        if not minetest.registered_nodes[above.name].buildable_to then
-               return
+               return itemstack
        end
 
        -- check if pointing at soil
        if minetest.get_item_group(under.name, "soil") < 2 then
-               return
+               return itemstack
        end
 
        -- add the node and remove 1 item from the itemstack
index 2de575fe28ab7e3d0ca234bb43c786a40cdb08fc..2ec661e1589f5ffb0d96a2a7cddada97ff5ae6d0 100644 (file)
@@ -251,8 +251,8 @@ minetest.register_node("flowers:waterlily", {
                        end
                        if not minetest.setting_getbool("creative_mode") then
                                itemstack:take_item()
-                               return itemstack
                        end
                end
+               return itemstack
        end
 })