Avoid fetching key state on background threads
This commit is contained in:
parent
5e81a49dc8
commit
c37d91e476
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -73,6 +73,7 @@
|
||||||
"perf.parallelize_model_loading.TransformationMatrixMixin",
|
"perf.parallelize_model_loading.TransformationMatrixMixin",
|
||||||
"perf.parallelize_model_loading.BooleanPropertyMixin",
|
"perf.parallelize_model_loading.BooleanPropertyMixin",
|
||||||
"perf.parallelize_model_loading.PropertyMixin",
|
"perf.parallelize_model_loading.PropertyMixin",
|
||||||
|
"perf.async_jei.InputConstantsMixin",
|
||||||
"perf.async_jei.IngredientListElementFactoryMixin",
|
"perf.async_jei.IngredientListElementFactoryMixin",
|
||||||
"perf.async_jei.ClientLifecycleHandlerMixin",
|
"perf.async_jei.ClientLifecycleHandlerMixin",
|
||||||
"perf.async_jei.JeiStarterMixin",
|
"perf.async_jei.JeiStarterMixin",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user