Using add_item with on_rightclick seems to have different behavior than if add_item is used with lets say on_punch. With on_rightclick the player will not receive the item if the slot the item is meant to go into (the first open slot) is the wielded/active slot. So if the first slot in the hotbar is empty and the player has the first slot as their active slot an item will not be added with add_item if used in on_rightclick. It will be added though if it is used with on_punch. Here are two examples:
This will properly if the wielded spot is where the item is meant to go:
Code: Select all
on_punch = function(pos, node, player, pointed_thing)
local inv = player:get_inventory()
local left = inv:add_item("main", "default:dirt")
end,
This will not work if the wielded spot is where the item is meant to go:
Code: Select all
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local inv = player:get_inventory()
local left = inv:add_item("main", "default:dirt")
end,
Surprisingly add_item in on_rightclick is still returning true as if it did add the item. Is this an annoying feature that is meant to be this way or a bug? It would seem like a bug to me because it is inconsistent.