[Solved] Help with looping sound

Started by leifio on

Topic category: Help with modding (Java Edition)

Last seen on 04:37, 11. Jul 2024
Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Solved] Help with looping sound
Thu, 07/11/2024 - 04:39 (edited)

I am trying to add these goggles and when they're active I want them to have a looping ambient sound. Problem is I'm not great with block code and every iteration I have tried to make ends up waiting then playing it every second causing it to pile, I get why it does this but I don't know how to make the loop activate, wait for a certain amount of time, then activate again.

I've tried complex code and bare bones and both end up either not working or end up waiting then constantly looping. Help please.

Edited by leifio on Thu, 07/11/2024 - 04:39
Last seen on 03:02, 19. Jul 2024
Joined Feb 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You set up a variable for…
Thu, 07/11/2024 - 03:16

You set up a variable for time. (The left side tab under Resources) Name it and choose NUMBER and GLOBAL_MAP.

Then make this code inside the Update Tick (or Entity Tick Update)

https://ibb.co/KW8z6XR

You have to know the length of the sound in ticks (20 ticks per 1 second) 

Also, to stop the sound doubling/echoing for other sounds you can add this:

https://ibb.co/6J7rtv1

 

 

 

Last seen on 04:37, 11. Jul 2024
Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Although your exact code…
Thu, 07/11/2024 - 04:39

Although your exact code didn't work, I just put a wait for 380 ticks (the duration of my sound) then made it add 1 to global time. Thank you for the base though!

Last seen on 02:46, 15. Jul 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Am I able to see the code…
Sat, 07/13/2024 - 14:06

Am I able to see the code for that? Need help with making sure sounds dont repeat themselves