trade on item pickup instead of on_rightclick

This commit is contained in:
cora 2022-10-06 01:26:49 +02:00 committed by PrairieWind
parent 5b3480860a
commit f8777220a3

View File

@ -38,6 +38,8 @@ local piglin = {
collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3}, collisionbox = {-0.3, -0.01, -0.3, 0.3, 1.94, 0.3},
visual = "mesh", visual = "mesh",
mesh = "extra_mobs_piglin.b3d", mesh = "extra_mobs_piglin.b3d",
spawn_in_group = 5,
spawn_in_group_min = 3,
textures = { { textures = { {
"extra_mobs_piglin.png", "extra_mobs_piglin.png",
"mcl_bows_bow_2.png", "mcl_bows_bow_2.png",
@ -71,6 +73,7 @@ local piglin = {
}, },
fear_height = 4, fear_height = 4,
view_range = 16, view_range = 16,
pick_up = {"mcl_core:gold_ingot"},
on_spawn = function(self) on_spawn = function(self)
self.weapon = self.base_texture[2] self.weapon = self.base_texture[2]
self.gold_items = 0 self.gold_items = 0
@ -110,7 +113,14 @@ local piglin = {
end end
end end
end, end,
on_rightclick = function(self, clicker) 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
--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 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() local item_gold = clicker:get_wielded_item()
item_gold:take_item(1) item_gold:take_item(1)