LaurentOutang Posted April 1, 2018 Posted April 1, 2018 Hello, Do you know a way to modify the length of a day (and a nigth) without doing a new WorldProvider. I want that the length of a day follows a function like : 5 * sin( 2*pi*f*DAY_COUNT + p ) + 10 in order to put a 15m day in summer and a 5m day in winter. Thank's for the help and sorry for my english. Quote
jabelar Posted April 1, 2018 Posted April 1, 2018 Did you search the forums? There are lots of lengthy discussions on this topic which don't need to be repeated here. Basically, to do it properly is complicated because you have handle things like the time command, sleep cycles, and some mod compatibilities such as sky animations. And yes generally it requires a replacement world provider. However, if you want a really crude way of doing it you can add or subtract ticks to the world tick counter -- basically like a "leap second" sort of approach but there are dangers to that as discussed at length in previous threads. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
LaurentOutang Posted April 2, 2018 Author Posted April 2, 2018 Yes I searched but I didn't find something really detailed. If I change ticks, does it affect the render like player speed on screen or this kind of stuff ? If I want that snow fall from the sky in winter should I also do a WorldProvider (if I must do this I will probably take the WorldProvider option for the time) ? Thank you Quote
Draco18s Posted April 2, 2018 Posted April 2, 2018 2 minutes ago, LaurentOutang said: If I change ticks ...what? Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Ruukas Posted April 2, 2018 Posted April 2, 2018 As you say, you need a WorldProvider (although, "need" is rarely the correct word to use about coding) Quote
Ruukas Posted April 2, 2018 Posted April 2, 2018 (edited) It's possible that you could bypass the WorldProvider, when rendering the sky, but I doubt that would be a good solution Edit: I almost forgot that the sky if far from the only difference between night and day Edited April 2, 2018 by Ruukas Quote
LaurentOutang Posted April 2, 2018 Author Posted April 2, 2018 27 minutes ago, Draco18s said: ...what? +- 1 tick 26 minutes ago, Ruukas said: As you say, you need a WorldProvider (although, "need" is rarely the correct word to use about coding) Ok thank you Quote
Draco18s Posted April 2, 2018 Posted April 2, 2018 3 minutes ago, LaurentOutang said: +- 1 tick Ok thank you Game Ticks != Render Ticks Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Ruukas Posted April 2, 2018 Posted April 2, 2018 3 minutes ago, Draco18s said: Game Ticks != Render Ticks But isn't time tied to game ticks? Quote
jabelar Posted April 2, 2018 Posted April 2, 2018 16 minutes ago, LaurentOutang said: Yes I searched but I didn't find something really detailed. If I change ticks, does it affect the render like player speed on screen or this kind of stuff ? If I want that snow fall from the sky in winter should I also do a WorldProvider (if I must do this I will probably take the WorldProvider option for the time) ? Thank you Rendering is done in separate thread (I think) which updates every screen refresh (like 60Hz or even 120Hz depending on display). The main game logic loops in "ticks" which are 20 per second (unless lagging). Since the rendering and main loop are not really synced up specifically, there is concept of "partial ticks" used to help smooth out some animations. So if you did something like simply changing the world tick count, it wouldn't directly affect rendering. However, it could affect other things. For example, I think the the sleep cycle uses it (like in WorldServer#tick() metho), and world difficulty uses world tick count for the increasing difficulty, I think the map spinning might use it, And some mods might use it for timing things. So there might be some side effects. But it would be fun to try. Just use a tick handler and use the World#setWorldTime() method as you wish and see what happens. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Ruukas Posted April 2, 2018 Posted April 2, 2018 I remember seeing timelapse (speeding up time) mods. I'm not sure exactly how they worked, but I don't think they used WorldProvider Quote
Draco18s Posted April 2, 2018 Posted April 2, 2018 2 minutes ago, Ruukas said: I remember seeing timelapse (speeding up time) mods. I'm not sure exactly how they worked, but I don't think they used WorldProvider No, they do. They'd have to. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Ruukas Posted April 2, 2018 Posted April 2, 2018 What if you replicate /time set and /gamerule doDayLightCycle to keep the sun in place, or skip some time? Not sure if that has the same implications as directly changing ticks. Quote
jabelar Posted April 2, 2018 Posted April 2, 2018 Another point. The world info contains two "time" fields. There is totalTime and worldTime. The latter only cycles through the 24000 of the day cycle and is used for things like celestial angle. The totalTime is the time since the world started. There is the corresponding World#setTime() and World#setWorldTotalTime() methods. The total time is used for a lot of stuff. If you look at the call hierarchy it is used for things like armor stand rendering applyRotations() method, used to "pace" some updates from happening too , quickly (like it waits every 600 ticks to update the "calendar date"), used in animations of items and TESR, checking for redstone torches to burn out, and many other things. In other words, if you slow down the "day / night" cycle by affect the rate of tick counters like totalTime you will likely slow down many other things. So it wouldn't just be a langer day, some things would also happen slower and some things might happen multiple times like command block triggers. Now that might be what you want to have happen -- if the day is longer maybe you would want some things to be slower. But just wanted to point that out. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
jabelar Posted April 2, 2018 Posted April 2, 2018 6 minutes ago, Ruukas said: What if you replicate /time set and /gamerule doDayLightCycle to keep the sun in place, or skip some time? Not sure if that has the same implications as directly changing ticks. If you just want the sky to move slower, that works pretty much like you just suggested -- basically you can affect the time of day direcly with World#setWorldTime() and it mostly just affects the celestial angle. However, as mentioned above you will then get out of sync with other functionality like sleep cycles (which will force the time to advance expecting vanilla day duration) and the "calendar" system. And if you try to fix everything it will get complicated because then you need also change the totalWorldTime and that is used by a lot of things. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
LaurentOutang Posted April 4, 2018 Author Posted April 4, 2018 I'm doing it with the class WorldProviderSurface, it works fine, I'll try to handle issues with sleeping and commands. Thank you 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.