aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java b/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java
index 12eea5b..2de2e5e 100644
--- a/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java
+++ b/src/main/java/moe/nea/firmament/mixins/custommodels/JsonUnbakedModelDataHolder.java
@@ -5,6 +5,7 @@ import com.llamalad7.mixinextras.sugar.Local;
import moe.nea.firmament.features.texturepack.BakedModelExtra;
import moe.nea.firmament.features.texturepack.JsonUnbakedModelFirmExtra;
import moe.nea.firmament.features.texturepack.TintOverrides;
+import moe.nea.firmament.util.ErrorUtil;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.Baker;
import net.minecraft.client.render.model.ModelRotation;
@@ -79,14 +80,11 @@ public abstract class JsonUnbakedModelDataHolder implements JsonUnbakedModelFirm
}
}
- @ModifyReturnValue(
- method = "bake(Lnet/minecraft/client/render/model/Baker;Ljava/util/function/Function;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;",
- at = @At(value = "RETURN"))
- private BakedModel bakeExtraInfo(BakedModel original, @Local(argsOnly = true) Baker baker) {
+ private void addExtraBakeInfo(BakedModel bakedModel, Baker baker) {
if (!this.toString().contains("minecraft") && this.toString().contains("crimson")) {
System.out.println("Found non minecraft model " + this);
}
- if (original instanceof BakedModelExtra extra) {
+ if (bakedModel instanceof BakedModelExtra extra) {
var headModel = getHeadModel_firmament();
if (headModel != null) {
extra.setHeadModel_firmament(baker.bake(headModel, ModelRotation.X0_Y0));
@@ -95,6 +93,37 @@ public abstract class JsonUnbakedModelDataHolder implements JsonUnbakedModelFirm
extra.setTintOverrides_firmament(getTintOverrides_firmament());
}
}
+ }
+
+ /**
+ * @see ProvideBakerToJsonUnbakedModelPatch
+ */
+ @Override
+ public void storeExtraBaker_firmament(@NotNull Baker baker) {
+ this.storedBaker = baker;
+ }
+
+ @Unique
+ private Baker storedBaker;
+
+ @ModifyReturnValue(
+ method = "bake(Ljava/util/function/Function;Lnet/minecraft/client/render/model/ModelBakeSettings;Z)Lnet/minecraft/client/render/model/BakedModel;",
+ at = @At("RETURN"))
+ private BakedModel bakeExtraInfoWithoutBaker(BakedModel original) {
+ if (storedBaker != null) {
+ addExtraBakeInfo(original, storedBaker);
+ storedBaker = null;
+ }
+ return original;
+ }
+
+ @ModifyReturnValue(
+ method = {
+ "bake(Lnet/minecraft/client/render/model/Baker;Ljava/util/function/Function;Lnet/minecraft/client/render/model/ModelBakeSettings;)Lnet/minecraft/client/render/model/BakedModel;"
+ },
+ at = @At(value = "RETURN"))
+ private BakedModel bakeExtraInfo(BakedModel original, @Local(argsOnly = true) Baker baker) {
+ addExtraBakeInfo(original, baker);
return original;
}
}