/// <summary>
        /// this is the execution method which gets executed later
        /// to get more arguments use the internal regArgs variable
        /// </summary>
        /// <param name="arg1">first argument after the command in the string</param>
        /// <param name="arg2">second argument after the command in the string</param>
        /// <param name="arg3">third argument after the command in the string</param>
        /// <param name="arg4">fourth argument after the command in the string</param>
        /// <returns>remember to set the command result in every return case</returns>
        public override CommandResult Execute(String arg1, String arg2, String arg3, String arg4)
        {
            Server.SendExecuteResponse(TriggerPlayer, ClientUser.LastEntityId.ToString());

            PacketGenerator gen = new PacketGenerator();
            gen.Add(ClientUser.LastEntityId);
            gen.Add(100);
            gen.Add(1000);
            gen.Add(100);
            gen.Add((byte)0);
            gen.Add((byte)0);

            ClientSocket c = Client as ClientSocket;
            (Server as ServerSocket).SendPacketToClient(PacketBytes._0x22_EntityTeleport_0x22, TriggerPlayer, gen.ToByteArray());

            XPosition pos = Client.Position;
            PacketGenerator teleportData = new PacketGenerator();
            teleportData.Add(100.0);// X
            teleportData.Add(999.5); // Y
            teleportData.Add(1000.0); // Stance
            teleportData.Add(100.0);  // Z
            teleportData.Add(pos.Rotation);
            teleportData.Add(pos.Pitch);
            teleportData.Add(pos.Unkown);
            Client.SendPacket(Vitt.Andre.TCPTunnelLib.Vitt.Andre.Tunnel.PacketBytes._0x0D_PlayerMoveAndLook_0x0D, teleportData.ToByteArray());

            (Server as ServerSocket).SendPacketToClient(PacketBytes._0x22_EntityTeleport_0x22, TriggerPlayer, gen.ToByteArray());

            return new CommandResult(true, string.Format("{0} executed by {1}", Name, TriggerPlayer));
        }
        private void InternalThread()
        {
            bool flag = false;
            byte[] buffer = new byte[0x100];
            while (this.internalSock.Connected && this.externalSock.Connected)
            {
                try
                {
                    if (!flag)
                    {
                        buffer = new byte[1];
                        if (this.internalSock.Receive(buffer) > 0)
                        {
                            // server to client
                            byte fByte = buffer[0];
                            this.intBuffer = new byte[] { fByte };
                            PacketSizes bytes = PacketSizes.Minus_2;
                            PacketBytes firstByte = (PacketBytes)fByte;

                            bytes = MinecraftEnums.GetPacketSize(firstByte);

                            //if (bytes == PacketSizes.Minus_2)
                            //{
                            //    databaseWorker.AddAction(new DatabaseAction(() =>
                            //    {
                            //        Log.Append(this, "Unkown Packet logged " + ((int)firstByte).ToString(), Log.PacketsLog);
                            //    }));
                            //    bytes = PacketSizes.Minus_1;
                            //}

                            bool flag2 = true;
                            if (bytes == PacketSizes.Minus_1)
                            {
                                switch (firstByte)
                                {
                                    case PacketBytes._0x33_ChunkMap_0x33:
                                        this.ReceiveBytes(this.internalSock, 13);
                                        this.ReceiveBytes(this.internalSock, ByteArythmetic.GetInt32(this.ReceiveBytes(this.internalSock, 4), 0));
                                        break;
                                    case PacketBytes._0x34_MultiBlockChange_0x34:
                                        this.ReceiveBytes(this.internalSock, 8);
                                        this.ReceiveBytes(this.internalSock, ByteArythmetic.GetInt16(this.ReceiveBytes(this.internalSock, 2), 0) * 4);
                                        break;

                                    case PacketBytes._0xFF_Disconnect_0xFF:
                                        this.Disconnect(this.ReceiveString(this.internalSock));
                                        break;

                                    case PacketBytes._0x01_Login_0x01:
                                        this.ReceiveBytes(this.internalSock, 4);
                                        this.ReceiveString(this.internalSock);
                                        // this.ReceiveString(this.internalSock);// Update 1.5 removed string
                                        this.ReceiveBytes(this.internalSock, 8);
                                        this.ReceiveBytes(this.internalSock, 1);
                                        break;

                                    case PacketBytes._0x02_Handshake_0x02:
                                        this.ReceiveString(this.internalSock);
                                        break;

                                    case PacketBytes._0x03_Chat_0x03:
                                        String chat = this.ReceiveString(this.internalSock);
                                        String playerJoinedString = String.Format("§e{0} joined the game.", name);
                                        if (chat == playerJoinedString)
                                        {
                                            flag2 = false;
                                        }

                                        break;
                                    case PacketBytes._0x04_UpdateTime_0x04:
                                        serverSocket.RealTimeOfDay = ByteArythmetic.GetInt64(buffer, 0);
                                        break;

                                        // 2010-01-13 Minecraft Beta 1.2
                                    case PacketBytes._0x18_MobSpawn_0x18:
                                        {
                                            ReceiveBytes(internalSock, 19);
                                            HandleInsanity(internalSock);
                                        }
                                        break;

                                    case PacketBytes._0x19_NewPacket_0x19:
                                        {
                                            ReceiveBytes(internalSock, 4);
                                            ReceiveString(internalSock);
                                            ReceiveBytes(internalSock, 16);
                                        }
                                        break;

                                    case PacketBytes._0x28_NewPacket_0x28:
                                        {
                                            ReceiveBytes(internalSock, 4);
                                            HandleInsanity(internalSock);
                                        }
                                        break;

                                    case PacketBytes._0x14_EntitySpawnName_0x14:
                                        this.ReceiveBytes(this.internalSock, 4);
                                        this.ReceiveString(this.internalSock);
                                        this.ReceiveBytes(this.internalSock, 0x10);
                                        break;

                                    case PacketBytes._0x64_OpenWindow_0x64:
                                        {
                                            this.ReceiveBytes(this.internalSock, 2);
                                            String str = this.ReceiveStringUtf8(this.internalSock);
                                            this.ReceiveBytes(this.internalSock, 1);
                                        }
                                        break;

                                    case PacketBytes._0x66_WindowClick_0x66:
                                        {
                                            ReceiveBytes(internalSock, 6);
                                            if (Util.AtoN(ReceiveBytes(internalSock, 2), 0) >= 0) ReceiveBytes(internalSock, 3);
                                        }
                                        break;

                                    case PacketBytes._0x67_SetSlot_0x67:
                                        {
                                            ReceiveBytes(internalSock, 3);
                                            if (Util.AtoN(ReceiveBytes(internalSock, 2), 0) >= 0) ReceiveBytes(internalSock, 3);
                                        }
                                        break;

                                    case PacketBytes._0x68_WindowItems_0x68:
                                        {
                                            ReceiveBytes(internalSock, 1);
                                            short xmax = Util.AtoN(ReceiveBytes(internalSock, 2), 0);
                                            for (short cx = 0; cx < xmax; cx++)
                                            {
                                                if (Util.AtoN(ReceiveBytes(internalSock, 2), 0) >= 0)
                                                {
                                                    ReceiveBytes(internalSock, 3);
                                                }
                                            }
                                        }
                                        break;

                                    case PacketBytes._0x82_UpdateSign_0x82:
                                        {
                                            this.ReceiveBytes(this.internalSock, 10);
                                            this.ReceiveString(this.internalSock);
                                            this.ReceiveString(this.internalSock);
                                            this.ReceiveString(this.internalSock);
                                            this.ReceiveString(this.internalSock);

                                        }
                                        break;

                                    case PacketBytes._0x3C_Explosion_0x3C:
                                        {
                                            ReceiveBytes(internalSock, 28); //8 + 8 + 8 + 4
                                            ReceiveBytes(internalSock, Util.AtoI(ReceiveBytes(internalSock, 4), 0) * 3);
                                        }
                                        break;

                                    case PacketBytes._0x17_AddObject_0x17:
                                        {
                                            ReceiveBytes(internalSock, 17);
                                            if (Util.AtoI(ReceiveBytes(internalSock, 4), 0) > 0)
                                            {
                                                ReceiveBytes(internalSock, 6);
                                            }
                                        }
                                        break;

                                    case PacketBytes._0x83_MapData_0x83:
                                        {
                                            ReceiveBytes(internalSock, 4);
                                            ReceiveBytes(internalSock, Util.AtoI(ReceiveBytes(internalSock, 1), 0));
                                        }
                                        break;

                                    case PacketBytes._0x0F_PlaceBlock_0x0F:
                                        {
                                            ReceiveBytes(internalSock, 10);
                                            if (Util.AtoN(ReceiveBytes(internalSock, 2), 0) >= 0) ReceiveBytes(internalSock, 3);
                                        }
                                        break;

                                    //case PacketBytes._0x3B_NewPacket_0x3B:
                                    //    {
                                    //        this.ReceiveBytes(this.internalSock, 10);
                                    //        this.ReceiveBytes(this.internalSock, ByteArythmetic.GetInt16(this.ReceiveBytes(this.internalSock, 2), 0));
                                    //    }
                                    //    break;
                                    // * removed*
                                    default:
                                        bytes = PacketSizes.Minus_2;
                                        break;
                                }
                            }
                            else if (bytes > 0)
                            {
                                buffer = this.ReceiveBytes(this.internalSock, (int)bytes);
                            }
                            //Label_0367:
                            if (bytes == PacketSizes.Minus_2)
                            {
                                //this.fwl.parent.AddRTLine(Color.Orange, "Invalid packet ID: " + ((int)num2) + "\r\n", false);
                                this.ReceiveBytes(this.internalSock, 0x400);
                                flag = true;
                            }

                            if (firstByte == PacketBytes._0x04_UpdateTime_0x04)
                            {
                                if (serverSocket.OverrideTimeOfDay)
                                {
                                    PacketGenerator p = new PacketGenerator();
                                    p.Add(serverSocket.TimeOfDay);
                                    byte[] time = p.ToByteArray();
                                    Buffer.BlockCopy(time, 0, this.intBuffer, this.intBuffer.Length - 8, 8);
                                }
                            }

                            if (flag2)
                            {
                                this.externalSock.Send(this.intBuffer);
                            }

                            try
                            {
                                while (this.packetQueueExt.Count > 0)
                                {
                                    byte[] data;
                                    if (this.packetQueueExt.Dequeue(out data))
                                    {
                                        this.externalSock.Send(data);
                                    }
                                }
                                continue;
                            }
                            catch (SocketException)
                            {
                                this.Disconnect();
                                continue;
                            }
                            catch
                            {
                                continue;
                            }

                        }
                        Thread.Sleep(5);
                    }
                    else
                    {
                        int size = this.internalSock.Receive(buffer);
                        if (size > 0)
                        {
                            this.externalSock.Send(buffer, 0, size, SocketFlags.None);
                        }
                        else
                        {
                            Thread.Sleep(5);
                        }
                    }
                }
                catch (SocketException)
                {
                    this.Disconnect();
                }
                catch
                {
                    this.Disconnect();
                }
            }
            this.Disconnect();
        }
