Playing a sound to the player at sun rise and sun down

Started by WildFyr on

Topic category: Help with modding (Java Edition)

Last seen on 15:42, 6. Nov 2023
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Playing a sound to the player at sun rise and sun down

I want to create a mod that plays a sound file at 6am and 6pm to help keep track of time underground and in different dimensions. What would be the best way to do this? Currently, I have a procedure set up with an if/else if statement with a get current world time equal to 0 or 12000 and it has a play command for each sound. This does nothing, as I have not stated where the sound is to play, but is this the most efficient way to do this or is there something else I am missing?

Last seen on 20:37, 26. Jul 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Yes you can do this, it's…
Tue, 10/31/2023 - 22:00

Yes you can do this, it's mostly just a matter of making sure you play the sound correctly. Keep in mind that if you provide a mono track, it'll play diegenicly, (That means the sound will have a source at the position you give it, and moving around will change its direction and volume), whereas a stereo track will just play for an entity regardless of their position. (This is how music works in Minecraft.)

As for the procedure, you probably want to use the global trigger 'On World Tick Update,' (this is honestly the first time I've ever seen an instance where it makes sense to use this), which checks if the time is equal to 0 or 12000. If either of these is true, use the 'With all players as entity iterator' bracket in the world tab, and inside, put a 'play sound' function, replacing the x/y/z values with the x/y/z coordinates of the entity iterator.

Again, not sure how this will work depending on whether or not you're in multiplayer; it seems like for stereo sounds like music all players can hear them regardless of position, but I'm also not sure if that's client or server side, (if it's distinct for each player.) Mono is more annoying because you have to make sure to provide a position, but if you're okay with playing diegenic sounds for your indicator, targeting all players as an entity iterator should work.

Last seen on 15:42, 6. Nov 2023
Joined Jul 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Exceptional! Thank you for…
Wed, 11/01/2023 - 15:31

Exceptional! Thank you for responding and helping me set this up; I had planned for it to be client-sided. For the sound file when you say either mono or stereo are you talking about the .ogg itself, or a setting somewhere in the sound resource? I am using the Rooster and Wolf sounds from The Legend of Zelda. As for being in Multiplayer, I did plan to use it while being in Multiplayer... Is there a way to make it work like the Advancement sound where it would only play for the player and not on all players? I am not sure how that works, so maybe that is impossible.