File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/dynamic_resources Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .embeddedt .modernfix .common .mixin .perf .dynamic_resources ;
2+
3+ import com .llamalad7 .mixinextras .injector .ModifyReturnValue ;
4+ import net .minecraft .client .resources .model .ModelBakery ;
5+ import net .minecraft .client .resources .model .UnbakedModel ;
6+ import net .minecraft .resources .ResourceLocation ;
7+ import org .embeddedt .modernfix .ModernFix ;
8+ import org .embeddedt .modernfix .annotation .ClientOnlyMixin ;
9+ import org .spongepowered .asm .mixin .Mixin ;
10+ import org .spongepowered .asm .mixin .Shadow ;
11+ import org .spongepowered .asm .mixin .Unique ;
12+ import org .spongepowered .asm .mixin .injection .At ;
13+
14+ @ Mixin (ModelBakery .ModelBakerImpl .class )
15+ @ ClientOnlyMixin
16+ public abstract class ModelBakerImplMixin {
17+ @ Shadow public abstract UnbakedModel getModel (ResourceLocation location );
18+
19+ @ Unique
20+ private int mfix$getDepth = 0 ;
21+
22+ /**
23+ * @author embeddedt
24+ * @reason force parent resolution to happen before model gets baked
25+ */
26+ @ ModifyReturnValue (method = "getModel" , at = @ At ("RETURN" ))
27+ private UnbakedModel resolveParents (UnbakedModel model ) {
28+ mfix$getDepth ++;
29+ if (mfix$getDepth == 1 ) {
30+ try {
31+ model .resolveParents (this ::getModel );
32+ } catch (Exception e ) {
33+ ModernFix .LOGGER .warn ("Exception encountered resolving parents" , e );
34+ }
35+ }
36+ mfix$getDepth --;
37+ return model ;
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments