From f7703c28896b4e6db3c91847b48b0bf4be066d37 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 13 Oct 2022 19:37:53 +0200 Subject: [PATCH] Fix piglins taking whole stacks --- mods/ENTITIES/mobs_mc/piglin.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/piglin.lua b/mods/ENTITIES/mobs_mc/piglin.lua index 596cf5543..20a80f9a1 100644 --- a/mods/ENTITIES/mobs_mc/piglin.lua +++ b/mods/ENTITIES/mobs_mc/piglin.lua @@ -115,17 +115,11 @@ local piglin = { end end, on_pick_up = function(self, itementity) - local clicker - for _,p in pairs(minetest.get_connected_players()) do - if vector.distance(p:get_pos(),self.object:get_pos()) < 10 then - clicker = p - end - end + local item = itementity.itemstring:split(" ")[1] + local it = ItemStack(itementity.itemstring) --return true --do not pick up - if clicker:is_player() and clicker:get_wielded_item():get_name() == "mcl_core:gold_ingot" and self.state ~= "attack" and self.gold_items < 3 then - local item_gold = clicker:get_wielded_item() - item_gold:take_item(1) - clicker:set_wielded_item(item_gold) + if item == "mcl_core:gold_ingot" and self.state ~= "attack" and self.gold_items < 3 then + it:take_item(1) self.state = "stand" self.object:set_animation({x=0,y=79}) self.trading = true @@ -146,6 +140,7 @@ local piglin = { end end) end + return it end, do_punch = function(self, hitter) if hitter:is_player() then