mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 13:53:45 +01:00
De-spaghettify piglin code a bit
This commit is contained in:
parent
71ad3b91db
commit
4570226536
@ -21,6 +21,16 @@ local trading_items = {
|
||||
local S = minetest.get_translator("mobs_mc")
|
||||
local mod_bows = minetest.get_modpath("mcl_bows") ~= nil
|
||||
|
||||
function mobs_mc.player_wears_gold(player)
|
||||
for i=1, 6 do
|
||||
local stack = player:get_inventory():get_stack("armor", i)
|
||||
local item = stack:get_name()
|
||||
if item == "mcl_armor:chestplate_gold" or item == "mcl_armor:leggings_gold" or item == "mcl_armor:helmet_gold" or item == "mcl_armor:boots_gold" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--###################
|
||||
--################### piglin
|
||||
--###################
|
||||
@ -84,8 +94,7 @@ local piglin = {
|
||||
zog:set_rotation(self.object:get_rotation())
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
if self.trading == true then
|
||||
elseif self.trading == true then
|
||||
self.state = "trading"
|
||||
self.object:set_bone_position("Arm_Right_Pitch_Control", vector.new(-3,5.785,0), vector.new(20,-20,18))
|
||||
self.object:set_bone_position("Head", vector.new(0,6.3,0), vector.new(-40,0,0))
|
||||
@ -101,18 +110,11 @@ local piglin = {
|
||||
|
||||
if self.state ~= "attack" then
|
||||
self._attacked_by_player = false
|
||||
end
|
||||
if self.state == "attack" and self.attack:is_player() then
|
||||
for i=1, 6 do
|
||||
local stack = self.attack:get_inventory():get_stack("armor", i)
|
||||
local item = stack:get_name()
|
||||
if item == "mcl_armor:chestplate_gold" or item == "mcl_armor:leggings_gold" or item == "mcl_armor:helmet_gold" or item == "mcl_armor:boots_gold" then
|
||||
elseif self.attack:is_player() and mobs_mc.player_wears_gold(self.attack) then
|
||||
if self._attacked_by_player == false then
|
||||
self.state = "stand"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_pick_up = function(self, itementity)
|
||||
local item = itementity.itemstring:split(" ")[1]
|
||||
|
Loading…
Reference in New Issue
Block a user