Java 类net.minecraft.network.EnumConnectionState 实例源码

项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
int serverInitiateHandshake()
{
    // Send mod salutation to the client
    // This will be ignored by vanilla clients
    this.state = ConnectionState.AWAITING_HANDSHAKE;
    this.manager.channel().pipeline().addFirst("fml:vanilla_detector", new VanillaTimeoutWaiter());
    // Need to start the handler here, so we can send custompayload packets
    serverHandler = new NetHandlerPlayServer(scm.func_72365_p(), manager, player);
    this.netHandler = serverHandler;
    // NULL the play server here - we restore it further on. If not, there are packets sent before the login
    player.field_71135_a = null;
    // manually for the manager into the PLAY state, so we can send packets later
    this.manager.func_150723_a(EnumConnectionState.PLAY);

    // Return the dimension the player is in, so it can be pre-sent to the client in the ServerHello v2 packet
    // Requires some hackery to the serverconfigmanager and stuff for this to work
    NBTTagCompound playerNBT = scm.getPlayerNBT(player);
    if (playerNBT!=null)
    {
        return playerNBT.func_74762_e("Dimension");
    }
    else
    {
        return 0;
    }
}
项目:Resilience-Client-Source    文件:NetHandlerHandshakeMemory.java   
/**
 * Allows validation of the connection state transition. Parameters: from, to (connection state). Typically throws
 * IllegalStateException or UnsupportedOperationException if validation fails
 */
public void onConnectionStateTransition(EnumConnectionState p_147232_1_, EnumConnectionState p_147232_2_)
{
    Validate.validState(p_147232_2_ == EnumConnectionState.LOGIN || p_147232_2_ == EnumConnectionState.STATUS, "Unexpected protocol " + p_147232_2_, new Object[0]);

    switch (NetHandlerHandshakeMemory.SwitchEnumConnectionState.field_151263_a[p_147232_2_.ordinal()])
    {
        case 1:
            this.field_147384_b.setNetHandler(new NetHandlerLoginServer(this.field_147385_a, this.field_147384_b));
            break;

        case 2:
            throw new UnsupportedOperationException("NYI");

        default:
    }
}
项目:NeptuneMod    文件:MixinNetHandlerHandshakeTCP_Bungee.java   
@Inject(method = "processHandshake", at = @At(value = "HEAD"), cancellable = true)
private void onProcessHandshake(C00Handshake packetIn, CallbackInfo ci) {
    if (packetIn.getRequestedState().equals(EnumConnectionState.LOGIN)) {
        final String[] split = packetIn.ip.split("\00");

        if (split.length >= 3) {
            packetIn.ip = split[0];
            ((IMixinNetworkManager_Bungee) this.networkManager).setRemoteAddress(new InetSocketAddress(split[1],
                            ((InetSocketAddress) this.networkManager.getRemoteAddress()).getPort()));
            ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedUUID(UUIDTypeAdapter.fromString(split[2]));

            if (split.length == 4) {
                ((IMixinNetworkManager_Bungee) this.networkManager).setSpoofedProfile(GSON.fromJson(split[3], Property[].class));
            }
        } else {
            final ChatComponentText chatcomponenttext =
                    new ChatComponentText("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
            this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
            this.networkManager.closeChannel(chatcomponenttext);
        }
    }
}
项目:DecompiledMinecraft    文件:C00Handshake.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.protocolVersion = buf.readVarIntFromBuffer();
    this.ip = buf.readStringFromBuffer(255);
    this.port = buf.readUnsignedShort();
    this.requestedState = EnumConnectionState.getById(buf.readVarIntFromBuffer());
}
项目:DecompiledMinecraft    文件:NetHandlerHandshakeTCP.java   
/**
 * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
 * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
 * must pass a versioncheck or receive a disconnect otherwise
 */
