Return to baking models on the main thread
Mods... as usual.
This commit is contained in:
parent
5df695cbbb
commit
7a2b57221e
|
|
@ -31,47 +31,10 @@ import java.util.Map;
|
|||
|
||||
@Mixin(ModelManager.class)
|
||||
public class ModelManagerMixin {
|
||||
@Shadow @Nullable private AtlasSet atlases;
|
||||
|
||||
@Shadow private Map<ResourceLocation, BakedModel> bakedRegistry;
|
||||
|
||||
@Shadow private Object2IntMap<BlockState> modelGroups;
|
||||
|
||||
@Shadow @Final private TextureManager textureManager;
|
||||
|
||||
@Shadow private BakedModel missingModel;
|
||||
|
||||
@Shadow @Final private BlockModelShaper blockModelShaper;
|
||||
|
||||
@Inject(method = "prepare(Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)Lnet/minecraft/client/resources/model/ModelBakery;", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiling/ProfilerFiller;endTick()V"), locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
private void fireModelBakeEvent(ResourceManager pResourceManager, ProfilerFiller pProfiler, CallbackInfoReturnable<ModelBakery> cir, ModelLoader pObject) {
|
||||
pProfiler.push("modelevent");
|
||||
if (this.atlases != null) {
|
||||
Minecraft.getInstance().executeBlocking(() -> {
|
||||
this.atlases.close();
|
||||
});
|
||||
}
|
||||
this.atlases = ((IExtendedModelBakery)(Object)pObject).getUnfinishedAtlasSet();
|
||||
this.bakedRegistry = pObject.getBakedTopLevelModels();
|
||||
this.modelGroups = pObject.getModelGroups();
|
||||
this.missingModel = this.bakedRegistry.get(ModelBakery.MISSING_MODEL_LOCATION);
|
||||
net.minecraftforge.client.ForgeHooksClient.onModelBake((ModelManager)(Object)this, this.bakedRegistry, pObject);
|
||||
pProfiler.popPush("cache");
|
||||
this.blockModelShaper.rebuildCache();
|
||||
pProfiler.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
* @reason most of the code is moved to prepare()
|
||||
*/
|
||||
@Overwrite
|
||||
protected void apply(ModelBakery pObject, ResourceManager pResourceManager, ProfilerFiller pProfiler) {
|
||||
pProfiler.startTick();
|
||||
pProfiler.push("upload");
|
||||
this.atlases = pObject.uploadTextures(this.textureManager, pProfiler);
|
||||
pProfiler.pop();
|
||||
@Inject(method = "apply(Lnet/minecraft/client/resources/model/ModelBakery;Lnet/minecraft/server/packs/resources/ResourceManager;Lnet/minecraft/util/profiling/ProfilerFiller;)V",
|
||||
at = @At(value = "RETURN"))
|
||||
private void allowBake(ModelBakery pObject, ResourceManager pResourceManager, ProfilerFiller pProfiler, CallbackInfo ci) {
|
||||
LazyBakedModel.allowBakeForFlags = true;
|
||||
pProfiler.endTick();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user