Force random location to the middle of block before teleporting (#33)

Also add 0.1 to the y so that the player is guaranteed to be above the below block
This commit is contained in:
Phoenix616 2019-10-03 13:46:42 +01:00
parent 4c1b8a7c9a
commit dd6fffe0d5

View File

@ -364,6 +364,9 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
Block belowBlock = belowLoc.getBlock(); Block belowBlock = belowLoc.getBlock();
((Player) e).sendBlockChange(belowLoc, belowBlock.getType(), belowBlock.getData()); ((Player) e).sendBlockChange(belowLoc, belowBlock.getType(), belowBlock.getData());
} }
targetLoc.setX(targetLoc.getBlockX() + 0.5);
targetLoc.setY(targetLoc.getY() + 0.1);
targetLoc.setZ(targetLoc.getBlockZ() + 0.5);
e.teleport(targetLoc); e.teleport(targetLoc);
sendMessage(e, "teleport", sendMessage(e, "teleport",
"worldname", targetLoc.getWorld().getName(), "worldname", targetLoc.getWorld().getName(),