setPlayerTime smootly

Discussion in 'Plugin Development' started by Sumure, Dec 6, 2017.

Thread Status:
Not open for further replies.
  1. Hi, I'm looking at how to make a player change his day when he enters a WorldGuard region:"player#setPlayerTime". I found this in the "Bukkit" forums and it has been very helpful, but I can't see what to do to make the day change smoothly and not suddenly.

    player.setPlayerTime:
    https://i.imgur.com/7A1pNJq.mp4
    world.setFullTime:
    https://i.imgur.com/AWawCcK.mp4

    Code:
        @EventHandler(priority = EventPriority.NORMAL)
        public void onRegionEnter(RegionEnterEvent e){
            Player player = e.getPlayer();
            String region = e.getRegion().getId();
            e.getPlayer().sendMessage("You just entered " + region);
            World w = Bukkit.getWorld("world");
       
            new BukkitRunnable() {
                int end = 17000;
                int worldTime = (int) w.getTime();
           
                @Override
                public void run() {
                    player.sendMessage("Updating Time: ");
    
                    if (player.getPlayerTime() % 24000 < end) {
                        player.sendMessage("Time: " + player.getPlayerTime());
                        player.setPlayerTime(worldTime, false);
                    } else {
                        player.sendMessage("Time: " + player.getPlayerTime());
                        player.setPlayerTime(end, false);
                        cancel();
                    }
               
                    worldTime = worldTime + addTime;
                }
            }.runTaskTimer(this, 0, 1);
    }
     
  2. Offline

    Zombie_Striker

    @Sumure
    There is no way to make it completely smooth; Minecraft doesn't allow you to change the actual timestep. You can increment the time every couple of ticks by a slightly larger value to simulate a "smooth" transition, but there will still have some skips.
     
  3. @Zombie_Striker Is possible to make with packets?
    Because potterworld server has it, I don't know how...
     
  4. Offline

    Zombie_Striker

    @Sumure
    The setPlayerTime is packets.

    It may be that "addTime" is too large. Try reducing addTime to something under 20.
     
  5. @Zombie_Striker I've already changed many times to test the problem is that it's very slow if I put numbers under 20. And if I put numbers like 100, what you see in the image happens. I share a video for you to see what I mean, this is on an mc server without mods, just plugins.

     
  6. Offline

    Zombie_Striker

    0ct0berBkkitPlgins likes this.
  7. @Zombie_Striker
    I checked that plugin and many others that do the same function but didn't help me at all. I'm trying to look for more information about this but it seems that no one has asked about it. Can I make a plugin request as what I'm looking for, right?

    And thank you for taking the time to help me.
     
Thread Status:
Not open for further replies.

Share This Page