Exemple #3
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (IsRunning)
            {
                if (!IsConnected)
                {
                    client = new TcpClient();
                    client.ReceiveTimeout = 10000;
                    client.SendTimeout = 10000;

                    try
                    {
                        client.Connect("localhost", mc.Config.ExternalPort);
                        IsConnected = true;
                    }
                    catch (Exception ex)
                    {
                        if (ClientException != null)
                        {
                            ClientException(this, new ClientExceptionEventArgs(ex));
                            Disconnect();
                            break;
                        }
                    }
                }
                else
                {
                    try
                    {
                        Receive();
                        if (ticker >= tickerMax)
                        {
                            PacketGenerator gen = new PacketGenerator();
                            gen.Add(PacketBytes._0x00_KeepAlive_0x00);
                            client.Client.Send(gen.ToByteArray());

                            if (moveAndLookReceived && !teleported)
                            {
                                teleported = true;
                                if (teleportTo != null)
                                {
                                    CommandTo cmd = new CommandTo(mc);
                                    cmd.TriggerPlayer = Name;
                                    cmd.Execute(teleportTo, "", "", "");
                                }
                            }

                            ticker = 0;
                        }
                        ticker++;
                        if (tickerMovement >= tickerMovementMax)
                        {
                            Move(0);

                            tickerMovement = 0;
                        }
                        tickerMovement++;
                    }
                    catch (Exception ex)
                    {
                        if (ClientException != null)
                        {
                            ClientException(this, new ClientExceptionEventArgs(ex));
                        }
                        try
                        {
                            Disconnect();
                            break;
                        }
                        catch (Exception ex2)
                        {
                            if (ClientException != null)
                            {
                                ClientException(this, new ClientExceptionEventArgs(ex2));
                            }
                        }
                    }
                }
                if (worker.CancellationPending)
                {
                    Disconnect();
                    break;
                }
                Thread.Sleep(1);
            }
            IsConnected = false;
        }
