Tweak point at which dummy models are cleared on Fabric

This commit is contained in:
embeddedt 2023-05-21 17:04:22 -04:00
parent c2f09fb998
commit 98da673cbe
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -244,6 +244,7 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
"entity/chest",
"item",
"items",
"part",
"pipe",
"ropebridge"
};
@ -266,6 +267,14 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
return materialsSet;
}
@Inject(method = "<init>", at = @At(value = "INVOKE_STRING", target = "Lnet/minecraft/util/profiling/ProfilerFiller;popPush(Ljava/lang/String;)V", args = "ldc=textures"))
private void clearDummyModels(CallbackInfo ci) {
// discard unwrapped models
Predicate<Map.Entry<ResourceLocation, UnbakedModel>> isVanillaModel = entry -> entry.getValue() instanceof BlockModel || entry.getValue() instanceof MultiVariant || entry.getValue() instanceof MultiPart;
this.unbakedCache.entrySet().removeIf(isVanillaModel);
this.topLevelModels.entrySet().removeIf(isVanillaModel);
}
@Inject(method = "uploadTextures", at = @At(value = "FIELD", target = "Lnet/minecraft/client/resources/model/ModelBakery;topLevelModels:Ljava/util/Map;", ordinal = 0), cancellable = true)
private void skipBake(TextureManager resourceManager, ProfilerFiller profiler, CallbackInfoReturnable<AtlasSet> cir) {
profiler.pop();
@ -287,10 +296,6 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
return super.put(key, value);
}
};
// discard unwrapped models
Predicate<Map.Entry<ResourceLocation, UnbakedModel>> isVanillaModel = entry -> entry.getValue() instanceof BlockModel || entry.getValue() instanceof MultiVariant || entry.getValue() instanceof MultiPart;
this.unbakedCache.entrySet().removeIf(isVanillaModel);
this.topLevelModels.entrySet().removeIf(isVanillaModel);
// bake indigo models
Stopwatch watch = Stopwatch.createStarted();
this.topLevelModels.forEach((key, value) -> {