Fix lag spike upon opening inventory or crafting table for the first time
This commit is contained in:
parent
a53fc02f07
commit
4f401d0653
|
@ -1,26 +0,0 @@
|
||||||
package dev.pfaff.recipe_nope.injector;
|
|
||||||
|
|
||||||
import org.objectweb.asm.tree.AnnotationNode;
|
|
||||||
import org.objectweb.asm.tree.MethodNode;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
|
||||||
import org.spongepowered.asm.mixin.injection.code.Injector;
|
|
||||||
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
|
|
||||||
import org.spongepowered.asm.mixin.transformer.MixinTargetContext;
|
|
||||||
|
|
||||||
@InjectionInfo.AnnotationType(Redirect.class)
|
|
||||||
@InjectionInfo.HandlerPrefix("redirect")
|
|
||||||
public final class ForceUnconstrainedRedirectInjectionInfo extends InjectionInfo {
|
|
||||||
public ForceUnconstrainedRedirectInjectionInfo(MixinTargetContext mixin, MethodNode method, AnnotationNode annotation) {
|
|
||||||
super(mixin, method, annotation);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Injector parseInjector(AnnotationNode injectAnnotation) {
|
|
||||||
return new UnconstrainedRedirectInjector(this, "@Redirect");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getDescription() {
|
|
||||||
return "UnconstrainedRedirector";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
package dev.pfaff.recipe_nope.mixin;
|
package dev.pfaff.recipe_nope.mixin;
|
||||||
|
|
||||||
import dev.pfaff.recipe_nope.injector.UnconstrainedRedirect;
|
|
||||||
import net.minecraft.client.ClientRecipeBook;
|
import net.minecraft.client.ClientRecipeBook;
|
||||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
import net.minecraft.client.multiplayer.ClientPacketListener;
|
||||||
import net.minecraft.world.item.crafting.Recipe;
|
import net.minecraft.world.item.crafting.Recipe;
|
||||||
|
@ -10,10 +9,12 @@ import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
||||||
@Mixin(ClientPacketListener.class)
|
@Mixin(ClientPacketListener.class)
|
||||||
public abstract class ClientPlayNetworkHandlerMixin {
|
public abstract class ClientPlayNetworkHandlerMixin {
|
||||||
@UnconstrainedRedirect(method = "*", at = @At(value = "NEW", target = "()Lnet/minecraft/client/ClientRecipeBook;"))
|
// for some reason the exact method name does not work outside of dev environment, and using wildcard causes game
|
||||||
private ClientRecipeBook onGameJoin$noRecipeBook() {
|
// to freeze upon opening crafting table the first time (why then and not upon world join?)
|
||||||
return null;
|
//@UnconstrainedRedirect(method = "*", at = @At(value = "NEW", target = "()Lnet/minecraft/client/ClientRecipeBook;"))
|
||||||
}
|
//private ClientRecipeBook onGameJoin$noRecipeBook() {
|
||||||
|
// return null;
|
||||||
|
//}
|
||||||
|
|
||||||
@Redirect(method = "handleUpdateRecipes", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/ClientRecipeBook;setupCollections(Ljava/lang/Iterable;)V"))
|
@Redirect(method = "handleUpdateRecipes", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/ClientRecipeBook;setupCollections(Ljava/lang/Iterable;)V"))
|
||||||
private void onSynchronizeRecipes$noRecipeBook(ClientRecipeBook instance, Iterable<Recipe<?>> recipes) {
|
private void onSynchronizeRecipes$noRecipeBook(ClientRecipeBook instance, Iterable<Recipe<?>> recipes) {
|
||||||
|
|
Loading…
Reference in New Issue