How do i make a sound that only plays when near a mob

Started by dsadasdas on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do i make a sound that only plays when near a mob

I wanna make a boss mob which has a sound which plays when you're near it, and stops playing when far away, how do i do this? and i dont want the sound to be coming from the boss, i want it to sound like its everywhere

Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
anybody??
Sun, 03/24/2024 - 20:45

anybody??

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have a potential solution…
Mon, 03/25/2024 - 00:57

I have a potential solution.

Step one, create a potion effect that has all of the visibility checkboxes unchecked, the potion effect does nothing and cannot be seen, making it good for a timer.

Step two, create a procedure under the "on player tick update" global trigger selection.

Step three, on the procedure add an if block, for the condition, under world data is a procedure block that checks for an entity in an area, use that and set the entity to your boss, and the area size to whatever you want.

Step four, create a second if block inside the first, and set the condition to a not block, followed by has event/target entity active potion effect, with the potion effect set to the one from step one.

Step five, inside the second if block, add the run command at X Y Z world management procedure block, and set the command to "playsound modid:sound ambient @p ~ ~1 ~" replace modid:sound with the internal registry name of the sound you want to play, you can optionally replace ambient with hostile to use different volume settings.

Step six, also inside the second if block, add a second run command at X Y Z procedure block with the command set to "effect give @p modid:potioneffect (seconds) 0 false" replace modid:potioneffect with the internal registry name of the timer potion effect created in step one, replace seconds with the number of seconds you want to pass between each time the sound plays(trust me, not matter what the sound is, you don't want it playing more than once per second).

That should be it, let me know if it doesn't work.

Also, one more thing, I will not post a picture of the procedure, as I do not use image hosting websites.