Patch OBJLoader to support parallel loading

Fixes #4
This commit is contained in:
embeddedt 2023-01-06 10:49:45 -05:00
parent f43d54eafd
commit 75695cf759
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package org.embeddedt.modernfix.mixin.perf.parallelize_model_loading;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.obj.MaterialLibrary;
import net.minecraftforge.client.model.obj.OBJLoader;
import net.minecraftforge.client.model.obj.OBJModel;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Mixin(OBJLoader.class)
public class OBJLoaderMixin {
@Shadow private Map<ResourceLocation, MaterialLibrary> materialCache;
@Shadow private Map<OBJModel.ModelSettings, OBJModel> modelCache;
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraftforge/client/model/obj/OBJLoader;materialCache:Ljava/util/Map;"))
private void useConcMap1(OBJLoader instance, Map<ResourceLocation, MaterialLibrary> value) {
this.materialCache = new ConcurrentHashMap<>();
}
@Redirect(method = "<init>", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraftforge/client/model/obj/OBJLoader;modelCache:Ljava/util/Map;"))
private void useConcMap2(OBJLoader instance, Map<ResourceLocation, MaterialLibrary> value) {
this.modelCache = new ConcurrentHashMap<>();
}
}

View File

@ -23,6 +23,7 @@
"bugfix.concurrency.RenderTypeMixin",
"bugfix.concurrency.MinecraftMixin",
"perf.parallelize_model_loading.ModelBakeryMixin",
"perf.parallelize_model_loading.OBJLoaderMixin",
"perf.trim_model_caches.ModelManagerMixin",
"perf.async_jei.IngredientListElementFactoryMixin",
"perf.async_jei.ClientLifecycleHandlerMixin",