aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/entity/ModifyPlayerSkin.kt
blob: b382fe299418d1bf58ea83dfaebd030ecc96ea28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

package moe.nea.firmament.gui.entity

import com.google.gson.JsonObject
import net.minecraft.client.util.SkinTextures
import net.minecraft.entity.LivingEntity
import net.minecraft.util.Identifier

object ModifyPlayerSkin : EntityModifier {
    override fun apply(entity: LivingEntity, info: JsonObject): LivingEntity {
        require(entity is GuiPlayer)
        info["cape"]?.let {
            entity.capeTexture = Identifier.of(it.asString)
        }
        info["skin"]?.let {
            entity.skinTexture = Identifier.of(it.asString)
        }
        info["slim"]?.let {
            entity.model = if (it.asBoolean) SkinTextures.Model.SLIM else SkinTextures.Model.WIDE
        }
        info["parts"]?.let {
            // TODO: support parts
        }
        return entity
    }

}