AntiRix Posted November 1, 2018 Posted November 1, 2018 Hi, I'm trying to cancel the default screenshot message "Screenshot saved as xxx.png" and write something else to chat. Unfortunately, because it's client-side, ClientChatReceivedEvent isn't fired. Is there a simple way rather than perhaps overriding ScreenshotHelper or capturing keypresses and handling the screenshot-taking myself? Quote
AntiRix Posted November 1, 2018 Author Posted November 1, 2018 Oh excellent, I couldn't find anything about it on the internet. I'll have to look at the files directly in future. Quote
AntiRix Posted November 1, 2018 Author Posted November 1, 2018 While I'm here, on the topic, are you aware of any way to detect any message being placed in chat for any reason, and a way to remove specific messages from chat? I'd like to remove any instances of multiple empty lines to avoid big spaces in chat, and just allow one empty line between two sets of text. Quote
V0idWa1k3r Posted November 1, 2018 Posted November 1, 2018 Well, there isn't an event for detecting any chat message but there is a ClientChatEvent that is fired every time most messages get added to the client's chat. It may not work for something like command messages though. For stuff like that you will need to manually check for changes in the client's chat. You can use GuiNewChat.chatLines to get all the chat lines(private, needs reflection) or GuiNewChat#getSentMessages(only works for the messages the client sent at any point, not the received ones) and check for changes in those lists, then modify them if you need it. You can get an instance of GuiNewChat with GuiIngame#getChatGUI and you can get an instance of GuiIngame with Minecraft.ingameGUI 1 Quote
AntiRix Posted November 1, 2018 Author Posted November 1, 2018 Ok great, I'll have a look into that. I'm trying to remove the default message, and instead, write an empty line, a message, then another empty line to the chat. I've tried setting the result message to null, new TextComponentString(null), but the former simply doesn't work and the latter crashes the game. Is there any way to actually remove that message apart from either canceling everything, saving the file myself and then displaying my message, or setting the result message to null, sending one blank line and my message, then allowing the event to write that final empty line from the result message? Quote
V0idWa1k3r Posted November 1, 2018 Posted November 1, 2018 12 minutes ago, AntiRix said: I've tried setting the result message to null This tells forge to do nothing and proceed with the default game logic. 12 minutes ago, AntiRix said: new TextComponentString(null) The string passed to TextComponentString can't be null. 13 minutes ago, AntiRix said: I'm trying to remove the default message, and instead, write an empty line, a message, then another empty line to the chat. Well set the message returned by the event to the empty line. Not null, but an empty string. Then send an empty line and your message to the chat. The order is reversed because the event's message is the one that is displayed last. Quote
AntiRix Posted November 1, 2018 Author Posted November 1, 2018 Just now, V0idWa1k3r said: Well set the message returned by the event to the empty line. Not null, but an empty string. Then send an empty line and your message to the chat. The order is reversed because the event's message is the one that is displayed last Yep, I thought I might have to resort to that. Quote
Recommended Posts
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.