public void processHandshake(C00Handshake packetIn)
{
    switch (packetIn.getRequestedState())
    {
        case LOGIN:
            this.networkManager.setConnectionState(EnumConnectionState.LOGIN);

            if (packetIn.getProtocolVersion() > 47)
            {
                ChatComponentText chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
                this.networkManager.closeChannel(chatcomponenttext);
            }
            else if (packetIn.getProtocolVersion() < 47)
            {
                ChatComponentText chatcomponenttext1 = new ChatComponentText("Outdated client! Please use 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext1));
                this.networkManager.closeChannel(chatcomponenttext1);
            }
            else
            {
                this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager));
            }

            break;

        case STATUS:
            this.networkManager.setConnectionState(EnumConnectionState.STATUS);
            this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager));
            break;

        default:
            throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState());
    }
}
项目:DecompiledMinecraft    文件:MessageSerializer.java   
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
    Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

    if (logger.isDebugEnabled())
    {
        logger.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", new Object[] {p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_encode_2_.getClass().getName()});
    }

    if (integer == null)
    {
        throw new IOException("Can\'t serialize unregistered packet");
    }
    else
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
        packetbuffer.writeVarIntToBuffer(integer.intValue());

        try
        {
            p_encode_2_.writePacketData(packetbuffer);
        }
        catch (Throwable throwable)
        {
            logger.error((Object)throwable);
        }
    }
}
项目:DecompiledMinecraft    文件:MessageDeserializer.java   
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
项目:DecompiledMinecraft    文件:C00Handshake.java   
public C00Handshake(int version, String ip, int port, EnumConnectionState requestedState)
{
    this.protocolVersion = version;
    this.ip = ip;
    this.port = port;
    this.requestedState = requestedState;
}
项目:DecompiledMinecraft    文件:C00Handshake.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.protocolVersion = buf.readVarIntFromBuffer();
    this.ip = buf.readStringFromBuffer(255);
    this.port = buf.readUnsignedShort();
    this.requestedState = EnumConnectionState.getById(buf.readVarIntFromBuffer());
}
项目:DecompiledMinecraft    文件:NetHandlerHandshakeTCP.java   
/**
 * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
 * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
 * must pass a versioncheck or receive a disconnect otherwise
 */
public void processHandshake(C00Handshake packetIn)
{
    switch (packetIn.getRequestedState())
    {
        case LOGIN:
            this.networkManager.setConnectionState(EnumConnectionState.LOGIN);

            if (packetIn.getProtocolVersion() > 47)
            {
                ChatComponentText chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
                this.networkManager.closeChannel(chatcomponenttext);
            }
            else if (packetIn.getProtocolVersion() < 47)
            {
                ChatComponentText chatcomponenttext1 = new ChatComponentText("Outdated client! Please use 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext1));
                this.networkManager.closeChannel(chatcomponenttext1);
            }
            else
            {
                this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager));
            }

            break;

        case STATUS:
            this.networkManager.setConnectionState(EnumConnectionState.STATUS);
            this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager));
            break;

        default:
            throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState());
    }
}
项目:DecompiledMinecraft    文件:MessageSerializer.java   
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
    Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

    if (logger.isDebugEnabled())
    {
        logger.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", new Object[] {p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_encode_2_.getClass().getName()});
    }

    if (integer == null)
    {
        throw new IOException("Can\'t serialize unregistered packet");
    }
    else
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
        packetbuffer.writeVarIntToBuffer(integer.intValue());

        try
        {
            p_encode_2_.writePacketData(packetbuffer);
        }
        catch (Throwable throwable)
        {
            logger.error((Object)throwable);
        }
    }
}
项目:DecompiledMinecraft    文件:MessageDeserializer.java   
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
项目:BaseClient    文件:C00Handshake.java   
public C00Handshake(int version, String ip, int port, EnumConnectionState requestedState)
{
    this.protocolVersion = version;
    this.ip = ip;
    this.port = port;
    this.requestedState = requestedState;
}
项目:BaseClient    文件:C00Handshake.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.protocolVersion = buf.readVarIntFromBuffer();
    this.ip = buf.readStringFromBuffer(255);
    this.port = buf.readUnsignedShort();
    this.requestedState = EnumConnectionState.getById(buf.readVarIntFromBuffer());
}
项目:BaseClient    文件:NetHandlerHandshakeTCP.java   
/**
 * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
 * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
 * must pass a versioncheck or receive a disconnect otherwise
 */
