Started by
baileywithaw
on
Topic category: Help with Minecraft modding (Java Edition)
So I'm trying to make a phone item that randomly rings when in the players inventory, but having a "wait random tick then play sound" procedure will indefinitely play sounds after some time. How do I make it play once and restart the wait random ticks?
One possibility is to use an if block that is something like:
[if[[random 0,1]<[0.001]]]
do [your procedure]
Instead of using the wait block, which does not pause the procedure from working.
The option I offered is a simple method that does a random delay, by simply randomizing when it happens.
If you want a more complex system with more control, you could do something with the item's NBT data, checking if NBT number value "timer" is greater than 0, setting "timer" to "timer" - 1 if it is. Else do your procedure to play the sound, then set timer to a random number within the range you want for the wait block.
The first option is purely random, the second is a little more complicated but has more control, neither of them use the built-in wait block as it acts as a delay for the current procedure, but does not stop the procedure from running again in the next tick, and the next.
I hope this helps.
YES! that works perfectly!! thank you!