Exemplo n.º 1
0
        public void connect(string address, int port)
        {
            registerPacket(PacketType.KeepAlive, typeof(Packet_KeepAlive));
            registerPacket(PacketType.Login, typeof(Packet_Login));
            registerPacket(PacketType.Handshake, typeof(Packet_Handshake));
            registerPacket(PacketType.Chat, typeof(Packet_Chat));
            registerPacket(PacketType.Time, typeof(Packet_Time));
            registerPacket(PacketType.EntityEquipment, typeof(Packet_EntityEquipment));
            registerPacket(PacketType.SpawnPosition, typeof(Packet_SpawnPosition));
            registerPacket(PacketType.UseEntity, typeof(Packet_UseEntity));
            registerPacket(PacketType.UpdateHealth, typeof(Packet_UpdateHealth));
            registerPacket(PacketType.Respawn, typeof(Packet_Respawn));
            registerPacket(PacketType.Flying, typeof(Packet_Flying));
            registerPacket(PacketType.PlayerPos, typeof(Packet_PlayerPos));
            registerPacket(PacketType.PlayerLook, typeof(Packet_PlayerLook));
            registerPacket(PacketType.PlayerPosAndLook, typeof(Packet_PlayerPosAndLook));
            registerPacket(PacketType.PlayerDigging, typeof(Packet_PlayerDigging));
            registerPacket(PacketType.HeldItemChange, typeof(Packet_HoldingChange));
            registerPacket(PacketType.UseBed, typeof(Packet_UseBed));
            registerPacket(PacketType.Animation, typeof(Packet_Animation));
            registerPacket(PacketType.EntityAction, typeof(Packet_EntityAction));
            registerPacket(PacketType.NamedEntitySpawn, typeof(Packet_NamedEntitySpawn));
            registerPacket(PacketType.PickupSpawn, typeof(Packet_PickupSpawn));
            registerPacket(PacketType.CollectItem, typeof(Packet_CollectItem));
            registerPacket(PacketType.AddObjVehicle, typeof(Packet_AddObjVehicle));
            registerPacket(PacketType.MobSpawn, typeof(Packet_MobSpawn));
            registerPacket(PacketType.EntityPainting, typeof(Packet_EntityPainting));
            registerPacket(PacketType.ExpOrb, typeof(Packet_ExpOrb));
            registerPacket(PacketType.EntityVel, typeof(Packet_EntityVel));
            registerPacket(PacketType.DestroyEntity, typeof(Packet_DestroyEntity));
            registerPacket(PacketType.Entity, typeof(Packet_Entity));
            registerPacket(PacketType.EntityRelativeMove, typeof(Packet_EntityRelativeMove));
            registerPacket(PacketType.EntityLook, typeof(Packet_EntityLook));
            registerPacket(PacketType.EntityLookAndRelativeMove, typeof(Packet_EntityLookAndRelativeMove));
            registerPacket(PacketType.EntityTeleport, typeof(Packet_EntityTeleport));
            registerPacket(PacketType.EntityHeadLook, typeof(Packet_EntityHeadLook));
            registerPacket(PacketType.EntityStatus, typeof(Packet_EntityStatus));
            registerPacket(PacketType.AttachEntity, typeof(Packet_AttachEntity));
            registerPacket(PacketType.EntityMetadata, typeof(Packet_EntityMetadata));
            registerPacket(PacketType.EntityEffect, typeof(Packet_EntityEffect));
            registerPacket(PacketType.RemoveEntityEffect, typeof(Packet_RemoveEntityEffect));
            registerPacket(PacketType.Experience, typeof(Packet_Experience));
            registerPacket(PacketType.EntityProperties, typeof(Packet_EntityProperties));
            //registerPacket(PacketType.PreChunk, typeof(Packet_PreChunk));
            registerPacket(PacketType.MapChunk, typeof(Packet_MapChunk));
            registerPacket(PacketType.MultiBlockChange, typeof(Packet_MultiBlockChange));
            registerPacket(PacketType.BlockChange, typeof(Packet_BlockChange));
            registerPacket(PacketType.BlockAction, typeof(Packet_BlockAction));
            registerPacket(PacketType.BlockBreakAnimation, typeof(Packet_BlockBreakingAnimation));
            registerPacket(PacketType.MapChunkBulk, typeof(Packet_MapChunkBulk));
            registerPacket(PacketType.Explosion, typeof(Packet_Explosion));
            registerPacket(PacketType.SoundEffect, typeof(Packet_SoundEffect));
            registerPacket(PacketType.NamedSoundEffect, typeof(Packet_NamedSoundEffect));
            registerPacket(PacketType.GameStateChange, typeof(Packet_GameStateChange));
            //registerPacket(PacketType.NewOrInvalidState, typeof(Packet_NewOrInvalidState));
            registerPacket(PacketType.Thunder, typeof(Packet_Thunder));
            registerPacket(PacketType.OpenWnd, typeof(Packet_OpenWnd));
            registerPacket(PacketType.CloseWnd, typeof(Packet_CloseWnd));
            registerPacket(PacketType.WndClick, typeof(Packet_WndClick));
            registerPacket(PacketType.SetSlot, typeof(Packet_SetSlot));
            registerPacket(PacketType.WndItems, typeof(Packet_WndItems));
            registerPacket(PacketType.UpdateWndProp, typeof(Packet_UpdateWndProp));
            registerPacket(PacketType.Transaction, typeof(Packet_Transaction));
            registerPacket(PacketType.CreativeInventoryAction, typeof(Packet_CreativeInventoryAction));
            registerPacket(PacketType.UpdateSign, typeof(Packet_UpdateSign));
            registerPacket(PacketType.ItemData, typeof(Packet_ItemData));
            registerPacket(PacketType.EntityTileUpdate, typeof(Packet_EntityTileUpdate));
            registerPacket(PacketType.IncStatistic, typeof(Packet_IncStatistic));
            registerPacket(PacketType.PlayerListItem, typeof(Packet_PlayerListItem));
            registerPacket(PacketType.PlayerAbilities, typeof(Packet_PlayerAbilities));
            registerPacket(PacketType.ClientStatus, typeof(Packet_ClientStatus));
            registerPacket(PacketType.PluginMessage, typeof(Packet_PluginMessage));
            registerPacket(PacketType.EncryptionResponse, typeof(Packet_EncryptionResponse));
            registerPacket(PacketType.EncryptionRequest, typeof(Packet_EncryptionRequest));
            //registerPacket(PacketType.ServerListPing, typeof(Packet_ServerListPing));
            registerPacket(PacketType.Kick, typeof(Packet_Kick));

            //PacketMap.Initialize();
            if (File.Exists("Out.bin"))
                File.Delete("Out.bin");
            output("Connecting...");
            packetReceived += new packetReceivedEventHandler(onPacketReceived);
            client.NoDelay = true;
            client.Connect(address, port);
            str = client.GetStream();

            Thread packetReceiverThread = new Thread(new ThreadStart(packetReceiver));
            packetReceiverThread.Name = "packetReceiver";
            //packetReceiverThread.Start();

            Thread packetHandlerThread = new Thread(new ThreadStart(packetHandler));
            packetHandlerThread.Name = "packetHandler";
            packetHandlerThread.Start();

            Packet_Handshake packet = new Packet_Handshake();
            packet.ProtocolVersion = Protocol;
            packet.Username = name;
            packet.Host = address;
            packet.Port = port;

            packets.Enqueue(packet);
        }
