How do I make a mob that play a sound when it's chasing you?

Started by TheKingDuck0225 on

Topic category: Help with Minecraft modding (Java Edition)

Active 1 year ago
Joined Jul 2023
Points:
201

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 0
How do I make a mob that play a sound when it's chasing you?
Sat, 07/22/2023 - 05:37 (edited)

So I need some help... When I'm being chased by mob I want it play music. Sorta like an enderman

Edited by TheKingDuck0225 on Sat, 07/22/2023 - 05:37
Active 2 months ago
Joined Dec 2021
Points:
529

User statistics:

  • Modifications: 1
  • Forum topics: 4
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 26
maybe if you look at a…
Thu, 08/17/2023 - 06:23

maybe if you look at a entity play a sound

 

Active 2 years ago
Joined Aug 2023
Points:
186

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 4
idk maybe u can modify the…
Thu, 08/17/2023 - 09:21

idk maybe u can modify the ai so it plays a sound when it sees u 

Active 11 hours ago
Joined Apr 2023
Points:
665

User statistics:

  • Modifications: 4
  • Forum topics: 22
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 543
probably on entity tick…
Thu, 08/17/2023 - 12:29

probably on entity tick update, run a procedure something like this(you will also need to create a timer potion effect that does nothing, in potion effect settings you can turn off particles):

if get attack target of event/target entity is (sub)type of LivingEntity

do   if get attack target of event/target entity is (sub)type of player and not event/target entity has potion effect (timer)

        do   play sound (your sound) at X: x position of attack target of event/target entity Y: y of attack target of event/target entity Z: z  position of attack target of event/target entity pitch 1 volume 1 (your sound)

                apply potion effect (timer) to event/target entity for (duration of sound) ticks 0 amplifier.

 

 

 

I apologize if I have misspelled anything, but you are able to create a procedure that looks like that in the latest version of MCreator.    The first line detects if your mob is actually targeting something so later lines won't crash(with it, it's fine), the second line checks for conditions of it chasing a player, and not on cooldown, the third part(one line in the procedure editor) actually plays the sound, and the fourth line adds the timer potion effect so the sound won't get spammed.

There are other ways to do what you want, but this one should work.

Active 11 months ago
Joined Jan 2024
Points:
147

User statistics:

  • Modifications: 0
  • Forum topics: 5
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 16
What block can I use if…
Tue, 01/30/2024 - 02:40

What block can I use if there is no "get attack target"

Active 7 months ago
Joined Jan 2025
Points:
39

User statistics:

  • Modifications: 0
  • Forum topics: 1
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 3
Can you put a picture…
Tue, 01/07/2025 - 16:16

Can you put a picture because I don't understand what you mean.