Set _removed to true in item entities sucked by hoppers

This double-check might just prevent future commits from triggering regressions
allowing hoppers to duplicate items.
This commit is contained in:
wallabra 2022-02-17 21:30:15 -03:00
parent eee07f56b5
commit 0c6da14e1f
Signed by untrusted user: Gustavo6046
GPG Key ID: 5182FABAA5E139B3
1 changed files with 4 additions and 2 deletions

View File

@ -350,7 +350,8 @@ minetest.register_abm({
local inv = meta:get_inventory() local inv = meta:get_inventory()
for _,object in pairs(minetest.get_objects_inside_radius(pos, 2)) do for _,object in pairs(minetest.get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" and not object:get_luaentity()._removed then local entity = object:get_luaentity()
if not object:is_player() and entity and entity.name == "__builtin:item" and not entity._removed then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
-- Item must get sucked in when the item just TOUCHES the block above the hopper -- Item must get sucked in when the item just TOUCHES the block above the hopper
-- This is the reason for the Y calculation. -- This is the reason for the Y calculation.
@ -359,7 +360,8 @@ minetest.register_abm({
local posob_miny = posob.y + object:get_properties().collisionbox[2] local posob_miny = posob.y + object:get_properties().collisionbox[2]
if math.abs(posob.x-pos.x) <= 0.5 and (posob_miny-pos.y < 1.5 and posob.y-pos.y >= 0.3) then if math.abs(posob.x-pos.x) <= 0.5 and (posob_miny-pos.y < 1.5 and posob.y-pos.y >= 0.3) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
object:get_luaentity().itemstring = "" entity._removed = true
entity.itemstring = ""
object:remove() object:remove()
end end
end end