Exemplo n.º 2
0
        public void connect(string address, int port)
        {
            registerPacket(PacketType.KeepAlive, typeof(Packet_KeepAlive));
            registerPacket(PacketType.Login, typeof(Packet_Login));
            registerPacket(PacketType.Handshake, typeof(Packet_Handshake));
            registerPacket(PacketType.Chat, typeof(Packet_Chat));
            registerPacket(PacketType.Time, typeof(Packet_Time));
            registerPacket(PacketType.EntityEquipment, typeof(Packet_EntityEquipment));
            registerPacket(PacketType.SpawnPosition, typeof(Packet_SpawnPosition));
            registerPacket(PacketType.UseEntity, typeof(Packet_UseEntity));
            registerPacket(PacketType.UpdateHealth, typeof(Packet_UpdateHealth));
            registerPacket(PacketType.Respawn, typeof(Packet_Respawn));
            registerPacket(PacketType.Flying, typeof(Packet_Flying));
            registerPacket(PacketType.PlayerPos, typeof(Packet_PlayerPos));
            registerPacket(PacketType.PlayerLook, typeof(Packet_PlayerLook));
            registerPacket(PacketType.PlayerPosAndLook, typeof(Packet_PlayerPosAndLook));
            registerPacket(PacketType.PlayerDigging, typeof(Packet_PlayerDigging));
            registerPacket(PacketType.HeldItemChange, typeof(Packet_HoldingChange));
            registerPacket(PacketType.UseBed, typeof(Packet_UseBed));
            registerPacket(PacketType.Animation, typeof(Packet_Animation));
            registerPacket(PacketType.EntityAction, typeof(Packet_EntityAction));
            registerPacket(PacketType.NamedEntitySpawn, typeof(Packet_NamedEntitySpawn));
            registerPacket(PacketType.PickupSpawn, typeof(Packet_PickupSpawn));
            registerPacket(PacketType.CollectItem, typeof(Packet_CollectItem));
            registerPacket(PacketType.AddObjVehicle, typeof(Packet_AddObjVehicle));
            registerPacket(PacketType.MobSpawn, typeof(Packet_MobSpawn));
            registerPacket(PacketType.EntityPainting, typeof(Packet_EntityPainting));
            registerPacket(PacketType.ExpOrb, typeof(Packet_ExpOrb));
            registerPacket(PacketType.EntityVel, typeof(Packet_EntityVel));
            registerPacket(PacketType.DestroyEntity, typeof(Packet_DestroyEntity));
            registerPacket(PacketType.Entity, typeof(Packet_Entity));
            registerPacket(PacketType.EntityRelativeMove, typeof(Packet_EntityRelativeMove));
            registerPacket(PacketType.EntityLook, typeof(Packet_EntityLook));
            registerPacket(PacketType.EntityLookAndRelativeMove, typeof(Packet_EntityLookAndRelativeMove));
            registerPacket(PacketType.EntityTeleport, typeof(Packet_EntityTeleport));
            registerPacket(PacketType.EntityHeadLook, typeof(Packet_EntityHeadLook));
            registerPacket(PacketType.EntityStatus, typeof(Packet_EntityStatus));
            registerPacket(PacketType.AttachEntity, typeof(Packet_AttachEntity));
            registerPacket(PacketType.EntityMetadata, typeof(Packet_EntityMetadata));
            registerPacket(PacketType.EntityEffect, typeof(Packet_EntityEffect));
            registerPacket(PacketType.RemoveEntityEffect, typeof(Packet_RemoveEntityEffect));
            registerPacket(PacketType.Experience, typeof(Packet_Experience));
            registerPacket(PacketType.EntityProperties, typeof(Packet_EntityProperties));
            //registerPacket(PacketType.PreChunk, typeof(Packet_PreChunk));
            registerPacket(PacketType.MapChunk, typeof(Packet_MapChunk));
            registerPacket(PacketType.MultiBlockChange, typeof(Packet_MultiBlockChange));
            registerPacket(PacketType.BlockChange, typeof(Packet_BlockChange));
            registerPacket(PacketType.BlockAction, typeof(Packet_BlockAction));
            registerPacket(PacketType.BlockBreakAnimation, typeof(Packet_BlockBreakingAnimation));
            registerPacket(PacketType.MapChunkBulk, typeof(Packet_MapChunkBulk));
            registerPacket(PacketType.Explosion, typeof(Packet_Explosion));
            registerPacket(PacketType.SoundEffect, typeof(Packet_SoundEffect));
            registerPacket(PacketType.NamedSoundEffect, typeof(Packet_NamedSoundEffect));
            registerPacket(PacketType.GameStateChange, typeof(Packet_GameStateChange));
            //registerPacket(PacketType.NewOrInvalidState, typeof(Packet_NewOrInvalidState));
            registerPacket(PacketType.Thunder, typeof(Packet_Thunder));
            registerPacket(PacketType.OpenWnd, typeof(Packet_OpenWnd));
            registerPacket(PacketType.CloseWnd, typeof(Packet_CloseWnd));
            registerPacket(PacketType.WndClick, typeof(Packet_WndClick));
            registerPacket(PacketType.SetSlot, typeof(Packet_SetSlot));
            registerPacket(PacketType.WndItems, typeof(Packet_WndItems));
            registerPacket(PacketType.UpdateWndProp, typeof(Packet_UpdateWndProp));
            registerPacket(PacketType.Transaction, typeof(Packet_Transaction));
            registerPacket(PacketType.CreativeInventoryAction, typeof(Packet_CreativeInventoryAction));
            registerPacket(PacketType.UpdateSign, typeof(Packet_UpdateSign));
            registerPacket(PacketType.ItemData, typeof(Packet_ItemData));
            registerPacket(PacketType.EntityTileUpdate, typeof(Packet_EntityTileUpdate));
            registerPacket(PacketType.IncStatistic, typeof(Packet_IncStatistic));
            registerPacket(PacketType.PlayerListItem, typeof(Packet_PlayerListItem));
            registerPacket(PacketType.PlayerAbilities, typeof(Packet_PlayerAbilities));
            registerPacket(PacketType.ClientStatus, typeof(Packet_ClientStatus));
            registerPacket(PacketType.PluginMessage, typeof(Packet_PluginMessage));
            registerPacket(PacketType.EncryptionResponse, typeof(Packet_EncryptionResponse));
            registerPacket(PacketType.EncryptionRequest, typeof(Packet_EncryptionRequest));
            //registerPacket(PacketType.ServerListPing, typeof(Packet_ServerListPing));
            registerPacket(PacketType.Kick, typeof(Packet_Kick));


            //PacketMap.Initialize();
            if (File.Exists("Out.bin"))
            {
                File.Delete("Out.bin");
            }
            output("Connecting...");
            packetReceived += new packetReceivedEventHandler(onPacketReceived);
            client.NoDelay  = true;
            client.Connect(address, port);
            str = client.GetStream();

            Thread packetReceiverThread = new Thread(new ThreadStart(packetReceiver));

            packetReceiverThread.Name = "packetReceiver";
            //packetReceiverThread.Start();

            Thread packetHandlerThread = new Thread(new ThreadStart(packetHandler));

            packetHandlerThread.Name = "packetHandler";
            packetHandlerThread.Start();

            Packet_Handshake packet = new Packet_Handshake();

            packet.ProtocolVersion = Protocol;
            packet.Username        = name;
            packet.Host            = address;
            packet.Port            = port;

            packets.Enqueue(packet);
        }