Merge pull request 'Fix hopper cart crash' (#3821) from fix_cart_hopper_crash into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3821
ancientmarinerdev 2023-06-28 20:35:37 +00:00
commit 823f7ee5c7

@ -85,24 +85,14 @@ local function hopper_take_item(self, dtime)
for k, v in pairs(objs) do for k, v in pairs(objs) do
local ent = v:get_luaentity() local ent = v:get_luaentity()
if ent._removed or not ent.itemstring or ent.itemstring == "" then if ent and not ent._removed and ent.itemstring and ent.itemstring ~= "" then
--minetest.log("Ignore this item")
break
end
-- Don't forget actual hoppers
local taken_items = false local taken_items = false
mcl_log("ent.name: " .. tostring(ent.name)) mcl_log("ent.name: " .. tostring(ent.name))
mcl_log("ent pos: " .. tostring(ent.object:get_pos())) mcl_log("ent pos: " .. tostring(ent.object:get_pos()))
local inv = mcl_entity_invs.load_inv(self, 5) local inv = mcl_entity_invs.load_inv(self, 5)
if not inv then return false end
if not inv then
mcl_log("No inv")
return false
end
local current_itemstack = ItemStack(ent.itemstring) local current_itemstack = ItemStack(ent.itemstring)
@ -181,6 +171,8 @@ local function hopper_take_item(self, dtime)
else else
mcl_log("No need to save") mcl_log("No need to save")
end end
end
end end
end end