Clear itemstring when picking up or merging items (#4530)

Prevents possible item duplication with other mods. Matches the behavior of the default `__builtin:item`.

See also https://github.com/mt-mods/pipeworks/issues/130

Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4530
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: OgelGames <ogelgames@noreply.git.minetest.land>
Co-committed-by: OgelGames <ogelgames@noreply.git.minetest.land>
This commit is contained in:
OgelGames 2024-07-31 03:26:28 +02:00 committed by the-real-herowl
parent b8d7139792
commit 0012bdb71e

View file

@ -136,6 +136,7 @@ local function try_object_pickup(player, inv, object, checkpos)
-- Destroy entity
-- This just prevents this section to be run again because object:remove() doesn't remove the item immediately.
le.target = checkpos
le.itemstring = ""
le._removed = true
-- Stop the object
@ -957,6 +958,7 @@ minetest.register_entity(":__builtin:item", {
self.random_velocity = 0
self:set_item(own_stack:to_string())
entity.itemstring = ""
entity._removed = true
object:remove()
return true