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)

Joined Jul 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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
Joined Dec 2021
Points:

User statistics:

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

maybe if you look at a entity play a sound

 

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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 

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
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.

Joined Jan 2024
Points:

User statistics:

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

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