Stop villagers from eating shulker boxes (#4266)

This modifies the logic for mobs picking up items to only match against the item's name and ignore any text in an items metadata.

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/4266
Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-authored-by: teknomunk <teknomunk@protonmail.com>
Co-committed-by: teknomunk <teknomunk@protonmail.com>
This commit is contained in:
teknomunk 2024-05-01 15:44:14 +00:00 committed by the-real-herowl
parent 22c4daab22
commit 0c372f987d
1 changed files with 2 additions and 1 deletions

View File

@ -87,7 +87,8 @@ function mob_class:check_item_pickup()
end
if self.pick_up then
for k,v in pairs(self.pick_up) do
if not player_near(p) and self.on_pick_up and l.itemstring:find(v) then
local itemstack = ItemStack(l.itemstring)
if not player_near(p) and self.on_pick_up and itemstack:get_name():find(v) then
local r = self.on_pick_up(self,l)
if r and r.is_empty and not r:is_empty() then
l.itemstring = r:to_string()