use of com.qouteall.immersive_portals.ducks.IEServerPlayerEntity in project ImmersivePortalsMod by qouteall.
the class ServerTeleportationManager method changePlayerDimension.
/**
* {@link ServerPlayerEntity#changeDimension(DimensionType)}
*/
private void changePlayerDimension(ServerPlayerEntity player, ServerWorld fromWorld, ServerWorld toWorld, Vec3d destination) {
BlockPos oldPos = player.getBlockPos();
teleportingEntities.add(player);
// TODO fix travel when riding entity
player.detach();
fromWorld.removePlayer(player);
player.removed = false;
player.x = destination.x;
player.y = destination.y;
player.z = destination.z;
player.world = toWorld;
player.dimension = toWorld.dimension.getType();
toWorld.respawnPlayer(player);
toWorld.checkChunk(player);
McHelper.getServer().getPlayerManager().sendWorldInfo(player, toWorld);
player.interactionManager.setWorld(toWorld);
Helper.log(String.format("%s teleported from %s %s to %s %s", player.getName().asString(), fromWorld.dimension.getType(), oldPos, toWorld.dimension.getType(), player.getBlockPos()));
// and the advancement of travelling for long distance through nether
if (toWorld.dimension.getType() == DimensionType.THE_NETHER) {
// this is used for
((IEServerPlayerEntity) player).setEnteredNetherPos(player.getPos());
}
((IEServerPlayerEntity) player).updateDimensionTravelAdvancements(fromWorld);
}
use of com.qouteall.immersive_portals.ducks.IEServerPlayerEntity in project ImmersivePortalsMod by qouteall.
the class ServerTeleportationManager method tick.
private void tick() {
teleportingEntities = new HashSet<>();
long tickTimeNow = McHelper.getServerGameTime();
if (tickTimeNow % 10 == 7) {
ArrayList<ServerPlayerEntity> copiedPlayerList = McHelper.getCopiedPlayerList();
for (ServerPlayerEntity player : copiedPlayerList) {
if (!player.notInAnyWorld) {
Long lastTeleportGameTime = this.lastTeleportGameTime.getOrDefault(player, 0L);
if (tickTimeNow - lastTeleportGameTime > 60) {
sendPositionConfirmMessage(player);
((IEServerPlayerEntity) player).setIsInTeleportationState(false);
} else {
((IEServerPlayNetworkHandler) player.networkHandler).cancelTeleportRequest();
}
}
}
}
}
use of com.qouteall.immersive_portals.ducks.IEServerPlayerEntity in project ImmersivePortalsMod by qouteall.
the class ServerTeleportationManager method teleportPlayer.
private void teleportPlayer(ServerPlayerEntity player, DimensionType dimensionTo, Vec3d newPos) {
ServerWorld fromWorld = (ServerWorld) player.world;
ServerWorld toWorld = McHelper.getServer().getWorld(dimensionTo);
if (player.dimension == dimensionTo) {
player.setPosition(newPos.x, newPos.y, newPos.z);
} else {
changePlayerDimension(player, fromWorld, toWorld, newPos);
((IEServerPlayNetworkHandler) player.networkHandler).cancelTeleportRequest();
}
((IEServerPlayerEntity) player).setIsInTeleportationState(true);
player.networkHandler.syncWithPlayerPosition();
}
Aggregations