public LSPacket getPacket() {
    LSPacketBuilder packet = new LSPacketBuilder();
    packet.setID(20);
    packet.addLong(player.getUsernameHash());
    packet.addInt(player.getOwner());

    packet.addLong(
        player.getLastLogin() == 0L && player.isChangingAppearance()
            ? 0
            : player.getCurrentLogin());
    packet.addLong(DataConversions.IPToLong(player.getCurrentIP()));
    packet.addShort(player.getCombatLevel());
    packet.addShort(player.getSkillTotal());
    packet.addShort(player.getX());
    packet.addShort(player.getY());
    packet.addShort(player.getFatigue());
    packet.addShort(player.getQuestPoints());
    packet.addShort(player.getDeaths());
    packet.addShort(player.getKills());

    PlayerAppearance a = player.getPlayerAppearance();
    packet.addByte((byte) a.getHairColour());
    packet.addByte((byte) a.getTopColour());
    packet.addByte((byte) a.getTrouserColour());
    packet.addByte((byte) a.getSkinColour());
    packet.addByte((byte) a.getSprite(0));
    packet.addByte((byte) a.getSprite(1));

    packet.addByte((byte) (player.isMale() ? 1 : 0));
    packet.addLong(player.getSkullTime());
    packet.addByte((byte) player.getCombatStyle());

    for (int i = 0; i < 18; i++) {
      packet.addLong(player.getExp(i));
      packet.addShort(player.getCurStat(i));
    }

    Inventory inv = player.getInventory();
    packet.addShort(inv.size());
    for (InvItem i : inv.getItems()) {
      packet.addShort(i.getID());
      packet.addInt(i.getAmount());
      packet.addByte((byte) (i.isWielded() ? 1 : 0));
    }

    Bank bnk = player.getBank();
    packet.addShort(bnk.size());
    for (InvItem i : bnk.getItems()) {
      packet.addShort(i.getID());
      packet.addInt(i.getAmount());
    }

    return packet.toPacket();
  }
  public RSCPacket getPacket() {
    List<Bubble> bubblesNeedingDisplayed = playerToUpdate.getBubblesNeedingDisplayed();
    List<ChatMessage> chatMessagesNeedingDisplayed =
        playerToUpdate.getChatMessagesNeedingDisplayed();
    List<Player> playersNeedingHitsUpdate = playerToUpdate.getPlayersRequiringHitsUpdate();

    List<Projectile> projectilesNeedingDisplayed = playerToUpdate.getProjectilesNeedingDisplayed();
    List<Player> playersNeedingAppearanceUpdate =
        playerToUpdate.getPlayersRequiringAppearanceUpdate();

    int updateSize =
        bubblesNeedingDisplayed.size()
            + chatMessagesNeedingDisplayed.size()
            + playersNeedingHitsUpdate.size()
            + projectilesNeedingDisplayed.size()
            + playersNeedingAppearanceUpdate.size();
    if (updateSize > 0) {
      RSCPacketBuilder updates = new RSCPacketBuilder();
      updates.setID(53);
      updates.addShort(updateSize);
      for (Bubble b : bubblesNeedingDisplayed) { // 0 - Draws item over players head
        updates.addShort(b.getOwner().getIndex());
        updates.addByte((byte) 0);
        updates.addShort(b.getID());
      }
      for (ChatMessage cm : chatMessagesNeedingDisplayed) { // 1/6 - Player talking
        updates.addShort(cm.getSender().getIndex());
        updates.addByte((byte) (cm.getRecipient() == null ? 1 : 6));
        System.out.println(cm.getRecipient() == null);
        updates.addByte((byte) cm.getLength());
        updates.addBytes(cm.getMessage());
      }
      for (Player p :
          playersNeedingHitsUpdate) { // 2 - Hitpoints update for players, draws health bar etc too
        updates.addShort(p.getIndex());
        updates.addByte((byte) 2);
        updates.addByte((byte) p.getLastDamage());
        updates.addByte((byte) p.getCurStat(3));
        updates.addByte((byte) p.getMaxStat(3));
      }
      for (Projectile p : projectilesNeedingDisplayed) { // 3/4 - Draws a projectile
        Entity victim = p.getVictim();
        if (victim instanceof Npc) {
          updates.addShort(p.getCaster().getIndex());
          updates.addByte((byte) 3);
          updates.addShort(p.getType());
          updates.addShort(((Npc) victim).getIndex());
        } else if (victim instanceof Player) {
          updates.addShort(p.getCaster().getIndex());
          updates.addByte((byte) 4);
          updates.addShort(p.getType());
          updates.addShort(((Player) victim).getIndex());
        }
      }
      for (Player p :
          playersNeedingAppearanceUpdate) { // 5 - Updates players appearance, clothes, skull,
                                            // combat etc.
        PlayerAppearance appearance = p.getPlayerAppearance();
        updates.addShort(p.getIndex());
        updates.addByte((byte) 5);
        updates.addShort(p.getAppearanceID());
        updates.addLong(p.getUsernameHash());
        updates.addLong(p.getClanNameHash());
        updates.addByte((byte) p.getWornItems().length);
        for (int i : p.getWornItems()) {
          updates.addByte((byte) i);
        }
        updates.addByte(appearance.getHairColour());
        updates.addByte(appearance.getTopColour());
        updates.addByte(appearance.getTrouserColour());
        updates.addByte(appearance.getSkinColour());
        updates.addByte((byte) p.getCombatLevel());
        updates.addByte((byte) (p.isSkulled() ? 1 : 0));
        updates.addByte(
            (byte)
                (p.isAdmin()
                    ? 3
                    : (p.isMod()
                        ? 2
                        : (p.isPMod() ? 1 : (p.isEvent() ? 4 : (p.isDeveloper() ? 5 : 0))))));
        updates.addLong(DataConversions.usernameToHash((p.flag == null ? "--" : p.flag)));
      }
      return updates.toPacket();
    }
    return null;
  }