use of com.qouteall.immersive_portals.ducks.IEServerPlayNetworkHandler in project ImmersivePortalsMod by qouteall.
the class ServerTeleportationManager method invokeTpmeCommand.
public void invokeTpmeCommand(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);
sendPositionConfirmMessage(player);
}
player.networkHandler.requestTeleport(newPos.x, newPos.y, newPos.z, player.yaw, player.pitch);
player.networkHandler.syncWithPlayerPosition();
((IEServerPlayNetworkHandler) player.networkHandler).cancelTeleportRequest();
}
use of com.qouteall.immersive_portals.ducks.IEServerPlayNetworkHandler 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.IEServerPlayNetworkHandler 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