1.16.5 Can I turn PNG into Json Object for NPC skin?

Discussion in 'Spigot Plugin Development' started by ShiftingKill, Sep 30, 2020.

  1. Is it possible to add a PNG file to an NPC I created. Not trying to use citizens and all that. Like instead of this:
    Code (Text):
    String [] name = getSkin(ply, skin);
    gameProfile.getProperties().put("textures", new Property("textures", name[0], name[1]));
    addNPCPacket(npc);
    Just wondering where the png could get turned into a String []
    The method getSkin returns this (where property is a JSON object):
    Code (Text):
    String texture = property.get("value").getAsString();
    String signature = property.get("signature").getAsString();
    return new String [] {texture, signature};
    So I may have answered it myself, can the PNG be converted to a Json object?
     
  2. You can use the Base64 encoding for skins, though I'm not exactly sure which image format minecraft itself uses, so you might need to do an extra conversion step first.
     
    #2 Jannyboy11, Sep 30, 2020
    Last edited: Sep 30, 2020
  3. Because I think the signature is important so the skin is shown properly ingame,
    the skin needs to be uploaded to a Minecraft account, so the signature is calculated.

    You could do that automatically.

    Maybe it also works without a proper signature, than you can use PNG Base64 like Jannyboy11 said.