Beispiel #1
0
 public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
 {
     switch (Action)
     {
         case EntityAction.Crouch:
             Client.IsCrouching = true;
             break;
         case EntityAction.Uncrouch:
             Client.IsCrouching = false;
             break;
         case EntityAction.StartSprinting:
             Client.IsSprinting = true;
             break;
         case EntityAction.StopSprinting:
             Client.IsSprinting = false;
             break;
     }
     if (Action != EntityAction.LeaveBed) // NOTE: Does this matter?
     {
         this.EntityId = Client.Entity.Id;
         for (int i = 0; i < 
              Server.GetClientsInWorld(Server.GetClientWorld(Client)).Count(); i++)
         {
             if (Server.Clients [i] != Client)
                 Server.Clients [i].SendPacket(this);
         }
         Server.ProcessSendQueue();
     }
 }
 public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
 {
     if (!Client.ReadyToSpawn)
         return;
     Client.Entity.Position = new Vector3(X, Y, Z);
     if (Client.Entity.Position.DistanceTo(Client.Entity.OldPosition) > 
         Client.MaxMoveDistance)
     {
         Client.SendPacket(new DisconnectPacket("Hacking: You moved too fast!"));
         Server.ProcessSendQueue();
         return;
     }
     Client.UpdateChunksAsync();
     Server.GetClientWorld(Client).EntityManager.UpdateEntity(Client.Entity);
     Server.ProcessSendQueue();
 }
 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     if (!client.ReadyToSpawn)
         return;
     client.Entity.Position = new Vector3(X, Y, Z);
     if (client.Entity.Position.DistanceTo(client.Entity.OldPosition) >
         client.MaxMoveDistance)
     {
         client.SendPacket(new DisconnectPacket("Hacking: You moved too fast!"));
         server.ProcessSendQueue();
         return;
     }
     client.UpdateChunksAsync();
     server.ProcessSendQueue();
     server.EntityManager.UpdateEntity(client.Entity);
 }
Beispiel #4
0
 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     EntityId = client.Entity.Id;
     var clients = server.GetClientsInWorld(server.GetClientWorld(client)).Where(c => c.Entity.Id != EntityId);
     foreach (var _client in clients)
         _client.SendPacket(this);
     server.ProcessSendQueue();
 }
        public override void HandlePacket(MinecraftServer server, MinecraftClient client)
        {
            EntityId = client.Entity.Id;
            var clients = server.EntityManager.GetKnownClients(client.Entity);

            foreach (var _client in clients)
                _client.SendPacket(this);
            server.ProcessSendQueue();
        }
        public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
        {
            Client.SharedKey = Server.CryptoServiceProvider.Decrypt(SharedSecret, false);

            Client.Encrypter = Cryptography.GenerateAES(Client.SharedKey).CreateEncryptor();

            Client.Decrypter = Cryptography.GenerateAES(Client.SharedKey).CreateDecryptor();

            Client.SendPacket(new EncryptionKeyResponsePacket());
            Server.ProcessSendQueue();
        }
 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     if (!client.ReadyToSpawn)
         return;
     client.Entity.FoodExhaustion += (float)client.Entity.GivenPosition.DistanceTo(new Vector3(X, Y, Z)) *
         (client.Entity.IsSprinting ? 0.1f : 0.01f); // TODO: Swimming
     client.Entity.GivenPosition = new Vector3(X, Y, Z);
     client.Entity.Pitch = Pitch;
     client.Entity.Yaw = Yaw;
     client.UpdateChunksAsync();
     server.ProcessSendQueue();
 }
