From a2b39ed94341895195cc4eb0dea7a2c52d72b44a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 31 Jan 2019 02:44:05 +0100 Subject: [PATCH] Mobs: Prevent jump sound spam --- mods/ENTITIES/mcl_mobs/api.lua | 9 ++++++++- mods/ENTITIES/mcl_mobs/api.txt | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 1ee20492e..60b6a5bae 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -787,7 +787,10 @@ local do_jump = function(self) end, self, v) if get_velocity(self) > 0 then - mob_sound(self, self.sounds.jump) + if self.jump_sound_cooloff <= 0 then + mob_sound(self, self.sounds.jump) + self.jump_sound_cooloff = 0.5 + end end else self.facing_fence = true @@ -2698,6 +2701,7 @@ local mob_activate = function(self, staticdata, def, dtime) self.selectionbox = selbox self.visual_size = vis_size self.standing_in = "" + self.jump_sound_cooloff = 0 -- used to prevent jump sound from being played too often in short time -- check existing nametag if not self.nametag then @@ -2769,6 +2773,9 @@ local mob_step = function(self, dtime) end end + if self.jump_sound_cooloff > 0 then + self.jump_sound_cooloff = self.jump_sound_cooloff - dtime + end falling(self, pos) -- smooth rotation by ThomasMonroe314 diff --git a/mods/ENTITIES/mcl_mobs/api.txt b/mods/ENTITIES/mcl_mobs/api.txt index 814b28ad3..599ee9cfc 100644 --- a/mods/ENTITIES/mcl_mobs/api.txt +++ b/mods/ENTITIES/mcl_mobs/api.txt @@ -137,7 +137,7 @@ functions needed for the mob to work properly which contains the following: 'shoot_attack' sound played when mob shoots. 'damage' sound heard when mob is hurt. 'death' played when mob is killed. - 'jump' played when mob jumps. + 'jump' played when mob jumps. There's a built-in cooloff timer to avoid sound spam 'fuse' sound played when mob explode timer starts. 'explode' sound played when mob explodes.