Fix piglins taking whole stacks

This commit is contained in:
cora 2022-10-13 19:37:53 +02:00 committed by PrairieWind
parent 8cb73ee509
commit f7703c2889
1 changed files with 5 additions and 10 deletions

View File

@ -115,17 +115,11 @@ local piglin = {
end end
end, end,
on_pick_up = function(self, itementity) on_pick_up = function(self, itementity)
local clicker local item = itementity.itemstring:split(" ")[1]
for _,p in pairs(minetest.get_connected_players()) do local it = ItemStack(itementity.itemstring)
if vector.distance(p:get_pos(),self.object:get_pos()) < 10 then
clicker = p
end
end
--return true --do not pick up --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 if item == "mcl_core:gold_ingot" and self.state ~= "attack" and self.gold_items < 3 then
local item_gold = clicker:get_wielded_item() it:take_item(1)
item_gold:take_item(1)
clicker:set_wielded_item(item_gold)
self.state = "stand" self.state = "stand"
self.object:set_animation({x=0,y=79}) self.object:set_animation({x=0,y=79})
self.trading = true self.trading = true
@ -146,6 +140,7 @@ local piglin = {
end end
end) end)
end end
return it
end, end,
do_punch = function(self, hitter) do_punch = function(self, hitter)
if hitter:is_player() then if hitter:is_player() then