public void processHandshake(C00Handshake packetIn)
{
    switch (packetIn.getRequestedState())
    {
        case LOGIN:
            this.networkManager.setConnectionState(EnumConnectionState.LOGIN);

            if (packetIn.getProtocolVersion() > 47)
            {
                ChatComponentText chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
                this.networkManager.closeChannel(chatcomponenttext);
            }
            else if (packetIn.getProtocolVersion() < 47)
            {
                ChatComponentText chatcomponenttext1 = new ChatComponentText("Outdated client! Please use 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext1));
                this.networkManager.closeChannel(chatcomponenttext1);
            }
            else
            {
                this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager));
            }

            break;

        case STATUS:
            this.networkManager.setConnectionState(EnumConnectionState.STATUS);
            this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager));
            break;

        default:
            throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState());
    }
}
项目:BaseClient    文件:MessageSerializer.java   
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
    Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

    if (logger.isDebugEnabled())
    {
        logger.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", new Object[] {p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_encode_2_.getClass().getName()});
    }

    if (integer == null)
    {
        throw new IOException("Can\'t serialize unregistered packet");
    }
    else
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
        packetbuffer.writeVarIntToBuffer(integer.intValue());

        try
        {
            p_encode_2_.writePacketData(packetbuffer);
        }
        catch (Throwable throwable)
        {
            logger.error((Object)throwable);
        }
    }
}
项目:BaseClient    文件:MessageDeserializer.java   
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
项目:BaseClient    文件:C00Handshake.java   
public C00Handshake(int version, String ip, int port, EnumConnectionState requestedState)
{
    this.protocolVersion = version;
    this.ip = ip;
    this.port = port;
    this.requestedState = requestedState;
}
项目:BaseClient    文件:C00Handshake.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.protocolVersion = buf.readVarIntFromBuffer();
    this.ip = buf.readStringFromBuffer(255);
    this.port = buf.readUnsignedShort();
    this.requestedState = EnumConnectionState.getById(buf.readVarIntFromBuffer());
}
项目:BaseClient    文件:NetHandlerHandshakeTCP.java   
/**
 * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
 * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
 * must pass a versioncheck or receive a disconnect otherwise
 */
public void processHandshake(C00Handshake packetIn)
{
    switch (packetIn.getRequestedState())
    {
        case LOGIN:
            this.networkManager.setConnectionState(EnumConnectionState.LOGIN);

            if (packetIn.getProtocolVersion() > 47)
            {
                ChatComponentText chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext));
                this.networkManager.closeChannel(chatcomponenttext);
            }
            else if (packetIn.getProtocolVersion() < 47)
            {
                ChatComponentText chatcomponenttext1 = new ChatComponentText("Outdated client! Please use 1.8.8");
                this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext1));
                this.networkManager.closeChannel(chatcomponenttext1);
            }
            else
            {
                this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager));
            }

            break;

        case STATUS:
            this.networkManager.setConnectionState(EnumConnectionState.STATUS);
            this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager));
            break;

        default:
            throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState());
    }
}
项目:BaseClient    文件:MessageSerializer.java   
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
    Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

    if (logger.isDebugEnabled())
    {
        logger.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", new Object[] {p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_encode_2_.getClass().getName()});
    }

    if (integer == null)
    {
        throw new IOException("Can\'t serialize unregistered packet");
    }
    else
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
        packetbuffer.writeVarIntToBuffer(integer.intValue());

        try
        {
            p_encode_2_.writePacketData(packetbuffer);
        }
        catch (Throwable throwable)
        {
            logger.error((Object)throwable);
        }
    }
}
项目:BaseClient    文件:MessageDeserializer.java   
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
项目:PacketControl    文件:PacketUtils.java   
public static EnumConnectionState toState(PacketPhase phase) {
    switch(phase) {
        case HANDSHAKE:
            return EnumConnectionState.HANDSHAKING;
        case STATUS:
            return EnumConnectionState.STATUS;
        case LOGIN:
            return EnumConnectionState.LOGIN;
        case PLAY:
            return EnumConnectionState.PLAY;
    }
    return EnumConnectionState.LOGIN;
}
项目:PacketControl    文件:PacketUtils.java   
public static PacketPhase fromState(EnumConnectionState phase) {
    switch(phase) {
        case HANDSHAKING:
            return PacketPhase.HANDSHAKE;
        case STATUS:
            return PacketPhase.STATUS;
        case LOGIN:
            return PacketPhase.LOGIN;
        case PLAY:
            return PacketPhase.PLAY;
    }
    return PacketPhase.LOGIN;
}
项目:EMC    文件:OAuthNetHandler.java   
@Override
public void handleLoginSuccess(SPacketLoginSuccess packetIn) {
    this.gameProfile = packetIn.getProfile();
    this.networkManager.setConnectionState(EnumConnectionState.PLAY);
    this.networkManager.setNetHandler(new OAuthNetHandlerPlayClient(this.mc, this.previousGuiScreen,
            this.networkManager, this.gameProfile, callback));
}
项目:EMC    文件:OAuth.java   
public static void oAuth(OAuthCallback callback) {
    new Thread(() -> {
        try {
            InetAddress inetaddress = InetAddress.getByName(ip);
            OAuthNetworkManager manager = OAuthNetworkManager.createNetworkManagerAndConnect(inetaddress, port,
                    Minecraft.getMinecraft().gameSettings.isUsingNativeTransport(), callback);
            manager.setNetHandler(new OAuthNetHandler(manager, Minecraft.getMinecraft(), null, callback));
            manager.sendPacket(new C00Handshake(ip, port, EnumConnectionState.LOGIN));
            manager.sendPacket(new CPacketLoginStart(Minecraft.getMinecraft().getSession().getProfile()));
        } catch (Exception ex) {
            callback.callback(false, "", "");
        }
    }).start();
}
项目:Backmemed    文件:C00Handshake.java   
public C00Handshake(int version, String ip, int port, EnumConnectionState requestedState)
{
    this.protocolVersion = version;
    this.ip = ip;
    this.port = port;
    this.requestedState = requestedState;
}
项目:Backmemed    文件:C00Handshake.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.protocolVersion = buf.readVarIntFromBuffer();
    this.ip = buf.readStringFromBuffer(255);
    this.port = buf.readUnsignedShort();
    this.requestedState = EnumConnectionState.getById(buf.readVarIntFromBuffer());
}
项目:Backmemed    文件:NetHandlerHandshakeTCP.java   
/**
 * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
 * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
 * must pass a versioncheck or receive a disconnect otherwise
 */
