Fix llama and donkey/mule drops

This commit is contained in:
cora 2022-10-04 11:36:43 +02:00
parent 8d8d49c87d
commit d202db00b7
2 changed files with 51 additions and 12 deletions

View File

@ -34,6 +34,30 @@ local horse_extra_texture = function(horse)
return textures return textures
end end
local function get_drops(self)
self.drops = {}
table.insert(self.drops,
{name = "mcl_mobitems:leather",
chance = 1,
min = 0,
max = 2,
looting = "common",
})
if self._saddle then
table.insert(self.drops,{name = "mcl_mobitems:saddle",
chance = 1,
min = 1,
max = 1,})
end
if self._chest then
table.insert(self.drops,{name = "mcl_chests:chest",
chance = 1,
min = 1,
max = 1,})
end
end
-- Helper functions to determine equipment rules -- Helper functions to determine equipment rules
local can_equip_horse_armor = function(entity_id) local can_equip_horse_armor = function(entity_id)
return entity_id == "mobs_mc:horse" or entity_id == "mobs_mc:skeleton_horse" or entity_id == "mobs_mc:zombie_horse" return entity_id == "mobs_mc:horse" or entity_id == "mobs_mc:skeleton_horse" or entity_id == "mobs_mc:zombie_horse"
@ -250,7 +274,7 @@ local horse = {
local tex = horse_extra_texture(self) local tex = horse_extra_texture(self)
self.base_texture = tex self.base_texture = tex
self.object:set_properties({textures = self.base_texture}) self.object:set_properties({textures = self.base_texture})
table.insert(self.drops,{name = "mcl_chests:chest",chance=1,min=1,max=1}) get_drops(self)
return return
elseif self._chest and clicker:get_player_control().sneak then elseif self._chest and clicker:get_player_control().sneak then
mcl_entity_invs.show_inv_form(self,clicker) mcl_entity_invs.show_inv_form(self,clicker)
@ -361,6 +385,7 @@ local horse = {
self.base_texture = tex self.base_texture = tex
self.object:set_properties({textures = self.base_texture}) self.object:set_properties({textures = self.base_texture})
minetest.sound_play({name = "mcl_armor_equip_leather"}, {gain=0.5, max_hear_distance=12, pos=self.object:get_pos()}, true) minetest.sound_play({name = "mcl_armor_equip_leather"}, {gain=0.5, max_hear_distance=12, pos=self.object:get_pos()}, true)
get_drops(self)
-- Put on horse armor if tamed -- Put on horse armor if tamed
elseif can_equip_horse_armor(self.name) and not self.driver and not self._horse_armor elseif can_equip_horse_armor(self.name) and not self.driver and not self._horse_armor

View File

@ -24,6 +24,29 @@ local carpets = {
unicolor_light_blue = { "mcl_wool:light_blue_carpet", "light_blue" }, unicolor_light_blue = { "mcl_wool:light_blue_carpet", "light_blue" },
} }
local function get_drops(self)
self.drops = {}
table.insert(self.drops,
{name = "mcl_mobitems:leather",
chance = 1,
min = 0,
max = 2,
looting = "common",
})
if self.carpet then
table.insert(self.drops,{name = self.carpet,
chance = 1,
min = 1,
max = 1,})
end
if self._has_chest then
table.insert(self.drops,{name = "mcl_chests:chest",
chance = 1,
min = 1,
max = 1,})
end
end
mcl_mobs:register_mob("mobs_mc:llama", { mcl_mobs:register_mob("mobs_mc:llama", {
description = S("Llama"), description = S("Llama"),
type = "animal", type = "animal",
@ -135,7 +158,7 @@ mcl_mobs:register_mob("mobs_mc:llama", {
self.object:set_properties({ self.object:set_properties({
textures = self.base_texture, textures = self.base_texture,
}) })
table.insert(self.drops,{name = "mcl_chests:chest",chance=1,min=1,max=1}) get_drops(self)
return return
elseif self._has_chest and clicker:get_player_control().sneak then elseif self._has_chest and clicker:get_player_control().sneak then
mcl_entity_invs.show_inv_form(self,clicker," - Strength "..math.floor(self._inv_size / 3)) mcl_entity_invs.show_inv_form(self,clicker," - Strength "..math.floor(self._inv_size / 3))
@ -164,16 +187,7 @@ mcl_mobs:register_mob("mobs_mc:llama", {
textures = self.base_texture, textures = self.base_texture,
}) })
self.carpet = item:get_name() self.carpet = item:get_name()
self.drops = { get_drops(self)
{name = "mcl_mobitems:leather",
chance = 1,
min = 0,
max = 2,},
{name = item:get_name(),
chance = 1,
min = 1,
max = 1,},
}
return return
end end
end end