Created
July 18, 2023 19:12
-
-
Save Ensamisten/b48046bb1d56ea272700481c86deb71e to your computer and use it in GitHub Desktop.
A Mixin in Java for Fabric (Minecraft 1.20.1) which prints "Player is typing..." each time a letter is written manually in the chat box.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Mixin(TextFieldWidget.class) | |
| public abstract class PlayerIsTyping { | |
| @Unique | |
| public abstract String charTyped(char chr, int modifiers); | |
| @Inject(at = @At("RETURN"), method = "charTyped") | |
| public void type(char chr, int modifiers, CallbackInfoReturnable<Boolean> cir) { | |
| if (cir.getReturnValue()) { | |
| assert MinecraftClient.getInstance().player != null; | |
| boolean returnValue = Boolean.parseBoolean(String.valueOf(cir.getReturnValue())); | |
| if (returnValue) { | |
| // The description of the action | |
| String message = MinecraftClient.getInstance().player.getName().getString() + " is typing..."; | |
| // Send the chat message to the player | |
| MinecraftClient.getInstance().player.sendMessage(Text.of(message)); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment