[SOLVED] How do I get music to player in a dimension when the play enters it?

Started by _Syntax_3rror_ on

Topic category: Help with Minecraft modding (Java Edition)

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[SOLVED] How do I get music to player in a dimension when the play enters it?
Sun, 04/07/2024 - 17:29 (edited)

I want it so music plays as soon as the player enters a certain dimension and when the music finishes, it waits a certain amount of time and plays the music again. I want this to be a constant loop.

Edited by _Syntax_3rror_ on Sun, 04/07/2024 - 17:29
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
To start, there should be a …
Sat, 09/23/2023 - 18:27

To start, there should be a "player enters dimension" trigger, either in your dimension element or in global triggers.

For the repeating loop, you are going to want to set up a procedure either for "on player update tick" or "on world update tick". The blow is for on world update so that all players hear it at the same time, but you can adapt it for the player update tick too.

 

"On world update tick"

Set up 2 global variables, one of them a numeric value called "dimension_ID_sound_lock_timer" and a Boolean/logic "dimension_ID_sound_lock"

 

If "dimension_ID_sound_lock" = false do{

Set "dimension_ID_sound_lock" = true

Set "dimension_ID_sound_lock_timer" = the amount of time you want for the delay in ticks (20 ticks/second - 60 seconds = 1,200 ticks)

For each player in world as entity iterator (if dimension ID player is in = your dimension do{

Play sound}

)

}

New "main" if statement:

if "dimension_ID_sound_lock" = true do {

If "dimension_ID_sound_lock_timer" > 0 do {

Set "dimension_ID_sound_lock_timer"  = get "dimension_ID_sound_lock_timer" minus 1}

Else if  "dimension_ID_sound_lock_timer" = 0 do {

Set "dimension_ID_sound_lock" = false}

}

 

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Am I able to have a picture…
Sun, 09/24/2023 - 10:37

Am I able to have a picture example?

 

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thank you so much for the…
Sun, 09/24/2023 - 16:00

Thank you so much for the help!
one last question: Can I use the same variables for multiple dimensions?

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Not really. It would be best…
Sun, 09/24/2023 - 16:11

Not really. It would be best to make a new variable for each dimension. If you use the same variable, and have multiple players in each dimension, then both dimensions would be modifying the variable at the same time, and it could get a little messy.

The code itself though can be used for any dimension. Just create a new global for each dimension.

Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Got it! Thank you!  
Sun, 09/24/2023 - 16:14

Got it! Thank you!