Merge remote-tracking branch 'origin/main' into 1.18

This commit is contained in:
embeddedt 2023-03-07 22:26:16 -05:00
commit 63fa31bde1
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
4 changed files with 31 additions and 61 deletions

View File

@ -22,6 +22,7 @@ public class ModernFixEarlyConfig {
this.addMixinRule("feature.branding", true);
this.addMixinRule("feature.measure_time", true);
this.addMixinRule("feature.reduce_loading_screen_freezes", false);
this.addMixinRule("feature.direct_stack_trace", false);
this.addMixinRule("perf.fast_registry_validation", true);
this.addMixinRule("perf.use_integrated_resources", true);
this.addMixinRule("perf.remove_biome_temperature_cache", true);
@ -42,7 +43,7 @@ public class ModernFixEarlyConfig {
this.addMixinRule("perf.faster_baking", true);
this.addMixinRule("perf.cache_model_materials", true);
this.addMixinRule("perf.datapack_reload_exceptions", true);
this.addMixinRule("perf.faster_texture_stitching", true);
this.addMixinRule("perf.faster_texture_stitching", false);
/* off by default in 1.18 because it doesn't work as well */
this.addMixinRule("perf.faster_singleplayer_load", false);
/* Keep this off if JEI isn't installed to prevent breaking vanilla gameplay */
@ -55,8 +56,9 @@ public class ModernFixEarlyConfig {
/* Mod compat */
disableIfModPresent("mixin.perf.thread_priorities", "smoothboot");
disableIfModPresent("mixin.perf.async_jei", "modernui");
disableIfModPresent("mixin.perf.compress_biome_container", "chocolate");
disableIfModPresent("mixin.perf.compress_biome_container", "chocolate", "betterendforge");
disableIfModPresent("mixin.bugfix.mc218112", "performant");
disableIfModPresent("mixin.perf.faster_baking", "touhou_little_maid");
}
private void disableIfModPresent(String configName, String... ids) {

View File

@ -0,0 +1,22 @@
package org.embeddedt.modernfix.mixin.feature.direct_stack_trace;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
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.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(CrashReport.class)
public class CrashReportMixin {
@Shadow @Final private Throwable exception;
@Inject(method = "addCategory(Ljava/lang/String;I)Lnet/minecraft/CrashReportCategory;", at = @At(value = "INVOKE", target = "Ljava/io/PrintStream;println(Ljava/lang/String;)V"))
private void dumpStacktrace(String s, int i, CallbackInfoReturnable<CrashReportCategory> cir) {
new Exception("ModernFix crash stacktrace").printStackTrace();
if(this.exception != null)
this.exception.printStackTrace();
}
}

View File

@ -1,75 +1,20 @@
package org.embeddedt.modernfix.mixin.perf.faster_baking;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.BlockModelShaper;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelManager;
import net.minecraft.client.renderer.texture.AtlasSet;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.client.model.ForgeModelBakery;
import org.embeddedt.modernfix.duck.IExtendedModelBakery;
import org.embeddedt.modernfix.models.LazyBakedModel;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import javax.annotation.Nullable;
import java.util.Map;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@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, ForgeModelBakery 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();
}
}

View File

@ -26,6 +26,7 @@
"feature.measure_time.ProfiledReloadInstanceMixin",
"feature.measure_time.ReloadableServerResourcesMixin",
"feature.branding.BrandingControlMixin",
"feature.direct_stack_trace.CrashReportMixin",
"perf.fast_registry_validation.ForgeRegistryMixin",
"perf.cache_strongholds.ChunkGeneratorMixin",
"perf.cache_upgraded_structures.StructureManagerMixin",