Moon Phases, World.setFullTime()

Discussion in 'Plugin Development' started by TobyZ28, Oct 11, 2012.

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


    Is there any way to use World.getFullTime()/ World.setFullTime() without breaking redstone clocks? I'm attempting to create a plugin that allows for adjustment of time without gimping the moon phases :) Editing World.setTime() shifts the moon phase by 1 day each time no matter what, even if i subtract a tiny amount from the time. (is this a bukkit bug?)

    Ie. I would like augment minecraft time without breaking redstone ;)
  2. Offline


    World.setFullTime(World.getFullTime() - time2remove); ?
  3. Offline


    That exact statement breaks any redstone using a delay :)
  4. Offline


    Ahh ok so he needs code which stores all redstone values, resets the time, then replaces all redstone values? That seems like too much effort for me to be bothered to do sorry mate.
  5. Offline


  6. Offline


    I believe the redstone issues are generally caused by time running backward. You could try to push the time forward by (almost) 8 days instead of subtracting time.

    world.setFullTime(world.getFullTime() - timeToRemove + (24000 * 8));
  7. Offline


    That seems like a too simple solution. What's the catch :p JK GJ.
  8. Offline


    The solution keeps the moon phases steady, and red-stone doesn't freeze but delay switches are accelerated every time the timer is called :( The same goes for button activated doors! I managed to get this working on a timer that updates every 40 ticks, so that its less noticeable by users, but 1/40 ticks a delay timer is potentially "off" and the sky has a noticeable jump in it vs a smaller timer setting.
  9. The native WorldServer class hash a method called "setTimeAndFixTicklists". I'm pretty sure this fixes these redstone issues. I've been using it in a private plugin of mine and didn't notice any issues (I didn't test redstone intensely, though). I have no idea why bukkit doesn't use this method in its API but the normal "setTime" one, which doesn't do this.

    I recommend using it if you are okay with depending on craftbukkit as a library. It's no obfuscated method name, so it's unlikely to change with updates as well.

    Usage with a bukkit world would be:
    ((CraftWorld) world).getHandle().setTimeAndFixTicklists(time);
  10. Offline


    Someone will have to verify that that actually works. I've used it before in MyWorlds and it still caused all redstone to freeze. Right now I simply increment the time by one day when locking the time.

    Best solution would be a fix by Mojang to include both a sun-time and a 'clock time'. (I say Mojang because the CraftBukkit dev team doesn't fix Minecraft)
  11. I'm pretty sure the fixed "NextTickListEntry" is actually redstone. They are serialized to the NBT tag "TileTicks", which is used for redstone, according to the wiki.

    Okay, so now I tested it, works fine for me. I did a quick video demonstrating it:

    The world I am in is reset to a certain time every 20 ticks in this scenario. Here's the class that does it: (look at line 35)

    As soon as I changed the line to use "setTime" instead, redstone went all crazy and broke on a per-coordinate basis (once repeater at x,y,z glitched out, it would never work again).
  12. Offline


    Hi guys,
    This solution was good until today.
    In 1.4.5 I did not find the setTimeAndFixTickLists methods.
    Any solutions ?
  13. I noticed that the method is gone, too. I was about to reimplement it manually, when I realized a pretty fundamental change: World time is now independant from "time of day"!

    While the time of day used to be simply "world time % 24000", it now appears to be an independant value, which is also separately sent to the client (look at changes for 1.4.1).

    That completely eliminates the redstone update issue for freezing / resetting time. You simply modify daytime only and the rest of the world will happily keep its pace.

    I think the code to set daytime was "nmsWorld.worldData.setDayTime(...)" (might work without the worldData part as well.
  14. Offline


    Yes but the moon is still having fun time cycling and cycling
Thread Status:
Not open for further replies.

Share This Page