public void processHandshake(C00Handshake packetIn)
{
    switch (packetIn.getRequestedState())
    {
        case LOGIN:
            this.networkManager.setConnectionState(EnumConnectionState.LOGIN);

            if (packetIn.getProtocolVersion() > 316)
            {
                TextComponentString textcomponentstring = new TextComponentString("Outdated server! I\'m still on 1.11.2");
                this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring));
                this.networkManager.closeChannel(textcomponentstring);
            }
            else if (packetIn.getProtocolVersion() < 316)
            {
                TextComponentString textcomponentstring1 = new TextComponentString("Outdated client! Please use 1.11.2");
                this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring1));
                this.networkManager.closeChannel(textcomponentstring1);
            }
            else
            {
                this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager));
            }

            break;

        case STATUS:
            this.networkManager.setConnectionState(EnumConnectionState.STATUS);
            this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager));
            break;

        default:
            throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState());
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
void clientListenForServerHandshake()
{
    manager.setConnectionState(EnumConnectionState.PLAY);
    //FMLCommonHandler.instance().waitForPlayClient();
    this.netHandler = FMLCommonHandler.instance().getClientPlayHandler();
    this.state = ConnectionState.AWAITING_HANDSHAKE;
}
项目:CustomWorldGen    文件:C00Handshake.java   
@SideOnly(Side.CLIENT)
public C00Handshake(int version, String ip, int port, EnumConnectionState requestedState)
{
    this.protocolVersion = version;
    this.ip = ip;
    this.port = port;
    this.requestedState = requestedState;
}
项目:CustomWorldGen    文件:C00Handshake.java   
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.protocolVersion = buf.readVarIntFromBuffer();
    this.ip = buf.readStringFromBuffer(255);
    this.port = buf.readUnsignedShort();
    this.requestedState = EnumConnectionState.getById(buf.readVarIntFromBuffer());
    this.hasFMLMarker = this.ip.contains("\0FML\0");
    this.ip = this.ip.split("\0")[0];
}
项目:CustomWorldGen    文件:NetHandlerLoginClient.java   
public void handleLoginSuccess(SPacketLoginSuccess packetIn)
{
    this.gameProfile = packetIn.getProfile();
    this.networkManager.setConnectionState(EnumConnectionState.PLAY);
    net.minecraftforge.fml.common.network.internal.FMLNetworkHandler.fmlClientHandshake(this.networkManager);
    NetHandlerPlayClient nhpc = new NetHandlerPlayClient(this.mc, this.previousGuiScreen, this.networkManager, this.gameProfile);
    this.networkManager.setNetHandler(nhpc);
    net.minecraftforge.fml.client.FMLClientHandler.instance().setPlayClient(nhpc);
}
项目:CustomWorldGen    文件:NetHandlerHandshakeTCP.java   
/**
 * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The
 * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention
 * must pass a versioncheck or receive a disconnect otherwise
 */
