Skip to content

Commit 07b8434

Browse files
committed
Fix for MC-122477 causing only backspace to work in textfields on linux (closes #77)
1 parent bd53640 commit 07b8434

File tree

5 files changed

+64
-11
lines changed

5 files changed

+64
-11
lines changed

changelogs/1.10.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- [MC-55347](https://bugs.mojang.com/browse/MC-55347) - Title with long duration shows in other world
44
- [MC-26757](https://bugs.mojang.com/browse/MC-26757) - Large item tooltips can get cut off at the edges of the screen *(fabric only)*
55

6+
**Rebugify no more!**
7+
8+
- Fix [MC-122477](https://bugs.mojang.com/browse/MC-122477) preventing some linux users from typing any characters in chat boxes.
9+
610
**Misc**
711

812
- On Quilt, require beta 15 or later because there is a crucial bug fix.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package cc.woverflow.debugify.fixes.mc122477;
2+
3+
public class KeyboardPollCounter {
4+
private static int count = 0;
5+
private static boolean requiresCount = false;
6+
7+
public static void poll() {
8+
if (requiresCount)
9+
count++;
10+
}
11+
12+
public static void startCounting() {
13+
requiresCount = true;
14+
}
15+
16+
public static void stopCountingAndReset() {
17+
requiresCount = false;
18+
count = 0;
19+
}
20+
21+
public static int getCount() {
22+
return count;
23+
}
24+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package cc.woverflow.debugify.mixins.basic.client.mc122477;
2+
3+
import cc.woverflow.debugify.fixes.BugFix;
4+
import cc.woverflow.debugify.fixes.FixCategory;
5+
import cc.woverflow.debugify.fixes.mc122477.KeyboardPollCounter;
6+
import com.mojang.blaze3d.systems.RenderSystem;
7+
import net.minecraft.util.Util;
8+
import org.spongepowered.asm.mixin.Mixin;
9+
import org.spongepowered.asm.mixin.injection.At;
10+
import org.spongepowered.asm.mixin.injection.Inject;
11+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
12+
13+
@BugFix(id = "MC-122477", category = FixCategory.BASIC, env = BugFix.Env.CLIENT)
14+
@Mixin(RenderSystem.class)
15+
public class RenderSystemMixin {
16+
@Inject(method = "flipFrame", at = @At(value = "INVOKE", target = "Lorg/lwjgl/glfw/GLFW;glfwPollEvents()V"))
17+
private static void onPollEvents(long window, CallbackInfo ci) {
18+
KeyboardPollCounter.poll();
19+
}
20+
}

common/src/main/java/cc/woverflow/debugify/mixins/basic/client/mc122477/TextFieldWidgetMixin.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import cc.woverflow.debugify.fixes.BugFix;
44
import cc.woverflow.debugify.fixes.FixCategory;
5+
import cc.woverflow.debugify.fixes.mc122477.KeyboardPollCounter;
6+
import net.minecraft.client.font.TextRenderer;
57
import net.minecraft.client.gui.widget.TextFieldWidget;
8+
import net.minecraft.text.Text;
69
import net.minecraft.util.Util;
710
import org.spongepowered.asm.mixin.Mixin;
811
import org.spongepowered.asm.mixin.Unique;
@@ -14,18 +17,19 @@
1417
@BugFix(id = "MC-122477", category = FixCategory.BASIC, env = BugFix.Env.CLIENT)
1518
@Mixin(TextFieldWidget.class)
1619
public class TextFieldWidgetMixin {
17-
@Unique
18-
private int debugify$ticks = 0;
19-
20-
@Inject(method = "tick", at = @At("HEAD"))
21-
private void onTick(CallbackInfo ci) {
22-
if (debugify$ticks < 2)
23-
debugify$ticks++;
20+
@Inject(method = "<init>(Lnet/minecraft/client/font/TextRenderer;IIIILnet/minecraft/client/gui/widget/TextFieldWidget;Lnet/minecraft/text/Text;)V", at = @At("RETURN"))
21+
private void startPolling(TextRenderer textRenderer, int x, int y, int width, int height, TextFieldWidget copyFrom, Text text, CallbackInfo ci) {
22+
KeyboardPollCounter.startCounting();
2423
}
2524

2625
@Inject(method = "charTyped", at = @At("HEAD"), cancellable = true)
2726
private void onCharTyped(char chr, int modifiers, CallbackInfoReturnable<Boolean> cir) {
28-
if (debugify$ticks <= 1 && Util.getOperatingSystem() == Util.OperatingSystem.LINUX)
29-
cir.setReturnValue(true);
27+
if (Util.getOperatingSystem() == Util.OperatingSystem.LINUX) {
28+
if (KeyboardPollCounter.getCount() == 1)
29+
cir.setReturnValue(true);
30+
31+
if (KeyboardPollCounter.getCount() >= 1)
32+
KeyboardPollCounter.stopCountingAndReset();
33+
}
3034
}
3135
}

common/src/main/resources/debugify-common.mixins.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"basic.client.mc116379.FishingBobberEntityRendererMixin",
1414
"basic.client.mc121772.MouseMixin",
1515
"basic.client.mc122477.TextFieldWidgetMixin",
16+
"basic.client.mc122477.RenderSystemMixin",
1617
"basic.client.mc122627.CommandSuggestorMixin",
1718
"basic.client.mc123739.ClientRecipeBookMixin",
1819
"basic.client.mc127970.HeldItemRendererMixin",
@@ -43,12 +44,12 @@
4344
"basic.client.mc53312.IllagerEntityModelMixin",
4445
"basic.client.mc53312.VillagerResemblingModelMixin",
4546
"basic.client.mc53312.ZombieVillagerEntityModelMixin",
47+
"basic.client.mc55347.InGameHudMixin",
4648
"basic.client.mc79545.InGameHudMixin",
4749
"basic.client.mc80859.HandledScreenMixin",
4850
"basic.client.mc93384.LivingEntityMixin",
4951
"gameplay.client.mc12829.LivingEntityMixin",
50-
"gameplay.client.mc12829.PlayerEntityMixin",
51-
"basic.client.mc55347.InGameHudMixin"
52+
"gameplay.client.mc12829.PlayerEntityMixin"
5253
],
5354
"mixins": [
5455
"basic.server.mc100991.FishingBobberEntityMixin",

0 commit comments

Comments
 (0)