Search in sources :

Example 1 with IntPositionEntityData

use of cn.nukkit.entity.data.IntPositionEntityData 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

Player (cn.nukkit.Player)1 IntPositionEntityData (cn.nukkit.entity.data.IntPositionEntityData)1 Skin (cn.nukkit.entity.data.Skin)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1