Avoid fetching key state on background threads

This commit is contained in:
embeddedt 2023-03-26 09:17:03 -04:00
parent 5e81a49dc8
commit c37d91e476
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package org.embeddedt.modernfix.mixin.perf.async_jei;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(InputConstants.class)
public class InputConstantsMixin {
@Redirect(method = "isKeyDown", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwGetKey(JI)I"))
private static int offThreadKeyFetch(long win, int k) {
if(RenderSystem.isOnRenderThreadOrInit())
return GLFW.glfwGetKey(win, k);
else
return 0;
}
}

View File

@ -73,6 +73,7 @@
"perf.parallelize_model_loading.TransformationMatrixMixin",
"perf.parallelize_model_loading.BooleanPropertyMixin",
"perf.parallelize_model_loading.PropertyMixin",
"perf.async_jei.InputConstantsMixin",
"perf.async_jei.IngredientListElementFactoryMixin",
"perf.async_jei.ClientLifecycleHandlerMixin",
"perf.async_jei.JeiStarterMixin",