Search in sources :

Example 1 with IEServerPlayNetworkHandler

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();
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) IEServerPlayNetworkHandler(com.qouteall.immersive_portals.ducks.IEServerPlayNetworkHandler)

Example 2 with IEServerPlayNetworkHandler

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();
                }
            }
        }
    }
}
Also used : IEServerPlayNetworkHandler(com.qouteall.immersive_portals.ducks.IEServerPlayNetworkHandler) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) IEServerPlayerEntity(com.qouteall.immersive_portals.ducks.IEServerPlayerEntity) IEServerPlayerEntity(com.qouteall.immersive_portals.ducks.IEServerPlayerEntity)

Example 3 with IEServerPlayNetworkHandler

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();
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) IEServerPlayNetworkHandler(com.qouteall.immersive_portals.ducks.IEServerPlayNetworkHandler) IEServerPlayerEntity(com.qouteall.immersive_portals.ducks.IEServerPlayerEntity)

Aggregations

IEServerPlayNetworkHandler (com.qouteall.immersive_portals.ducks.IEServerPlayNetworkHandler)3 IEServerPlayerEntity (com.qouteall.immersive_portals.ducks.IEServerPlayerEntity)2 ServerWorld (net.minecraft.server.world.ServerWorld)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)1