aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/gui/entity/ModifyPlayerSkin.kt
blob: 886a17e61b4493e213988bd02a7ee1e2a47f6543 (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(it.asString)
        }
        info["skin"]?.let {
            entity.skinTexture = Identifier(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
    }

}