public void processHandshake(C00Handshake packetIn)
{
    if (!net.minecraftforge.fml.common.FMLCommonHandler.instance().handleServerHandshake(packetIn, this.networkManager)) return;

    switch (packetIn.getRequestedState())
    {
        case LOGIN:
            this.networkManager.setConnectionState(EnumConnectionState.LOGIN);

            if (packetIn.getProtocolVersion() > 210)
            {
                TextComponentString textcomponentstring = new TextComponentString("Outdated server! I\'m still on 1.10.2");
                this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring));
                this.networkManager.closeChannel(textcomponentstring);
            }
            else if (packetIn.getProtocolVersion() < 210)
            {
                TextComponentString textcomponentstring1 = new TextComponentString("Outdated client! Please use 1.10.2");
                this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring1));
                this.networkManager.closeChannel(textcomponentstring1);
            }
            else
            {
                this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager));
            }

            break;
        case STATUS:
            this.networkManager.setConnectionState(EnumConnectionState.STATUS);
            this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager));
            break;
        default:
            throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState());
    }
}
项目:wizards-of-lua    文件:ReconnectAction.java   
private void connect(String ip, int port) throws UnknownHostException {
  InetAddress inetaddress = InetAddress.getByName(ip);
  Minecraft minecraft = Minecraft.getMinecraft();
  boolean isUsingNativeTransport = minecraft.gameSettings.isUsingNativeTransport();
  GuiScreen previousGuiScreen = null;
  // The following code is copied from
  // net.minecraft.client.multiplayer.GuiConnecting.connect(String, int)
  NetworkManager networkManager =
      NetworkManager.createNetworkManagerAndConnect(inetaddress, port, isUsingNativeTransport);
  networkManager
      .setNetHandler(new NetHandlerLoginClient(networkManager, minecraft, previousGuiScreen));
  networkManager.sendPacket(new C00Handshake(316, ip, port, EnumConnectionState.LOGIN, true));
  networkManager.sendPacket(new CPacketLoginStart(minecraft.getSession().getProfile()));
}
项目:TRHS_Club_Mod_2016    文件:NetworkDispatcher.java   
void clientListenForServerHandshake()
{
    manager.func_150723_a(EnumConnectionState.PLAY);
    FMLCommonHandler.instance().waitForPlayClient();
    this.netHandler = FMLCommonHandler.instance().getClientPlayHandler();
    this.state = ConnectionState.AWAITING_HANDSHAKE;
}
项目:Factorization    文件:PacketProxyingPlayer.java   
void preinitWrapping() {
    playerNetServerHandler = new NetHandlerPlayServer(mcServer, networkManager, this);
    playerNetServerHandler.netManager.channel().attr(NetworkDispatcher.FML_DISPATCHER).set(new NetworkDispatcher(this.networkManager));
    //Compare net.minecraftforge.fml.common.network.FMLOutboundHandler.OutboundTarget.PLAYER.{...}.selectNetworks(Object, ChannelHandlerContext, FMLProxyPacket)
    playerNetServerHandler.netManager.setConnectionState(EnumConnectionState.PLAY);
    /* (misc notes here)
     * We don't need to touch NetworkDispatcher; we need a NetworkManager.
     *
     * NetworkManager.scheduleOutboundPacket is too early I think?
     * What we really want is its channel.
     */
}
项目:CauldronGit    文件:NetworkDispatcher.java   
void serverInitiateHandshake()
{
    // Send mod salutation to the client
    // This will be ignored by vanilla clients
    this.state = ConnectionState.AWAITING_HANDSHAKE;
    this.manager.channel().pipeline().addFirst("fml:vanilla_detector", new VanillaTimeoutWaiter());
    // Need to start the handler here, so we can send custompayload packets
    serverHandler = new NetHandlerPlayServer(scm.getServerInstance(), manager, player);
    this.netHandler = serverHandler;
    // NULL the play server here - we restore it further on. If not, there are packets sent before the login
    player.playerNetServerHandler = null;
    // manually for the manager into the PLAY state, so we can send packets later
    this.manager.setConnectionState(EnumConnectionState.PLAY);
}
项目:CauldronGit    文件:NetworkDispatcher.java   
void clientListenForServerHandshake()
{
    manager.setConnectionState(EnumConnectionState.PLAY);
    FMLCommonHandler.instance().waitForPlayClient();
    this.netHandler = FMLCommonHandler.instance().getClientPlayHandler();
    this.state = ConnectionState.AWAITING_HANDSHAKE;
}
项目:Resilience-Client-Source    文件:C00Handshake.java   
public C00Handshake(int p_i45266_1_, String p_i45266_2_, int p_i45266_3_, EnumConnectionState p_i45266_4_)
{
    this.field_149600_a = p_i45266_1_;
    this.field_149598_b = p_i45266_2_;
    this.field_149599_c = p_i45266_3_;
    this.field_149597_d = p_i45266_4_;
}