Posted June 26, 201411 yr Is there a way on the client side to check if the player is typing in the chat? Kain
June 26, 201411 yr This is a bit of a joke.... But: BIND EVERY KEY!!!! Good question this. We all stuff up sometimes... But I seem to be at the bottom of that pot.
June 26, 201411 yr If you mean typing anything (including movement keys) then you can of course just use key input event handling. You might also be able to be clever and check for chat entry and exit, but might be a bit tough to ensure you're in sync with when it is actually in chat. I think the best way might be to detect when the chat gui is open. The GuiNewChat class has a public method called isChatOpen(). There is only one GuiNewChat instance per client (it is persistent because it has to keep track of all the previous chat entries) which can be retrieved with the public method called getChatGui() in the GuiIngame class. The GuiIngame class is extended by Forge and there seems to be one public instance in the Minecraft class. So...I think (haven't tried it) that you can use (only on client side!) Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatOpen() to check if chat is being entered. It should be true when open. You could check it every tick I guess in some sort of tick method or event handler, or you could check during key input event to save some processing burden. EDIT: I just tried this and you have to use a tick handler -- key input events actually DON'T fire while chat interface is up. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
June 26, 201411 yr Okay, I tried this out and it works well. Subscribe to rendertick event on FML bus and used following method: @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(RenderTickEvent event) { // DEBUG if (Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatOpen()) { System.out.println("Chat is open"); } } And it printed "Chat is open" over and over on console when I either opened the command line with "/" or a chat with "T". It stopped printing to the console when I pressed ESC to get out of chat. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.