[TUTORIAL] World Event Timer (Works with multiple players)

Started by Velatus on

Topic category: User side tutorials

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[TUTORIAL] World Event Timer (Works with multiple players)

This was originally for my mod, From Beneath The Ulthran Skies, but I have recently changed the World Event System into custom code so I no longer need the procedure version, and it would be a waste to just delete it and not help others who want a system like it in their own mod.

I built the procedures on MCreator version 2025.3, Forge-1.20.1 but it should still work for the current NeoForge version as long as none of the procedure blocks have been deleted.

A link to the procedures can be found at the bottom of this page.


Variables Needed:

world_event_timer

Number

GLOBAL_WORLD

600

world_event_type (Optional)

String

GLOBAL_WORLD

 

world_event_active

Logic

GLOBAL_WORLD

false

world_event_controller_uuid

String

GLOBAL_MAP

 

world_event_candidate_count

Number

GLOBAL_MAP

0

World Event Timer is used to keep the system looping until it hits the trigger condition to start a World Event. The number is based in ticks and should be the same or higher than the number in the "WORLD_EVENT_TIMER" procedure.

World Event Type is an optional variable as it isn't in this tutorial but would be required if you want to separate events into manageable categories.

World Event Active is a logic (boolean) variable used by the "WORLD_EVENT_TIMER" procedure to check if the world event should activate.

World Event Controller UUID is a variable that stores the current player's UUID that the event will occur on. This is used by "WORLD_EVENT_CHOOSE_PLAYER", "WORLD_EVENT_TIMER_RESET_CHOOSE_PLAYER", and "WORLD_EVENT_LEFT_PLAYER_CHECK" procedures

World Event Candidate Count is a number that stores the number of players in the world and is used by "WORLD_EVENT_CHOOSE_PLAYER" and "WORLD_EVENT_TIMER_RESET_CHOOSE_PLAYER" procedures.


WORLD_EVENT_TIMER

Trigger: On Player Tick Update

This procedure runs in the Server Side Overworld (Surface) and checks if the world_event_controller_uuid is not blank and if the world_event_controller_uuid matches someone on the server. If it does it checks if world_event_active is false and activates the timer function. When the timer reaches a number below 0, it will make world_event_active true, start the event (in the procedure it places a stone block on the world event controller player), and then resets the timer and chooses another player.

 

WORLD_EVENT_TIMER_RESET_CHOOSE_PLAYER

Trigger: No Additional Trigger

Local Variables: 

candidate_count

Number

candidate_uuid

String

This procedure calculates how many people are in the world and chooses a random player, storing their uuid in a local variable. It then checks if the local variable candidate_uuid is not blank and checks if the candidate_uuid is not the same world_event_controller_uuid as the previous event. If its a new uuid it then saves the global world_event_controller_uuid as the candidate_uuid. If the candidate_uuid was the same as the world_event_controller_uuid it saves the global world_event_controller_uuid as the candidate_uuid (Sometimes errors can occur in code so thats why it gets set again). All "print" can be ignored as they are used for debugging.

 

WORLD_EVENT_CHOOSE_PLAYER

Trigger: Player Joins The World

Local Variables:

candidate_count

Number

candidate_uuid

String

This procedure is essentially the same as WORLD_EVENT_TIMER_RESET_CHOOSE_PLAYER but allows the whole procedure set to work when no players have been on the world before.

 

WORLD_EVENT_LEFT_PLAYER_CHECK

Trigger: Player Leaves The World

This procedure checks if the player who left matches the world_event_controller_uuid. If it does, it will reset the timer and choose a new player in the world to be the target for the world event.

 


 

Procedures Link: Google Drive Link

Recommended Import Order: 

  1. WORLD_EVENT_CHOOSE_PLAYER
  2. WORLD_EVENT_TIMER_RESET_CHOOSE_PLAYER
  3. WORLD_EVENT_TIMER
  4. WORLD_EVENT_LEFT_PLAYER_CHECK

If some of the procedures have parts missing from them that means either Snails' Plugin is required or is incompatible with your MCreator version (I cannot recall if I used anything from it). I do recommend downloading Snail's Plugin as it has a lot of useful procedure blocks you can use.