use of net.silentchaos512.gems.world.TeleporterGems in project SilentGems by SilentChaos512.
the class TeleportUtil method teleportPlayerTo.
public static boolean teleportPlayerTo(EntityPlayerMP player, DimensionalPosition pos) {
int oldDimension = player.dimension;
// Debug line TODO: Remove later.
String debugLine = "Teleporting %s from {%s} to {%s}.";
debugLine = String.format(debugLine, player.getName(), new DimensionalPosition(player.getPosition(), player.dimension), pos);
SilentGems.logHelper.info(debugLine);
if (pos.dim != oldDimension) {
WorldServer oldWorldServer = player.getServer().getWorld(oldDimension);
WorldServer newWorldServer = player.getServer().getWorld(pos.dim);
// Dismount and teleport mount
if (player.getRidingEntity() != null) {
Entity mount = player.getRidingEntity();
player.dismountEntity(mount);
teleportEntityTo(mount, pos);
}
// Teleport player to dimension, using a custom teleporter to prevent Nether portal spawns
player.getServer().getPlayerList().transferPlayerToDimension(player, pos.dim, new TeleporterGems(newWorldServer));
if (oldDimension == 1) {
// Fixes world not loading when teleporting from the End.
newWorldServer.spawnEntity(player);
}
}
player.setPositionAndUpdate(pos.x + 0.5, pos.y + 1.0, pos.z + 0.5);
return true;
}
Aggregations