diff --git a/mods/ENTITIES/mobs_mc/piglin.lua b/mods/ENTITIES/mobs_mc/piglin.lua index b9bddb025..55abdd0f6 100644 --- a/mods/ENTITIES/mobs_mc/piglin.lua +++ b/mods/ENTITIES/mobs_mc/piglin.lua @@ -16,6 +16,13 @@ local trading_items = { { itemstring = "mcl_throwing:ender_pearl", amount_min = 2, amount_max = 6 }, { itemstring = "mcl_potions:fire_resistance", amount_min = 1, amount_max = 1 }, { itemstring = "mcl_potions:fire_resistance_splash", amount_min = 1, amount_max = 1 }, + { itemstring = "mcl_enchanting:book_enchanted", amount_min = 1, amount_max = 1 }, + { itemstring = "mcl_armor:boots_iron_enchanted", amount_min = 1, amount_max = 1 }, + { itemstring = "mcl_blackstone:blackstone", amount_min = 8, amount_max = 16 }, + { itemstring = "mcl_bows:arrow", amount_min = 6, amount_max = 12 }, + { itemstring = "mcl_core:crying_obsidian", amount_min = 1, amount_max = 1 }, + { itemstring = "mcl_fire:fire_charge", amount_min = 1, amount_max = 1 }, + --{ itemstring = "FIXME:spectral_arrow", amount_min = 6, amount_max = 12 }, } local S = minetest.get_translator("mobs_mc") @@ -142,14 +149,18 @@ local piglin = { local c_pos = self.object:get_pos() if c_pos then self.what_traded = trading_items[math.random(#trading_items)] - for x = 1, math.random(self.what_traded.amount_min, self.what_traded.amount_max) do - local p = c_pos - local nn=minetest.find_nodes_in_area_under_air(vector.offset(c_pos,-1,-1,-1),vector.offset(c_pos,1,1,1),{"group:solid"}) - if nn and #nn > 0 then - p = vector.offset(nn[math.random(#nn)],0,1,0) - end - minetest.add_item(p, self.what_traded.itemstring) + local stack = ItemStack(self.what_traded.itemstring) + stack:set_count(math.random(self.what_traded.amount_min, self.what_traded.amount_max)) + if mcl_enchanting.is_enchanted(self.what_traded.itemstring) then + local enchantment = "soul_speed" + mcl_enchanting.enchant(stack, enchantment, mcl_enchanting.random(nil, 1, mcl_enchanting.enchantments[enchantment].max_level)) end + local p = c_pos + local nn=minetest.find_nodes_in_area_under_air(vector.offset(c_pos,-1,-1,-1),vector.offset(c_pos,1,1,1),{"group:solid"}) + if nn and #nn > 0 then + p = vector.offset(nn[math.random(#nn)],0,1,0) + end + minetest.add_item(p, stack) end end) end