aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-11 01:58:23 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-11 01:58:23 +0200
commitfeca9c937be40bfed255e6574dea70d640fdafea (patch)
tree5ad4975ccfdc4b232e9a7fb34df4c01be4c2d441 /src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java
parent67cc7c22ac5f6873eb4549bc69db9f014c09c07f (diff)
downloadFirmament-feca9c937be40bfed255e6574dea70d640fdafea.tar.gz
Firmament-feca9c937be40bfed255e6574dea70d640fdafea.tar.bz2
Firmament-feca9c937be40bfed255e6574dea70d640fdafea.zip
Add custom head models
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.java30
1 files changed, 30 insertions, 0 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
new file mode 100644
index 0000000..3b85421
--- /dev/null
+++ b/src/main/java/moe/nea/firmament/mixins/custommodels/PatchJsonUnbakedModelDeserializer.java
@@ -0,0 +1,30 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.mixins.custommodels;
+
+import com.google.gson.JsonObject;
+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 net.minecraft.client.render.model.json.JsonUnbakedModel;
+import net.minecraft.util.Identifier;
+import org.spongepowered.asm.mixin.Mixin;
+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;
+ }
+}