Add Ability to make custom sounds loop when triggered

Upvotes: 0
Issue description

Add Ability to make custom sounds loop when triggered

trying to make a weird buzzing sound loop endlessly in a custom dimension with great difficulty

Issue comments

I have done this in the past. My mod has various alarms, computers, etc. 

 

It's actually quite simple logically, but MCreator sadly does not support it. 

 

Basically, here's the steps

1. [Block Unlocked] Create procedure that plays desired sound

2. [Block Unlocked] Set tick rate of block to length of sound

3. [Block Unlocked] Set block onTick procedure to created sound procedure from step 1

4. [Block Unlocked] Set block redstone on procedure to created sound procedure from step 1

4. LOCK BLOCK AND GO TO BLOCK CODE

5. [Block Locked] Move schedule block update/tick call from onBlockAdded to Redstone on function.

5. [Block Locked] In onTick function in block code, add check for if block still has redstone power. Inside that, add another call to schedule block update/tick.

 

Basically, this modification gives you a block that will loop a sound of your choice while the block has redstone power. This is done by modifying block tick behavior.

 

Instead of the block always ticking, redstone power on triggers the block to immediately start ticking. 

 

Each time the block ticks, it will play the sound, and check if it still is getting redstone power. If it still has power, it schedules another block tick, but if it doesn't have power, it doesn't schedule another block tick.

 

This also synchronizes the sound on blocks that get redstone power at the same time.

 

Thank you! Is that a feature that could be added in a future MCreator version? I know it’s a rather small bit of code, but I also know you are busy with other stuff in MCreator — i’d help add this feature if I could.



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.