Minor optimization to ForgeRegistry.validateContent
This commit is contained in:
parent
7868bd90ee
commit
7f018c1ff7
|
|
@ -19,6 +19,7 @@ public class ModernFixEarlyConfig {
|
|||
this.addMixinRule("core", true); // TODO: Don't actually allow the user to disable this
|
||||
this.addMixinRule("feature.measure_time", true);
|
||||
this.addMixinRule("feature.reduce_loading_screen_freezes", false);
|
||||
this.addMixinRule("perf.fast_registry_validation", true);
|
||||
this.addMixinRule("perf.remove_biome_temperature_cache", true);
|
||||
this.addMixinRule("perf.resourcepacks", true);
|
||||
this.addMixinRule("perf.reduce_blockstate_cache_rebuilds", true);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
package org.embeddedt.modernfix.mixin.perf.fast_registry_validation;
|
||||
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
import net.minecraftforge.registries.ForgeRegistry;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@Mixin(value = ForgeRegistry.class, remap = false)
|
||||
public class ForgeRegistryMixin {
|
||||
private static Method bitSetTrimMethod = null;
|
||||
private static boolean bitSetTrimMethodRetrieved = false;
|
||||
|
||||
/**
|
||||
* Cache the result of findMethod instead of running it multiple times.
|
||||
* Null checks are not required as the surrounding code handles it already.
|
||||
*/
|
||||
@Redirect(method = "validateContent", at = @At(value = "INVOKE", target = "Lnet/minecraftforge/fml/common/ObfuscationReflectionHelper;findMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;"))
|
||||
private Method skipMultipleRemap(Class<?> clz, String methodName, Class<?>[] params) {
|
||||
if(!bitSetTrimMethodRetrieved) {
|
||||
bitSetTrimMethodRetrieved = true;
|
||||
bitSetTrimMethod = ObfuscationReflectionHelper.findMethod(clz, methodName, params);
|
||||
}
|
||||
return bitSetTrimMethod;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,8 @@
|
|||
"perf.kubejs.RecipeEventJSMixin",
|
||||
"perf.kubejs.RecipeJSMixin",
|
||||
"perf.kubejs.IDFilterMixin",
|
||||
"perf.kubejs.CustomIngredientMixin"
|
||||
"perf.kubejs.CustomIngredientMixin",
|
||||
"perf.fast_registry_validation.ForgeRegistryMixin"
|
||||
],
|
||||
"client": [
|
||||
"core.MinecraftMixin",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user