Include ModernFix itself in time calculations for dynamic resources

This commit is contained in:
embeddedt 2025-05-19 11:02:07 -04:00
parent 6df33005a7
commit af526b9113
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -33,14 +33,18 @@ public class ForgeHooksClientMixin {
if(!ModLoader.isLoadingStateValid())
return;
ModelEvent.ModifyBakingResult bakeEvent = ((ModelEvent.ModifyBakingResult)event);
ModelBakeEventHelper helper = new ModelBakeEventHelper(bakeEvent.getModels());
Method acceptEv = ObfuscationReflectionHelper.findMethod(ModContainer.class, "acceptEvent", Event.class);
Stopwatch globalTimer = Stopwatch.createStarted();
Stopwatch selfTimer = Stopwatch.createStarted();
ModelBakeEventHelper helper = new ModelBakeEventHelper(bakeEvent.getModels());
selfTimer.stop();
Method acceptEv = ObfuscationReflectionHelper.findMethod(ModContainer.class, "acceptEvent", Event.class);
Map<String, Stopwatch> times = new Object2ObjectOpenHashMap<>();
times.put("modernfix", selfTimer);
ModList.get().forEachModContainer((id, mc) -> {
Map<ResourceLocation, BakedModel> newRegistry = helper.wrapRegistry(id);
ModelEvent.ModifyBakingResult postedEvent = new ModelEvent.ModifyBakingResult(newRegistry, bakeEvent.getModelBakery());
Stopwatch timer = times.computeIfAbsent(id, $ -> Stopwatch.createStarted());
Stopwatch timer = times.computeIfAbsent(id, $ -> Stopwatch.createUnstarted());
timer.start();
try {
acceptEv.invoke(mc, postedEvent);
} catch(ReflectiveOperationException e) {