Search in sources :

Example 1 with Skin

use of cn.nukkit.entity.data.Skin in project Nukkit by Nukkit.

the class PlayerSkinPacket method decode.

@Override
public void decode() {
    this.uuid = this.getUUID();
    String skinId = this.getString();
    this.skinName = this.getString();
    this.oldSkinName = this.getString();
    byte[] data = this.getByteArray();
    byte[] cape = this.getByteArray();
    this.skin = new Skin(data, skinId);
    this.skin.setCape(this.skin.new Cape(cape));
    this.geometryModel = this.getString();
    this.geometryData = this.getString();
}
Also used : Skin(cn.nukkit.entity.data.Skin)

Example 2 with Skin

use of cn.nukkit.entity.data.Skin in project Nukkit by Nukkit.

the class LoginPacket method decodeSkinData.

private void decodeSkinData() {
    JsonObject skinToken = decodeToken(new String(this.get(this.getLInt())));
    String skinId = null;
    if (skinToken.has("ClientRandomId"))
        this.clientId = skinToken.get("ClientRandomId").getAsLong();
    if (skinToken.has("SkinId"))
        skinId = skinToken.get("SkinId").getAsString();
    if (skinToken.has("SkinData")) {
        this.skin = new Skin(skinToken.get("SkinData").getAsString(), skinId);
        if (skinToken.has("CapeData"))
            this.skin.setCape(this.skin.new Cape(Base64.getDecoder().decode(skinToken.get("CapeData").getAsString())));
    }
    if (skinToken.has("SkinGeometryName"))
        this.skinGeometryName = skinToken.get("SkinGeometryName").getAsString();
    if (skinToken.has("SkinGeometry"))
        this.skinGeometry = Base64.getDecoder().decode(skinToken.get("SkinGeometry").getAsString());
}
Also used : JsonObject(com.google.gson.JsonObject) Skin(cn.nukkit.entity.data.Skin)

Example 3 with Skin

use of cn.nukkit.entity.data.Skin in project Nukkit by Nukkit.

the class EntityHuman method initEntity.

@Override
protected void initEntity() {
    this.setDataFlag(DATA_PLAYER_FLAGS, DATA_PLAYER_FLAG_SLEEP, false);
    this.setDataFlag(DATA_FLAGS, DATA_FLAG_GRAVITY);
    this.setDataProperty(new IntPositionEntityData(DATA_PLAYER_BED_POSITION, 0, 0, 0), false);
    if (!(this instanceof Player)) {
        if (this.namedTag.contains("NameTag")) {
            this.setNameTag(this.namedTag.getString("NameTag"));
        }
        if (this.namedTag.contains("Skin") && this.namedTag.get("Skin") instanceof CompoundTag) {
            if (!this.namedTag.getCompound("Skin").contains("Transparent")) {
                this.namedTag.getCompound("Skin").putBoolean("Transparent", false);
            }
            this.setSkin(new Skin(this.namedTag.getCompound("Skin").getByteArray("Data"), this.namedTag.getCompound("Skin").getString("ModelId")));
        }
        this.uuid = Utils.dataToUUID(String.valueOf(this.getId()).getBytes(StandardCharsets.UTF_8), this.getSkin().getData(), this.getNameTag().getBytes(StandardCharsets.UTF_8));
    }
    super.initEntity();
}
Also used : Player(cn.nukkit.Player) IntPositionEntityData(cn.nukkit.entity.data.IntPositionEntityData) Skin(cn.nukkit.entity.data.Skin) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

Skin (cn.nukkit.entity.data.Skin)3 Player (cn.nukkit.Player)1 IntPositionEntityData (cn.nukkit.entity.data.IntPositionEntityData)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 JsonObject (com.google.gson.JsonObject)1