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); }
@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.
@Zombie_Striker Is possible to make with packets? Because potterworld server has it, I don't know how...
@Sumure The setPlayerTime is packets. It may be that "addTime" is too large. Try reducing addTime to something under 20.
@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.
@Sumure It looks like they are updating the daylight-tick multiple times a tick. You may need to use a separate thread and a packet injector to send the packets faster than the server can tick. You should decompile this plugin to see how they achieve the time-change: https://www.curseforge.com/minecraft/bukkit-plugins/customtime
@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.