1.16.5 Changing Player Skin For Self

Discussion in 'Spigot Plugin Development' started by BeefDev, Sep 6, 2021.

  1. Hey I am making a plugin which involves skin changing. Reloading the skin for other players is very easy, you can just use Player#hidePlayer Player#showPlayer. However for the player who is getting their skin changed I am sending the PacketPlayOutPlayerInfo and then have to either kill them or tp them to a new world. Is there a way to bypass that last step and show the player their new skin instantly. I could use an API as a last resort but I would like to do that on my own to understand how its done.

    Note I am not using ProtocolLib
  2. Watching from 7:30 shows the class used if you don't want to watch the entire video.
  3. That video runs the code on player join which I think reloads the skin or smt, the first time I tried changing skins I used the code from this video and it didn't change the skin for the player until they died or tped to another world. I ended up using the SkinsRestorer API
  4. You'd have to send these packets in this order:
    1. PacketPlayOutPlayerInfo - REMOVE_PLAYER packet
    2. PacketPlayOutPlayerInfo - ADD_PLAYER packet
    3. PacketPlayOutRespawn
    4. PacketPlayOutPosition
    You can set the player's skin signature through the GameProfile within the EntityPlayer object.
    I'm not sure if this still works on 1.16 as I've tested this using NMS v1.8.R3, but I'm quite sure it would still work.
  5. Hi, I did change the skin and send remove + add packet, but not the 2 last packets. Even though the API worked I will try this as it is a lot neater than having to import a giant library like skins restorer. If it works (cant test rn) thank you very much
    • Like Like x 1