Exemple #4
0
        private void Receive()
        {
            if (!handShakeSendToServer)
            {
                PacketGenerator gen = new PacketGenerator();
                gen.Add((byte)PacketBytes._0x02_Handshake_0x02);
                gen.Add(Name);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
            }

            extBuffer = ReceiveBytes(client.Client, 1);

            PacketBytes firstByte = (PacketBytes)extBuffer[0];
            PacketSizes size = MinecraftEnums.GetPacketSize(firstByte);
            if (size != PacketSizes.Minus_1)
            {
                if (firstByte == PacketBytes._0x0D_PlayerMoveAndLook_0x0D)
                {
                    size = PacketSizes.Minus_1;
                }
                if (firstByte == PacketBytes._0x03_Chat_0x03)
                {
                    size = PacketSizes.Minus_1;
                }

                if (size != PacketSizes.Minus_1)
                {
                    ReceiveBytes((int)size);
                }
            }

            if(size == PacketSizes.Minus_1)
            {
                switch (firstByte)
                {
                    case PacketBytes.Minues_1:
                        break;
                    case PacketBytes._0x00_KeepAlive_0x00:
                        break;
                    case PacketBytes._0x01_Login_0x01:
                        if (!loginRequestReceived)
                        {
                            LoginRequest();
                        }
                        break;
                    case PacketBytes._0x02_Handshake_0x02:
                        if (!handShakeReceived)
                        {
                            Handshake();
                        }
                        break;
                    case PacketBytes._0x03_Chat_0x03:
                        String chat = ReceiveString(client.Client);
                        AddOutput("Chat: " + chat);
                        break;
                    case PacketBytes._0x04_UpdateTime_0x04:
                        ReceiveInt64();
                        break;
                    case PacketBytes._0x05_EntityEquipment_01_0x05:
                        ReceiveInt32();
                        ReceiveInt16();
                        ReceiveInt16();
                        ReceiveInt16();
                        break;
                    case PacketBytes._0x06_SpawnPosition_02_0x06:
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        break;
                    case PacketBytes._0x07_Use_Entity_0x07:
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveBoolean();
                        break;
                    case PacketBytes._0x08_Health_0x08:
                        short health = ReceiveInt16();
                        if (health <= 0)
                        {
                            PacketGenerator gen = new PacketGenerator();
                            gen.Add(PacketBytes._0x08_Health_0x08);
                            client.Client.Send(gen.ToByteArray());
                        }
                        break;
                    case PacketBytes._0x09_Respawn_0x09:
                        break;
                    case PacketBytes._0x0A_Player_0x0A:
                        break;
                    case PacketBytes._0x0B_PlayerPosition_0x0B:
                        break;
                    case PacketBytes._0x0C_PlayerLook_0x0C:

                        break;
                    case PacketBytes._0x0D_PlayerMoveAndLook_0x0D:
                        position.X = Util.AtoD(ReceiveBytes(8), 0);
                        position.Y = Util.AtoD(ReceiveBytes(8), 0);
                        position.Stance = Util.AtoD(ReceiveBytes(8), 0);
                        position.Z = Util.AtoD(ReceiveBytes(8), 0);
                        position.Rotation = Util.AtoF(ReceiveBytes(4), 0);
                        position.Pitch = Util.AtoF(ReceiveBytes(4), 0);
                        position.Unkown = ByteArythmetic.GetBoolean(ReceiveBytes(1), 0);
                        moveAndLookReceived = true;
                        Move(0);
                        break;
                    case PacketBytes._0x0E_BlockDig_0x0E:
                        break;
                    case PacketBytes._0x0F_PlaceBlock_0x0F:
                        break;
                    case PacketBytes._0x10_BlockItemSwitch_0x10:
                        ReceiveBytes(2);
                        break;
                    case PacketBytes._0x11_UseBed_0x11:
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveInt32();
                        break;
                    case PacketBytes._0x12_ArmAnimation_0x12:
                        ReceiveInt32();
                        ReceiveByte();
                        break;
                    case PacketBytes._0x13_NewPacket_0x13:
                        ReceiveBytes(5);
                        break;
                    case PacketBytes._0x14_EntitySpawnName_0x14:
                        ReceiveInt32();
                        ReceiveString(client.Client);
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        ReceiveInt16();
                        break;
                    case PacketBytes._0x15_EntitySpawn_0x15:
                        ReceiveInt32();
                        ReceiveInt16();
                        ReceiveByte();
                        ReceiveInt16();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        ReceiveByte();
                        break;
                    case PacketBytes._0x16_CollectItem_0x16:
                        ReceiveInt32();
                        ReceiveInt32();
                        break;
                    case PacketBytes._0x17_AddObject_0x17:
                        ReceiveBytes(client.Client, 17);
                        if (Util.AtoI(ReceiveBytes(client.Client, 4), 0) > 0)
                        {
                            ReceiveBytes(client.Client, 6);
                        }
                        break;
                    case PacketBytes._0x18_MobSpawn_0x18:
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        HandleInsanity(client.Client);
                        break;
                    case PacketBytes._0x1B_NewPacket:
                        ReceiveFloat();
                        ReceiveFloat();
                        ReceiveFloat();
                        ReceiveFloat();
                        ReceiveBoolean();
                        ReceiveBoolean();
                        break;
                    case PacketBytes._0x1C_EntityVelocity_0x1C:
                        ReceiveInt32();
                        ReceiveInt16();
                        ReceiveInt16();
                        ReceiveInt16();
                        break;
                    case PacketBytes._0x1D_DestroyEntity_0x1D:
                        ReceiveInt32();
                        break;
                    case PacketBytes._0x1E_Entity_0x1E:
                        ReceiveInt32();
                        break;
                    case PacketBytes._0x1F_RelativeEntityMove_0x1F:
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        ReceiveByte();
                        break;
                    case PacketBytes._0x19_NewPacket_0x19:
                        ReceiveInt32();
                        ReceiveString(client.Client);
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        break;
                    case PacketBytes._0x20_EntityLook_0x20:
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        break;
                    case PacketBytes._0x21_RelativeEntityLookAndMove_0x21:
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        ReceiveByte();
                        ReceiveByte();
                        ReceiveByte();
                        break;
                    case PacketBytes._0x22_EntityTeleport_0x22:
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        break;
                    case PacketBytes._0x26_HitEntity_0x26:
                        ReceiveInt32();
                        ReceiveByte();
                        break;
                    case PacketBytes._0x27_AttachEntity_0x27:
                        ReceiveInt32();
                        ReceiveInt32();
                        break;
                    case PacketBytes._0x28_NewPacket_0x28:
                        ReceiveInt32();
                        HandleInsanity(client.Client);
                        break;
                    case PacketBytes._0x32_ChunkPre_0x32:
                        ReceiveInt32();
                        ReceiveInt32();
                        ReceiveBoolean();
                        break;
                    case PacketBytes._0x33_ChunkMap_0x33:
                        ReceiveInt32();
                        ReceiveInt16();
                        ReceiveInt32();
                        ReceiveByte();
                        ReceiveByte();
                        ReceiveByte();
                        int chunkSize = ReceiveInt32();
                        ReceiveBytes(chunkSize);
                        break;
                    case PacketBytes._0x34_MultiBlockChange_0x34:
                        this.ReceiveBytes(8);
                        this.ReceiveBytes(ByteArythmetic.GetInt16(this.ReceiveBytes(2), 0) * 4);
                        break;
                    case PacketBytes._0x35_BlockChange_0x35:
                        ReceiveBytes(11);
                        break;
                    case PacketBytes._0x36_BlockAction_0x36:
                        ReceiveBytes(12);
                        break;
                    case PacketBytes._0x3C_Explosion_0x3C:
                        ReceiveBytes(28); //8 + 8 + 8 + 4
                        ReceiveBytes(ByteArythmetic.GetInt32(ReceiveBytes(4), 0) * 3);
                        break;
                    case PacketBytes._0x46_InvalidBed_0x46:
                        ReceiveByte();
                        break;
                    case PacketBytes._0x47_Weather_0x47:
                        ReceiveBytes(17);
                        break;
                    case PacketBytes._0x64_OpenWindow_0x64:
                        ReceiveBytes(2);
                        ReceiveStringUtf8(client.Client); // UTF8
                        ReceiveBytes(1);
                        break;
                    case PacketBytes._0x65_CloseWindow_0x65:
                        ReceiveBytes(1);
                        break;
                    case PacketBytes._0x66_WindowClick_0x66:
                        ReceiveBytes(7); // Update 1.5 + 1 bool
                        if (Util.AtoN(ReceiveBytes(2), 0) >= 0) ReceiveBytes(3);
                        break;
                    case PacketBytes._0x67_SetSlot_0x67:
                        ReceiveBytes(3);
                        if (Util.AtoN(ReceiveBytes(2), 0) >= 0) ReceiveBytes(3);
                        break;
                    case PacketBytes._0x68_WindowItems_0x68:
                        short xmax = Util.AtoN(ReceiveBytes(3), 1);
                        for (short cx = 0; cx < xmax; cx++)
                        {
                            if (Util.AtoN(ReceiveBytes(2), 0) >= 0)
                            {
                                ReceiveBytes(3);
                            }
                        }
                        break;
                    case PacketBytes._0x69_UpdateProgressBar_0x69:
                        ReceiveBytes(5);
                        break;
                    case PacketBytes._0x6A_Transaction_0x6A:
                        ReceiveBytes(4);
                        break;
                    case PacketBytes._0x82_UpdateSign_0x82:
                        ReceiveBytes(10);
                        ReceiveString(client.Client);
                        ReceiveString(client.Client);
                        ReceiveString(client.Client);
                        ReceiveString(client.Client);
                        break;
                    case PacketBytes._0x83_MapData_0x83:
                        {
                            ReceiveBytes(client.Client, 4);
                            ReceiveBytes(client.Client, Util.AtoI(ReceiveBytes(client.Client, 1), 0));
                        }
                        break;
                    case PacketBytes._0xC8_IncrementStatistics_0xC8:
                        ReceiveBytes(5);
                        break;
                    case PacketBytes._0xFF_Disconnect_0xFF:
                        String str =ReceiveString(client.Client);
                        AddOutput("NPC Disconnected: " + str);
                        break;
                    default:
                        break;
                }
            }
        }
