How can I detect when the day changes?

Started by RawrTheDinosawr on

Topic category: Help with modding (Java Edition)

Last seen on 00:56, 4. Sep 2024
Joined Aug 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How can I detect when the day changes?

I'm adding a calendar and seasons system to my mod and I need to know when the Minecraft day changes in order to run the procedure to update it. Days are counted from 1-5 and on the 6th day the season changes with the day counter resetting back to 1. At first I tried just running the procedure when it detects that the time of day is 18,000 (midnight) but for some reason it ran multiple times in the single tick that it is midnight for and changed the day all the way from 1 to 5.

I can't just get the game time and divide it by 24,000 to get the day number because I need to specifically detect when it goes up by a whole number in order to change the date in the calendar system.

Here's the system that I currently have and doesn't work:

I would have put in another image showing the day counter going straight from one up to five but I can only put in a single image. The stuff in this procedure that gets cut off below the screenshot sets the season (stored as a text variable so that it works with the calendar) to the season_number variable.