private void HandleDisconnect(Client client, DisconnectPacket packet) { if (client.LoggedIn && client.Player.Username.Length > 0) { Server.BroadcastPacket(new ChatMessagePacket("", ChatColor.Yellow + client.Player.Username + " left the game.")); Server.BroadcastPacket(new DestroyEntityPacket(client.Player.EntityID)); Logger.Info(client.Player.Username + " left the game. (" + packet.Reason + ")"); } client.Dispose(); }
private void HandlePlayerDigging(Client client, PlayerDiggingPacket packet) { if (!client.LoggedIn) client.Dispose(); // TODO: Check if player is close enough to break the block; implement Start Digging and Drop statuses if (packet.DigStatus == 2 || Server.GameMode == 1) // Finished Digging { Nullable<Block> nb = Server.GetWorldManager().GetWorld(0).GetBlock(new WorldLocation(packet.DigX, (int)packet.DigY, packet.DigZ)); if (nb != null) { Block b = (Block)nb; if (Location.Distance(new Location(b.Location.X, b.Location.Y, b.Location.Z), client.Player.Location) > 5) return; ItemEntity dropEntity = new ItemEntity(Server.TotalEntityCount++, b.GetBlockType()); dropEntity.Location = new Location(b.Location.X, b.Location.Y, b.Location.Z); Server.GetWorldManager().GetWorld(0).AddEntity(dropEntity); Server.BroadcastPacket(new PickupSpawnPacket(dropEntity.EntityID, (short)dropEntity.Type, 1, 0, (int)dropEntity.Location.X, (int)dropEntity.Location.Y, (int)dropEntity.Location.Z, 0, 0, 0)); b.SetBlockType(BlockType.Air); Server.BroadcastPacket(new EntityPacket(dropEntity.EntityID)); Server.OnBlockChange(b); } } }