["Guide"] A Block for Repeating Music

Started by absoluteRat on

Topic category: Help with modding (Java Edition)

Last seen on 00:12, 7. Sep 2024
Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
["Guide"] A Block for Repeating Music

I did a lot of digging for a means of looping music over many forums and could not find one. After trial and error and many crashes, I present to you, "It is daytime my dudes".

The Procedure: [Yrrt]

How it looks in action: [Skrrt]

The Procedure Towards the Procedure:

    Create a variable for to act as a switch over the rapid-fire Global On Player Tick block. We're not using world tick because it lacks the dependency, "Entity". Furthermore, we're not using a Local Variable as Local Variables can not be assigned to "Do" tasks. [I found all of this out while trying to make this so trustmebro.png] I set my Variable to the name of my music, as it is also an apt descriptor of what time it is. 

    So, just by looking at the code, you can likely understand what is going on now with this knowledge. The procedure is confirming whether or not it's day, notably, night, and assigning a value to a variable. When TheLateHours is at 1, think about "TheLateHours (the song to loop) is currently playing". Now, TheLateHours will be at 1 for 2480 ticks. 2480 ticks translates roughly to 2:02 in real time which is exactly how long TheLateHours will play for. Once those ticks expire, the song will be over, and TheLateHours will be set to 0 -- TheLateHours is not playing. 

    The procedure is now going to repeat as it is happening every player tick. Meaning, from square one, TheLateHours will be at 0 and then once again set to 1. The song loops.

    I hope you can apply this procedure in your mod. At this time in my concluding paragraph, I'd like to take the time to thank both the developers of MCreator and the MCreator Community. Without MCreator, I'd likely never see my dream mod come about.

    Truly,

absoluteRat.