Send target location block change to player (possibly related to #33)

This has been shown to stop the client from falling into blocks while teleporting in the past and might as well still solve some issues where the client hasn't received the chunk data yet.
This commit is contained in:
Phoenix616 2019-09-19 18:21:10 +01:00
parent 66b02e8201
commit e979043e14
1 changed files with 4 additions and 0 deletions

View File

@ -344,6 +344,10 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
searcher.search().thenApply(targetLoc -> {
searcher.getTargets().forEach(e -> {
cooldowns.put(searcher.getId(), e.getUniqueId(), new AbstractMap.SimpleImmutableEntry<>(System.currentTimeMillis(), searcher.getCooldown()));
if (e instanceof Player) {
Location belowLoc = targetLoc.clone().subtract(0, 1, 0);
((Player) e).sendBlockChange(belowLoc, belowLoc.getBlock().getBlockData());
}
e.teleport(targetLoc);
sendMessage(e, "teleport",
"worldname", targetLoc.getWorld().getName(),