Get Time of Day

Discussion in 'Plugin Development' started by Daniel Few, May 24, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Daniel Few

    How can you get the MineCraft time in a server? Check to see what time it is?
    -DanJames
     
  2. Offline

    DreadKyller

    you need to somehow get the world itslef, you can do this like:

    player.getWorld()

    once you get the world use getTime()

    world.getTime();
     
  3. Offline

    SilverstarX

    Would you like to have a plugin for that or do you want to get the time in a plugin?

    If second, its
    Code:
    Bukkit.getServer().getWorld(worldname).getTime();
    where worldname is a String containing the name of the world.
    That will get you the relative time, like 8:00, but as a long, where 0 is 8:00 and 1000 is 9:00 and so on (and 500 about 8:30 etc pp).
    getFullTime will get you the absolute time, for use in a calender or such.
     
  4. Offline

    Daniel Few

    You know a minecraft day is 24000, is there a list somewhere which shows u where in that time the different times of day starts.

    Eg: Sunrise at 0
    Sunset at 12000 - dunno if these are right but is there a list?
    -DanJames
     
  5. Offline

    DreadKyller

    unfortuneatly with the getWorld(name) you have to know the name of the world, not good unless you know how to get the world name.

    and @Daniel Few : you are correct, 0 refers to the point where the sun is half showing and 1200 is the point where the sun is half done going down, 0 and 2400 are the same, the minecraft time is by seconds, so every 100 int the real world seconds is the equivalent of 1 hour in the minecraft world, 1 and 2/3 minute = 1 hour.
     
  6. Offline

    Daniel Few

    Is there a Event when sunset begins/ends and sunrise begins/ends?
    -DanJames
     
  7. Offline

    DreadKyller

  8. Offline

    Daniel Few

    @DreadKyller
    But surely Minecraft needs to know when zombies are coming out? Is this avaiable in bukkit?
    -DanJames
     
  9. Offline

    nisovin

    Sunrise is around 23000, noon 6000, sunset 13000, and midnight 18000. There aren't sunrise and sunset events, you'd have to schedule a repeating task to watch the time.
     
  10. Offline

    Daniel Few

    @nisovin
    Thanks for that :) You helped a lot.
    -DanJames

    @DreadKyller
    @nisovin
    @SilverstarX

    Does getTime() get the time of day, or the time since the server started?
    -DanJames

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 16, 2016
  11. Offline

    nisovin

    World.getTime() gets the time of day between 0 and 24000. World.getFullTime() gets the time since the server started.
     
  12. Offline

    Daniel Few

  13. Offline

    DreadKyller

    @Daniel Few : yes, minecraft needs to know what time to spawn zombies and stuff, but it useually uses lightLevel and not time, as seeing they can spawn in caves and places where it is dark, even when not night.

    @nisovin : If sunrise starts 100 seconds before 0 then sunset is 100 seconds before 1200, not 100 after, otherwise it's more of sun_has_already_set.
     
  14. Offline

    nisovin

  15. Offline

    jamescosten

    Ok well i'll have a crack at this......ahem

    Use the ingame clock, [​IMG]
     
  16. Offline

    Daniel Few

    @jamescosten
    Well hello Mr. Sarcy, didn't know you were on-line today.
    -DanJames
     
  17. Offline

    jamescosten

    At least you got the MR right :D
     
  18. When u use dynmap on a server and go and check the map, there's a clock and sun/moon showing the time and lightlevel. They have to get the "real" time somehow, right? Just a noob question :p
     
  19. Offline

    DreadKyller

    @Sketaful : yes, it uses the world.getTime() or it could probably find the time somehow from a clock(the ingame hand-held one)
     
Thread Status:
Not open for further replies.

Share This Page