Suppress exception stacktraces for datapack reloads by default

This commit is contained in:
embeddedt 2023-02-11 12:26:45 -05:00
parent cc77da1027
commit af63b3ed11
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
4 changed files with 34 additions and 0 deletions

View File

@ -41,6 +41,7 @@ public class ModernFixEarlyConfig {
this.addMixinRule("perf.cache_blockstate_cache_arrays", true);
this.addMixinRule("perf.faster_baking", true);
this.addMixinRule("perf.cache_model_materials", true);
this.addMixinRule("perf.datapack_reload_exceptions", true);
/* Keep this off if JEI isn't installed to prevent breaking vanilla gameplay */
this.addMixinRule("perf.blast_search_trees", FMLLoader.getLoadingModList().getModFileById("jei") != null);
this.addMixinRule("safety", true);

View File

@ -0,0 +1,16 @@
package org.embeddedt.modernfix.mixin.perf.datapack_reload_exceptions;
import net.minecraft.loot.LootTableManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(LootTableManager.class)
public class LootTableManagerMixin {
@Redirect(method = "*(Lnet/minecraft/resources/IResourceManager;Lcom/google/common/collect/ImmutableMap$Builder;Lnet/minecraft/util/ResourceLocation;Lcom/google/gson/JsonElement;)V",
at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"))
private void logWithoutStacktrace(Logger instance, String s, Object location, Object exc) {
instance.error(s + ": {}", location, exc.toString());
}
}

View File

@ -0,0 +1,15 @@
package org.embeddedt.modernfix.mixin.perf.datapack_reload_exceptions;
import net.minecraft.item.crafting.RecipeManager;
import org.apache.logging.log4j.Logger;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(RecipeManager.class)
public class RecipeManagerMixin {
@Redirect(method = "apply(Ljava/util/Map;Lnet/minecraft/resources/IResourceManager;Lnet/minecraft/profiler/IProfiler;)V", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;error(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V"))
private void silenceException(Logger instance, String s, Object location, Object exc) {
instance.error(s + ": {}", location, exc.toString());
}
}

View File

@ -25,6 +25,8 @@
"perf.compress_biome_container.MixinBiomeContainer",
"perf.nuke_empty_chunk_sections.MixinChunk",
"perf.cache_blockstate_cache_arrays.AbstractBlockStateCacheMixin",
"perf.datapack_reload_exceptions.LootTableManagerMixin",
"perf.datapack_reload_exceptions.RecipeManagerMixin",
"feature.measure_time.BootstrapMixin"
],
"client": [