2020import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
2121import team .chisel .ctm .CTM ;
2222import team .chisel .ctm .api .model .IModelCTM ;
23- import team .chisel .ctm .client .mixin .ModelBakerImplAccessor ;
2423import team .chisel .ctm .client .model .AbstractCTMBakedModel ;
2524import team .chisel .ctm .client .model .ModelCTM ;
2625import team .chisel .ctm .client .texture .IMetadataSectionCTM ;
@@ -39,7 +38,7 @@ public abstract class TextureMetadataHandlerMixin implements ModernFixClientInte
3938
4039 @ Shadow (remap = false ) @ Nonnull protected abstract BakedModel wrap (UnbakedModel model , BakedModel object ) throws IOException ;
4140
42- @ Shadow (remap = false ) @ Final public static Multimap <ResourceLocation , Material > TEXTURES_SCRAPED ;
41+ @ Shadow (remap = false ) @ Final private Multimap <ResourceLocation , Material > scrapedTextures ;
4342
4443 @ Inject (method = "<init>" , at = @ At ("RETURN" ))
4544 private void subscribeDynamic (CallbackInfo ci ) {
@@ -70,7 +69,7 @@ public BakedModel onBakedModelLoad(ResourceLocation rl, UnbakedModel rootModel,
7069 continue ;
7170 }
7271
73- Collection <Material > textures = Sets .newHashSet (TEXTURES_SCRAPED .get (dep ));
72+ Collection <Material > textures = Sets .newHashSet (scrapedTextures .get (dep ));
7473 Collection <ResourceLocation > newDependencies = model .getDependencies ();
7574 for (Material tex : textures ) {
7675 IMetadataSectionCTM meta = null ;
@@ -108,10 +107,12 @@ private void handleInit(ResourceLocation key, BakedModel wrappedModel, ModelBake
108107 IModelCTM var10 = baked .getModel ();
109108 if (var10 instanceof ModelCTM ctmModel ) {
110109 if (!ctmModel .isInitialized ()) {
110+ // Clear the baked cache as upstream CTM does
111+ ((CTMModelBakeryAccessor )bakery ).mfix$getBakedCache ().clear ();
111112 Function <Material , TextureAtlasSprite > spriteGetter = (m ) -> {
112113 return Minecraft .getInstance ().getModelManager ().getAtlas (m .atlasLocation ()).getSprite (m .texture ());
113114 };
114- ModelBakery .ModelBakerImpl baker = ModelBakerImplAccessor . createImpl ( bakery , ($ , m ) -> {
115+ ModelBakery .ModelBakerImpl baker = bakery . new ModelBakerImpl ( ($ , m ) -> {
115116 return spriteGetter .apply (m );
116117 }, key );
117118 // bypass bakedCache so that dependent models get re-baked and thus retrieve their sprites again
0 commit comments