How to make my mob dance like piglins when they hear certain music in a radius?

Started by vlonabuser on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to make my mob dance like piglins when they hear certain music in a radius?

I made a computer that can play any record in the game and i have a mob that i want to vibe when i turn music on. I tried to do it that way: when computer plays music it changes its "music" logic nbt to true, i dont know how to optimise scanning blocks so i js made it so every tick my mob checks if block at x+/- random 1:6  y +/- random 1:6 has "music" logic nbt set to true, if it is, it changes his data logic "vibe" to true and it should play animation and override its motion vector to 0 cuz i dont know how to stop it from walking any other way. Somehow it crashes the game with "/ 0" java exception. Pls help

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
can you show the procedure?
Fri, 09/19/2025 - 06:38

can you show the procedure?

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i dont know how to show it…
Fri, 09/19/2025 - 20:17

i dont know how to show it its too big, is there a way i can send you full mod so you can take a better look cuz i think i messed up somewhere else

 

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'd prefer you just send the…
Sat, 09/20/2025 - 10:36

I'd prefer you just send the procedure(s) that are relevant, you can send them as procedure files,

Joined Jun 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
https://drive.google.com…
Sun, 09/21/2025 - 06:28

https://drive.google.com/file/d/1c5QkzyWo12Hr2GgbDAh3nRbwMPic_k1g/view?usp=sharing

it works but not how i wanted it to, computer should make blocks under it (in 7*7 radius) have "music" nbt tag set to true, make global var musicplaying to true and set vars musicx y and z to its location. now there is another problem, i dont know why nbt tags work only with custom blocks so i had to make one, if musicplaying is true it sets nbt tag "music" to true so it works. only problem is its still not working like piglins and there is no easy way to check or set something in radius so i think this is not the most optimal way to implement my idea, i think you are more skilled in this than me so pls give me some tips

Joined Dec 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
the reason why you can't set…
Sun, 09/21/2025 - 07:34

the reason why you can't set some block's nbt is because they have to be block entities. You should be able to set the nbt of fx. a chest or a furnace.

you can check for entities in a radius with this,