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();
}
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());
}
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();
}
Aggregations