Beispiel #8
0
        public override void HandlePacket(MinecraftServer server, MinecraftClient client)
        {
            if (ProtocolVersion < MinecraftServer.ProtocolVersion)
            {
                client.SendPacket(new DisconnectPacket("Outdated client!"));
                server.ProcessSendQueue();
                return;
            }
            if (ProtocolVersion > MinecraftServer.ProtocolVersion)
            {
                client.SendPacket(new DisconnectPacket("Outdated server!"));
                server.ProcessSendQueue();
                return;
            }
            if (server.Clients.Count(c => c.Username == Username) != 0)
            {
                client.SendPacket(new DisconnectPacket("You are already logged in!"));
                server.ProcessSendQueue();
                return;
            }
            client.Username = Username;
            client.Hostname = Hostname + ":" + Port.ToString();
            // Respond with encryption request
            if (server.OnlineMode)
                client.AuthenticationHash = CreateHash();
            else
                client.AuthenticationHash = "-";
            if (server.EncryptionEnabled)
            {
                var keyRequest =
                    new EncryptionKeyRequestPacket(client.AuthenticationHash,
                                                   server.ServerKey);
                client.SendPacket(keyRequest);
                server.ProcessSendQueue();
            }
            else
                server.LogInPlayer(client);

            client.StartWorkers();
        }
        public override void HandlePacket(MinecraftServer server, MinecraftClient client)
        {
            switch (ClientStatus)
            {
                case ClientStatus.InitialSpawn:
                    // Create a hash for session verification
                    SHA1 sha1 = SHA1.Create();
                    AsnKeyBuilder.AsnMessage encodedKey = AsnKeyBuilder.PublicKeyToX509(server.ServerKey);
                    byte[] shaData = Encoding.UTF8.GetBytes(client.AuthenticationHash)
                        .Concat(client.SharedKey)
                        .Concat(encodedKey.GetBytes()).ToArray();
                    string hash = Cryptography.JavaHexDigest(shaData);

                    // Talk to session.minecraft.net
                    if (server.Settings.OnlineMode)
                    {
                        var webClient = new WebClient();
                        var webReader = new StreamReader(webClient.OpenRead(
                            new Uri(string.Format(sessionCheckUri, client.Username, hash))));
                        string response = webReader.ReadToEnd();
                        webReader.Close();
                        if (response != "YES")
                        {
                            client.SendPacket(new DisconnectPacket("Failed to verify username!"));
                            return;
                        }
                    }

                    server.LogInPlayer(client);
                    break;
                case ClientStatus.Respawn:
                    var world = client.World;
                    client.Entity.Position = new Vector3(
                        client.Entity.SpawnPoint.X,
                        client.Entity.SpawnPoint.Y + PlayerEntity.Height,
                        client.Entity.SpawnPoint.Z);
                    client.Entity.Health = client.Entity.MaxHealth;
                    client.Entity.Food = 20;
                    client.Entity.FoodSaturation = 20;
                    server.EntityManager.SpawnEntity(world, client.Entity);
                    client.SendPacket(new UpdateHealthPacket(client.Entity.Health, client.Entity.Food, client.Entity.FoodSaturation));
                    client.SendPacket(new RespawnPacket(Dimension.Overworld, server.Settings.Difficulty,
                        client.Entity.GameMode, world.LevelType));
                    client.SendPacket(new PlayerPositionAndLookPacket(
                                  client.Entity.Position, client.Entity.Yaw, client.Entity.Pitch, true));
                    server.ProcessSendQueue();
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }
        public override void HandlePacket(MinecraftServer server, MinecraftClient client)
        {
            client.SharedKey = server.CryptoServiceProvider.Decrypt(SharedSecret, false);

            client.Encrypter = new BufferedBlockCipher(new CfbBlockCipher(new AesFastEngine(), 8));
            client.Encrypter.Init(true,
                                  new ParametersWithIV(new KeyParameter(client.SharedKey), client.SharedKey, 0, 16));

            client.Decrypter = new BufferedBlockCipher(new CfbBlockCipher(new AesFastEngine(), 8));
            client.Decrypter.Init(false,
                                  new ParametersWithIV(new KeyParameter(client.SharedKey), client.SharedKey, 0, 16));

            client.SendPacket(new EncryptionKeyResponsePacket());
            server.ProcessSendQueue();
        }
 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     if (client.Entity.Position.DistanceTo(Position) > 6) // TODO: Use client.Reach
         return;
     var item = client.Entity.Inventory[client.Entity.SelectedSlot];
     if (item != null && item.Id == 0xFFFF)
         item.Id = 0;
     if (item != null)
     {
         item.Item.OnItemUsed(server.GetClientWorld(client), Position, AdjustByDirection(Direction), CursorPosition, client.Entity);
         if (client.Entity.GameMode != GameMode.Creative)
             client.Entity.Inventory[client.Entity.SelectedSlot].Count--;
     }
     else
     {
         client.SendPacket(new DisconnectPacket("Unrecognized item!"));
         server.ProcessSendQueue();
     }
 }
 public override void HandlePacket(MinecraftServer server, MinecraftClient client)
 {
     client.SendPacket(new DisconnectPacket(GetPingValue(server)));
     server.ProcessSendQueue();
 }
Beispiel #13
0
 public override void HandlePacket(MinecraftServer Server, ref MinecraftClient Client)
 {
     Client.SendPacket(new DisconnectPacket(GetPingValue(Server)));
     Server.ProcessSendQueue();
 }