Jump to content

Recommended Posts

Posted

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?

Posted

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.

Posted

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

  • Like 1
Posted

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?

Posted
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.

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.