当前位置: 首页>>代码示例>>Java>>正文


Java C00Handshake类代码示例

本文整理汇总了Java中net.minecraft.network.handshake.client.C00Handshake的典型用法代码示例。如果您正苦于以下问题:Java C00Handshake类的具体用法?Java C00Handshake怎么用?Java C00Handshake使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


C00Handshake类属于net.minecraft.network.handshake.client包,在下文中一共展示了C00Handshake类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onProcessHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:23,代码来源:MixinNetHandlerHandshakeTCP_Bungee.java

示例2: processHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
/**
 * 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());
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:41,代码来源:NetHandlerHandshakeTCP.java

示例3: oAuth

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
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();
}
 
开发者ID:Moudoux,项目名称:EMC,代码行数:15,代码来源:OAuth.java

示例4: processHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
/**
 * 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());
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:41,代码来源:NetHandlerHandshakeTCP.java

示例5: processHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
/**
 * 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;
    this.networkManager.setConnectionState(packetIn.getRequestedState());
    this.networkManager.setNetHandler(new NetHandlerLoginServer(this.mcServer, this.networkManager));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:NetHandlerHandshakeMemory.java

示例6: processHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
/**
 * 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());
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:41,代码来源:NetHandlerHandshakeTCP.java

示例7: connect

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
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()));
}
 
开发者ID:wizards-of-lua,项目名称:wizards-of-lua,代码行数:15,代码来源:ReconnectAction.java

示例8: onProcessHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
@Inject(method = "processHandshake", at = @At("HEAD"))
public void onProcessHandshake(C00Handshake packetIn, CallbackInfo ci) {
    IMixinNetworkManager info = (IMixinNetworkManager) this.networkManager;
    info.setProtocolVersion(packetIn.getProtocolVersion());
    info.setHostnamePinged(packetIn.ip);
    info.setPortPinged(packetIn.port);
}
 
开发者ID:NeptunePowered,项目名称:NeptuneCommon,代码行数:8,代码来源:MixinNetHandlerHandshakeTCP.java

示例9: processHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
/**
 * 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 p_147383_1_)
{
    switch (NetHandlerHandshakeTCP.SwitchEnumConnectionState.field_151291_a[p_147383_1_.func_149594_c().ordinal()])
    {
        case 1:
            this.field_147386_b.setConnectionState(EnumConnectionState.LOGIN);
            ChatComponentText var2;

            if (p_147383_1_.func_149595_d() > 4)
            {
                var2 = new ChatComponentText("Outdated server! I\'m still on 1.7.2");
                this.field_147386_b.scheduleOutboundPacket(new S00PacketDisconnect(var2), new GenericFutureListener[0]);
                this.field_147386_b.closeChannel(var2);
            }
            else if (p_147383_1_.func_149595_d() < 4)
            {
                var2 = new ChatComponentText("Outdated client! Please use 1.7.2");
                this.field_147386_b.scheduleOutboundPacket(new S00PacketDisconnect(var2), new GenericFutureListener[0]);
                this.field_147386_b.closeChannel(var2);
            }
            else
            {
                this.field_147386_b.setNetHandler(new NetHandlerLoginServer(this.field_147387_a, this.field_147386_b));
            }

            break;

        case 2:
            this.field_147386_b.setConnectionState(EnumConnectionState.STATUS);
            this.field_147386_b.setNetHandler(new NetHandlerStatusServer(this.field_147387_a, this.field_147386_b));
            break;

        default:
            throw new UnsupportedOperationException("Invalid intention " + p_147383_1_.func_149594_c());
    }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:42,代码来源:NetHandlerHandshakeTCP.java

示例10: onProcessHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
@Inject(method = "processHandshake", at = @At(value = "HEAD"))
private void onProcessHandshake(C00Handshake packetIn, CallbackInfo ci) {
    final IMixinNetworkManager info = (IMixinNetworkManager) this.networkManager;
    info.setProtocolVersion(packetIn.getProtocolVersion());
    info.setHostnamePinged(packetIn.ip);
    info.setPortPinged(packetIn.port);
}
 
开发者ID:NeptunePowered,项目名称:NeptuneMod,代码行数:8,代码来源:MixinNetHandlerHandshakeTCP.java

示例11: channelRead0

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, C00Handshake packet) throws Exception {
    if(!NettyChannelInitializer.serverStarting){
        ctx.fireChannelRead(packet);
        ctx.pipeline().remove(this);
    }else{
        ctx.writeAndFlush(new S00PacketDisconnect(new ChatComponentText("Server is still starting! Please wait before connecting!"))).addListener(ChannelFutureListener.CLOSE);
    }
}
 
开发者ID:nailed,项目名称:nailed,代码行数:10,代码来源:ServerStartingConnectionDestroyer.java

示例12: connect

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
public void connect(final String p_connect_1_, final int p_connect_2_)
{
    Realms.setConnectedToRealms(true);
    (new Thread("Realms-connect-task")
    {
        public void run()
        {
            InetAddress inetaddress = null;

            try
            {
                inetaddress = InetAddress.getByName(p_connect_1_);

                if (RealmsConnect.this.aborted)
                {
                    return;
                }

                RealmsConnect.this.connection = NetworkManager.func_181124_a(inetaddress, p_connect_2_, Minecraft.getMinecraft().gameSettings.func_181148_f());

                if (RealmsConnect.this.aborted)
                {
                    return;
                }

                RealmsConnect.this.connection.setNetHandler(new NetHandlerLoginClient(RealmsConnect.this.connection, Minecraft.getMinecraft(), RealmsConnect.this.onlineScreen.getProxy()));

                if (RealmsConnect.this.aborted)
                {
                    return;
                }

                RealmsConnect.this.connection.sendPacket(new C00Handshake(47, p_connect_1_, p_connect_2_, EnumConnectionState.LOGIN));

                if (RealmsConnect.this.aborted)
                {
                    return;
                }

                RealmsConnect.this.connection.sendPacket(new C00PacketLoginStart(Minecraft.getMinecraft().getSession().getProfile()));
            }
            catch (UnknownHostException unknownhostexception)
            {
                Realms.clearResourcePack();

                if (RealmsConnect.this.aborted)
                {
                    return;
                }

                RealmsConnect.LOGGER.error((String)"Couldn\'t connect to world", (Throwable)unknownhostexception);
                Minecraft.getMinecraft().getResourcePackRepository().func_148529_f();
                Realms.setScreen(new DisconnectedRealmsScreen(RealmsConnect.this.onlineScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {"Unknown host \'" + p_connect_1_ + "\'"})));
            }
            catch (Exception exception)
            {
                Realms.clearResourcePack();

                if (RealmsConnect.this.aborted)
                {
                    return;
                }

                RealmsConnect.LOGGER.error((String)"Couldn\'t connect to world", (Throwable)exception);
                String s = exception.toString();

                if (inetaddress != null)
                {
                    String s1 = inetaddress.toString() + ":" + p_connect_2_;
                    s = s.replaceAll(s1, "");
                }

                Realms.setScreen(new DisconnectedRealmsScreen(RealmsConnect.this.onlineScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {s})));
            }
        }
    }).start();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:78,代码来源:RealmsConnect.java

示例13: processHandshake

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
/**
 * 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)
{
    this.networkManager.setConnectionState(packetIn.getRequestedState());
    this.networkManager.setNetHandler(new NetHandlerLoginServer(this.mcServer, this.networkManager));
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:11,代码来源:NetHandlerHandshakeMemory.java

示例14: connect

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
private void connect(final String ip, final int port)
{
    logger.info("Connecting to " + ip + ", " + port);
    (new Thread("Server Connector #" + CONNECTION_ID.incrementAndGet())
    {
        public void run()
        {
            InetAddress inetaddress = null;

            try
            {
                if (GuiConnecting.this.cancel)
                {
                    return;
                }

                inetaddress = InetAddress.getByName(ip);
                GuiConnecting.this.networkManager = NetworkManager.func_181124_a(inetaddress, port, GuiConnecting.this.mc.gameSettings.func_181148_f());
                GuiConnecting.this.networkManager.setNetHandler(new NetHandlerLoginClient(GuiConnecting.this.networkManager, GuiConnecting.this.mc, GuiConnecting.this.previousGuiScreen));
                GuiConnecting.this.networkManager.sendPacket(new C00Handshake(47, ip, port, EnumConnectionState.LOGIN));
                GuiConnecting.this.networkManager.sendPacket(new C00PacketLoginStart(GuiConnecting.this.mc.getSession().getProfile()));
            }
            catch (UnknownHostException unknownhostexception)
            {
                if (GuiConnecting.this.cancel)
                {
                    return;
                }

                GuiConnecting.logger.error((String)"Couldn\'t connect to server", (Throwable)unknownhostexception);
                GuiConnecting.this.mc.displayGuiScreen(new GuiDisconnected(GuiConnecting.this.previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {"Unknown host"})));
            }
            catch (Exception exception)
            {
                if (GuiConnecting.this.cancel)
                {
                    return;
                }

                GuiConnecting.logger.error((String)"Couldn\'t connect to server", (Throwable)exception);
                String s = exception.toString();

                if (inetaddress != null)
                {
                    String s1 = inetaddress.toString() + ":" + port;
                    s = s.replaceAll(s1, "");
                }

                GuiConnecting.this.mc.displayGuiScreen(new GuiDisconnected(GuiConnecting.this.previousGuiScreen, "connect.failed", new ChatComponentTranslation("disconnect.genericReason", new Object[] {s})));
            }
        }
    }).start();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:54,代码来源:GuiConnecting.java

示例15: registerDefaults

import net.minecraft.network.handshake.client.C00Handshake; //导入依赖的package包/类
@DelayedRegistration(RegistrationPhase.PRE_INIT)
@Override
public void registerDefaults() {
    // Handshake
    register("handshake", "Handshake", PacketSide.SERVERBOUND, PacketPhase.HANDSHAKE, C00Handshake.class);

    // Entity
    clientbound("destroy_entities", "Destroy Entities", SPacketDestroyEntities.class, PacketControlFactory::createDestroyEntities);
    clientbound("entity_metadata", "Entity Metadata", SPacketEntityMetadata.class, PacketControlFactory::createEntityMetadata);
    clientbound("entity_velocity", "Entity Velocity", SPacketEntityVelocity.class);
    clientbound("spawn_experience_orb", "Spawn Experience Orb", SPacketSpawnExperienceOrb.class);
    clientbound("spawn_global_entity", "Spawn Global Entity", SPacketSpawnGlobalEntity.class);
    clientbound("spawn_mob", "Spawn Mob", SPacketSpawnMob.class);
    clientbound("spawn_object", "Spawn Object", SPacketSpawnObject.class, PacketControlFactory::createSpawnObject);
    clientbound("spawn_painting", "Spawn Painting", SPacketSpawnPainting.class);

    // Inventory
    clientbound("close_window", "Close Window", SPacketCloseWindow.class, PacketControlFactory::createCloseWindow);
    clientbound("confirm_transaction", "Confirm Transaction", SPacketConfirmTransaction.class, PacketControlFactory::createConfirmTransaction);
    clientbound("open_window", "Open Window", SPacketOpenWindow.class, PacketControlFactory::createOpenWindow);
    clientbound("set_slot", "Set Slot", SPacketSetSlot.class, PacketControlFactory::createSetSlot);
    clientbound("window_items", "Window Items", SPacketWindowItems.class, PacketControlFactory::createWindowItems);

    // Player
    clientbound("player_abilities", "Player Abilities", SPacketPlayerAbilities.class, PacketControlFactory::createPlayerAbilities);
    clientbound("spawn_player", "Spawn Player", SPacketSpawnPlayer.class);
    clientbound("use_bed", "Use Bed", SPacketUseBed.class, PacketControlFactory::createUseBed);
    clientbound("vehicle_position", "Vehicle Position", SPacketMoveVehicle.class);

    // World
    clientbound("custom_sound", "Custom Sound", SPacketCustomSound.class, PacketControlFactory::createCustomSound);
    clientbound("game_sound", "Game Sound", SPacketSoundEffect.class, PacketControlFactory::createGameSound);
    clientbound("open_sign_editor", "Open Sign Editor", SPacketSignEditorOpen.class, PacketControlFactory::createOpenSignEditor);
    clientbound("world_time", "World Time", SPacketTimeUpdate.class, PacketControlFactory::createWorldTime);

    // Client
    serverbound("click_window", "Click Window", CPacketClickWindow.class);
    serverbound("move_vehicle", "Move Vehicle", CPacketVehicleMove.class);
    serverbound("update_sign", "Update Sign", CPacketUpdateSign.class);
    serverbound("window_close", "Window Close", CPacketCloseWindow.class);
}
 
开发者ID:Guichaguri,项目名称:PacketControl,代码行数:42,代码来源:PacketRegistryModule.java


注:本文中的net.minecraft.network.handshake.client.C00Handshake类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。