Minecraft – How to turn seconds into minutes and seconds

minecraft-commandsminecraft-java-edition

I am making a racing minigame in Minecraft in 1.8.9 right now. I seem to have trouble how to figure out how to convert my existing setup into minutes and seconds. Let me explain:

I have an objective, best, which finds the best time of a player once they finish my course. After, the player can check to see if they have reached a personal best by pressing a button. This button just executes a tellraw command that says the objective. The problem is that best is in only seconds, so if their personal best is higher than 59 seconds, it will still display in seconds. How do I convert it to minutes and seconds?

Read the bold to save time and not die of boredom.

Best Answer

Adding a converter

Since you have one objective that has all the time in seconds, all you want to do is essentially subtract 60 seconds off of the objective and add a minute to a separate score for every 60 seconds. You can do this by adding a clock that does a /testfor to test if the player has at least a score of 60 for the objective best. You can get the output from that command using a comparator and, when that result is true, have two other command blocks that will subtract 60 seconds and add a minute to the player's score. The remaining seconds will be converted to bestsecond and the minutes will be bestminute. That's it!