Filled REALTIME day/night

Discussion in 'Archived: Plugin Requests' started by kamakarzy, Apr 22, 2013.

  1. Offline

    timtower Moderator Moderator

    kamakarzy You do need to realize that the time minecraft is using is a bit odd
    This is my code :
    Code:
    Calendar cal = Calendar.getInstance();
            cal.getTime();
            int hour = cal.get(Calendar.HOUR_OF_DAY);
            int minute = cal.get(Calendar.MINUTE);
            int minutes = hour*60 + minute;
            int newtick = minutes*1000/72;
            world.setTime(newtick-6000);
    If you have any changes please let me know
     
  2. Offline

    ShadowDog007

    Going by this example, 720000 = 10000.
    Nice math.
     
  3. Offline

    kamakarzy

    im not a coding expert but (newtick-6000) wouldnt that do the sum of int newtick = miutes*1000/72; then -6000 if thats the case souldnt it be

    Code:
    Calendar cal = Calendar.getInstance();
            cal.getTime();
            int hour = cal.get(Calendar.HOUR_OF_DAY);
            int minute = cal.get(Calendar.MINUTE);
            int minutes = hour*60 + minute;
            int newtick = minutes*1000/72;
            world.setTime(newtick);
    ShadowDog007 nice find forgot to add a 0 lol

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  4. Offline

    timtower Moderator Moderator

    kamakarzy In minecraft 7:00 is gametick 0, that is why I take 6000 of, but maybe it should be 7000
     
  5. Offline

    kamakarzy

  6. Offline

    timtower Moderator Moderator

    kamakarzy Sorry for the mistake, but do you get the -6000?
     
  7. Offline

    kamakarzy

    yea i do get it as if you type /time set 10000 its 4pm in game if you set 23000 its 5am

    timtower its working just for some reason time is off by 1 hour and 50 mins

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
  8. Offline

    timtower Moderator Moderator

    kamakarzy Do I need to add 1 hour and 50 min or remove them?
     
  9. Offline

    kamakarzy

    add m8 but other then that great and thank you ever so much
     
  10. Offline

    timtower Moderator Moderator

  11. Offline

    kamakarzy

    sorry timtower the whole reason its not working is my fault i used all real time maths apart from minutes so your using minecraft ticks instead of real time the actual code would be

    Code:
    Calendar cal = Calendar.getInstance();
            cal.getTime();
            int hour = cal.get(Calendar.HOUR_OF_DAY);
            int minute = cal.get(Calendar.MINUTE);
            int minutes = hour*60 + minute;
            int newtick = minutes*1200/72;
            world.setTime(newtick);
     
  12. Offline

    timtower Moderator Moderator

    Mistakes are human ;)
    https://www.dropbox.com/s/gjr6kqiw2dfarfd/TimeLikeMe.jar
     
  13. Offline

    kamakarzy

  14. Offline

    YoshiGenius

    Why wouldn't it? :p
     
  15. Offline

    timtower Moderator Moderator

    kamakarzy No problem ;)
    Please mark the thread as Filled

    YoshiGenius You just add a tick every 72 ticks, but when do you start it? It will follow the same time window though, but it won't be the same time

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

    YoshiGenius

    When the server starts up, set the time to whatever the real time is using the previously stated thingo. Convert the date to ticks then divide that by 72.
     
  17. Offline

    timtower Moderator Moderator

    YoshiGenius If the server lags it won't work anymore, not going to edit something that is working
     
  18. Offline

    YoshiGenius

    True... calculations can account for that. :p

    Remember, you need to reset the world tick back to zero at 6am, because minecraft doesnt keep going up.
     
  19. Offline

    timtower Moderator Moderator

    YoshiGenius Minecraft has the ability to take numbers smaller than 0 and bigger than 24000, it is auto adapting. No need to keep that in mind.
     
  20. Offline

    FlOppy

    I download your plugin which is cool, but i had to stop it because of the low latency it causes and the graphical default. infact everytime the sun goes up, i think because it is recalculating the position with minecraft and the plugin. the problem is that every 5 seconds (aproximatively) all the light goes brighter causes lags and really weird for the eyes it is dark and every 5 seconds it is sunny. I think it does that only when the sun goes down and maybe when the sun goes up haven't tested it.

    Do you think there is a possibility to fix that ?
     

Share This Page