Search in sources :

Example 1 with TakumiTeleporter

use of com.tntmodders.takumi.world.teleport.TakumiTeleporter in project takumicraft by TNTModders.

the class BlockTakumiPortalFrame method changeDim.

private boolean changeDim(EntityPlayer playerIn) {
    MinecraftServer server = playerIn.world.getMinecraftServer();
    if (server != null) {
        PlayerList playerList = server.getPlayerList();
        int i = playerIn.dimension == DimensionType.OVERWORLD.getId() ? TakumiWorldCore.TAKUMI_WORLD.getId() : DimensionType.OVERWORLD.getId();
        Teleporter teleporter = new TakumiTeleporter(server.getWorld(i));
        if (playerIn instanceof EntityPlayerMP) {
            playerList.transferPlayerToDimension((EntityPlayerMP) playerIn, i, teleporter);
        } else {
            int origin = playerIn.dimension;
            playerIn.dimension = i;
            playerIn.world.removeEntityDangerously(playerIn);
            playerIn.isDead = false;
            playerList.transferEntityToWorld(playerIn, origin, server.getWorld(origin), server.getWorld(i), teleporter);
        }
    }
    return true;
}
Also used : PlayerList(net.minecraft.server.management.PlayerList) Teleporter(net.minecraft.world.Teleporter) TakumiTeleporter(com.tntmodders.takumi.world.teleport.TakumiTeleporter) TakumiTeleporter(com.tntmodders.takumi.world.teleport.TakumiTeleporter) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MinecraftServer(net.minecraft.server.MinecraftServer)

Example 2 with TakumiTeleporter

use of com.tntmodders.takumi.world.teleport.TakumiTeleporter in project takumicraft by TNTModders.

the class BlockTakumiPortal method onEntityCollidedWithBlock.

/**
 * Called When an Entity Collided with the Block
 */
@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
    if (!entityIn.isRiding() && !entityIn.isBeingRidden() && entityIn.isNonBoss()) {
        MinecraftServer server = worldIn.getMinecraftServer();
        if (server != null && entityIn.timeUntilPortal <= 0) {
            PlayerList playerList = server.getPlayerList();
            int i = entityIn.dimension == DimensionType.OVERWORLD.getId() ? TakumiWorldCore.TAKUMI_WORLD.getId() : DimensionType.OVERWORLD.getId();
            TakumiTeleporter teleporter = new TakumiTeleporter(server.getWorld(i));
            teleporter.setTakumiPortal(entityIn, pos);
            entityIn.timeUntilPortal = entityIn.getPortalCooldown() * 2;
            if (entityIn instanceof EntityPlayerMP) {
                playerList.transferPlayerToDimension((EntityPlayerMP) entityIn, i, teleporter);
            } else {
                int origin = entityIn.dimension;
                entityIn.dimension = i;
                worldIn.removeEntityDangerously(entityIn);
                entityIn.isDead = false;
                playerList.transferEntityToWorld(entityIn, origin, server.getWorld(origin), server.getWorld(i), teleporter);
            }
        }
    }
}
Also used : PlayerList(net.minecraft.server.management.PlayerList) TakumiTeleporter(com.tntmodders.takumi.world.teleport.TakumiTeleporter) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) MinecraftServer(net.minecraft.server.MinecraftServer)

Aggregations

TakumiTeleporter (com.tntmodders.takumi.world.teleport.TakumiTeleporter)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 MinecraftServer (net.minecraft.server.MinecraftServer)2 PlayerList (net.minecraft.server.management.PlayerList)2 Teleporter (net.minecraft.world.Teleporter)1