From 31186731166917515d0a30d2e87fcd043366f751 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 18 Feb 2020 23:49:35 +0100 Subject: [PATCH] Play sound for equipping horse armor or saddle --- mods/ENTITIES/mobs_mc/1_items_default.lua | 9 +++++++++ mods/ENTITIES/mobs_mc/horse.lua | 6 +++++- mods/ENTITIES/mobs_mc/pig.lua | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/1_items_default.lua b/mods/ENTITIES/mobs_mc/1_items_default.lua index f0e1301e..687c0ac1 100644 --- a/mods/ENTITIES/mobs_mc/1_items_default.lua +++ b/mods/ENTITIES/mobs_mc/1_items_default.lua @@ -283,6 +283,9 @@ if c("iron_horse_armor") then _doc_items_usagehelp = horse_armor_use, inventory_image = "mobs_mc_iron_horse_armor.png", _horse_overlay_image = "mobs_mc_horse_armor_iron.png", + sounds = { + _mcl_armor_equip = "mcl_armor_equip_iron", + }, stack_max = 1, groups = { horse_armor = 85 }, }) @@ -294,6 +297,9 @@ if c("gold_horse_armor") then _doc_items_usagehelp = horse_armor_use, inventory_image = "mobs_mc_gold_horse_armor.png", _horse_overlay_image = "mobs_mc_horse_armor_gold.png", + sounds = { + _mcl_armor_equip = "mcl_armor_equip_iron", + }, stack_max = 1, groups = { horse_armor = 60 }, }) @@ -305,6 +311,9 @@ if c("diamond_horse_armor") then _doc_items_usagehelp = horse_armor_use, inventory_image = "mobs_mc_diamond_horse_armor.png", _horse_overlay_image = "mobs_mc_horse_armor_diamond.png", + sounds = { + _mcl_armor_equip = "mcl_armor_equip_diamond", + }, stack_max = 1, groups = { horse_armor = 45 }, }) diff --git a/mods/ENTITIES/mobs_mc/horse.lua b/mods/ENTITIES/mobs_mc/horse.lua index bf95fa84..c16f6208 100644 --- a/mods/ENTITIES/mobs_mc/horse.lua +++ b/mods/ENTITIES/mobs_mc/horse.lua @@ -223,6 +223,7 @@ local horse = { local tex = horse_extra_texture(self) self.base_texture = tex 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()}) -- Put on horse armor if tamed elseif can_equip_horse_armor(self.name) and not self.driver and not self._horse_armor @@ -252,7 +253,10 @@ local horse = { local tex = horse_extra_texture(self) self.base_texture = tex self.object:set_properties({textures = self.base_texture}) - + local def = w:get_definition() + if def.sounds and def.sounds._mcl_armor_equip then + minetest.sound_play({name = def.sounds._mcl_armor_equip}, {gain=0.5, max_hear_distance=12, pos=self.object:get_pos()}) + end -- Mount horse elseif not self.driver and self._saddle then diff --git a/mods/ENTITIES/mobs_mc/pig.lua b/mods/ENTITIES/mobs_mc/pig.lua index 768a3052..1d9c56b1 100644 --- a/mods/ENTITIES/mobs_mc/pig.lua +++ b/mods/ENTITIES/mobs_mc/pig.lua @@ -125,6 +125,7 @@ mobs:register_mob("mobs_mc:pig", { stack:take_item() inv:set_stack("main", clicker:get_wield_index(), stack) end + minetest.sound_play({name = "mcl_armor_equip_leather"}, {gain=0.5, max_hear_distance=8, pos=self.object:get_pos()}) return end