1
0
Fork 0

De-spaghettify piglin code a bit

This commit is contained in:
cora 2022-10-13 19:46:25 +02:00 committed by PrairieWind
parent 71ad3b91db
commit 4570226536
1 changed files with 16 additions and 14 deletions

View File

@ -21,6 +21,16 @@ local trading_items = {
local S = minetest.get_translator("mobs_mc") local S = minetest.get_translator("mobs_mc")
local mod_bows = minetest.get_modpath("mcl_bows") ~= nil 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 --################### piglin
--################### --###################
@ -84,8 +94,7 @@ local piglin = {
zog:set_rotation(self.object:get_rotation()) zog:set_rotation(self.object:get_rotation())
self.object:remove() self.object:remove()
return return
end elseif self.trading == true then
if self.trading == true then
self.state = "trading" 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("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)) self.object:set_bone_position("Head", vector.new(0,6.3,0), vector.new(-40,0,0))
@ -101,19 +110,12 @@ local piglin = {
if self.state ~= "attack" then if self.state ~= "attack" then
self._attacked_by_player = false self._attacked_by_player = false
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
if self.state == "attack" and self.attack:is_player() then end,
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
if self._attacked_by_player == false then
self.state = "stand"
end
end
end
end
end,
on_pick_up = function(self, itementity) on_pick_up = function(self, itementity)
local item = itementity.itemstring:split(" ")[1] local item = itementity.itemstring:split(" ")[1]
local it = ItemStack(itementity.itemstring) local it = ItemStack(itementity.itemstring)