Exemple #5
0
        private void Handshake()
        {
            serverHash = ReceiveString(client.Client);
            AddOutput(String.Format("Serverhash: {0}", serverHash));
            if (serverHash == "+")
            {
                PacketGenerator gen = new PacketGenerator();
                gen.Add(PacketBytes._0x01_Login_0x01);
                gen.Add(11); //protocol version
                gen.Add(Name);
                gen.Add((long)0);
                gen.Add((byte)0);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
                loginRequestSend = true;
            }
            else if (serverHash == "-")
            {
                PacketGenerator gen = new PacketGenerator();
                gen.Add(PacketBytes._0x01_Login_0x01);
                gen.Add(11); //protocol version
                gen.Add(Name);
                gen.Add((long)0);
                gen.Add((byte)0);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
                loginRequestSend = true;
            }
            else
            {
                Authenticate();

                PacketGenerator gen = new PacketGenerator();
                gen.Add(PacketBytes._0x01_Login_0x01);
                gen.Add(11); //protocol version
                gen.Add(Name);
                gen.Add((long)0);
                gen.Add((byte)0);
                client.Client.Send(gen.ToByteArray());
                handShakeSendToServer = true;
                loginRequestSend = true;
            }
            handShakeReceived = true;
        }
Exemple #6
0
 public void SpeakThrough(String message)
 {
     if (IsConnected)
     {
         PacketGenerator gen = new PacketGenerator();
         gen.Add(PacketBytes._0x03_Chat_0x03);
         gen.Add(message);
         SendPackets(gen.ToByteArray());
     }
 }
Exemple #7
0
 public void Move(int amount)
 {
     if (isConnected)
     {
         PacketGenerator gen = new PacketGenerator();
         gen.Add(PacketBytes._0x0D_PlayerMoveAndLook_0x0D);
         gen.Add((double)(position.X+amount));
         gen.Add(position.Stance);
         gen.Add(position.Y);
         gen.Add(position.Z);
         gen.Add(position.Rotation);
         gen.Add(position.Pitch);
         gen.Add(position.Unkown);
         SendPackets(gen.ToByteArray());
     }
 }