diff options
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java index cd6fb17..d6c25b5 100644 --- a/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java +++ b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java @@ -6,6 +6,7 @@ import com.google.gson.JsonPrimitive; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.llamalad7.mixinextras.sugar.Local; import moe.nea.firmament.features.texturepack.JsonUnbakedModelFirmExtra; +import moe.nea.firmament.features.texturepack.TintOverrides; import net.minecraft.client.render.model.json.JsonUnbakedModel; import net.minecraft.util.Identifier; import org.spongepowered.asm.mixin.Mixin; @@ -13,13 +14,18 @@ import org.spongepowered.asm.mixin.injection.At; @Mixin(JsonUnbakedModel.Deserializer.class) public class PatchJsonUnbakedModelDeserializer { - @ModifyReturnValue(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/client/render/model/json/JsonUnbakedModel;", - at = @At("RETURN")) - private JsonUnbakedModel addHeadModel(JsonUnbakedModel original, @Local JsonObject jsonObject) { - var headModel = jsonObject.get("firmament:head_model"); - if (headModel instanceof JsonPrimitive prim && prim.isString()) { - ((JsonUnbakedModelFirmExtra) original).setHeadModel_firmament(Identifier.of(prim.getAsString())); - } - return original; - } + @ModifyReturnValue(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/client/render/model/json/JsonUnbakedModel;", + at = @At("RETURN")) + private JsonUnbakedModel addHeadModel(JsonUnbakedModel original, @Local JsonObject jsonObject) { + var headModel = jsonObject.get("firmament:head_model"); + var extra = ((JsonUnbakedModelFirmExtra) original); + if (headModel instanceof JsonPrimitive prim && prim.isString()) { + extra.setHeadModel_firmament(Identifier.of(prim.getAsString())); + } + var tintOverrides = jsonObject.get("firmament:tint_overrides"); + if (tintOverrides instanceof JsonObject object) { + extra.setTintOverrides_firmament(TintOverrides.Companion.parse(object)); + } + return original; + } } |