Started by
TheKingDuck0225
on
Topic category: Help with Minecraft modding (Java Edition)
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
maybe if you look at a entity play a sound
idk maybe u can modify the ai so it plays a sound when it sees u
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.
What block can I use if there is no "get attack target"