Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop "You can only sleep at night" message filling the chat #102

Merged
merged 3 commits into from
Sep 14, 2022

Conversation

Quarri6343
Copy link
Member

before
キャプチャ1626

after

Minecraft.1.7.10.2022-09-08.00-10-41.mp4

About printChatMessageWithOptionalDeletion second argument:
"0" will not delete any duplicated chat, "1" is occupied by vanilla, "2" is occupied by Forge, so I use 3

@Alexdoru
Copy link
Member

Alexdoru commented Sep 7, 2022

why would you click the bed ten times tho

if (event.message.equals(new ChatComponentTranslation("tile.bed.noSleep", new Object[0]))
|| event.message.equals(new ChatComponentTranslation("tile.bed.notSafe", new Object[0]))
|| event.message.equals(new ChatComponentTranslation("tile.bed.occupied", new Object[0]))) {
this.gameController.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(event.message, 3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo you shouldn't use the printChatMessageWithOptionalDeletion method since you don't know which other mod uses which message ids, and it might start deleting other chat messages that you don't expect.

If you want to delete chat messages you should make your own deleteChatLine method that iterates though private final List chatLines = new ArrayList(); private final List field_146253_i = new ArrayList();

like I did here https://github.com/Alexdoru/MegaWallsEnhancements/blob/4055c0d6434914bfeb89019d0299a2a85cea3a92/src/main/java/fr/alexdoru/megawallsenhancementsmod/asm/hooks/GuiNewChatHook.java#L26

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I just set the message id a very big number?
there are 2 billion channels so it should not cause conflicts if I set it like 251545647

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can I just set the message id a very big number? there are 2 billion channels so it should not cause conflicts if I set it like 251545647

Imperfect but sounds reasonable

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have HUD overlay above hotbar (GTNewHorizons/GTNHLib#7), so we can use that I guess

@Glease
Copy link
Contributor

Glease commented Sep 7, 2022

FIY there is a addChatThrottled api in structurelib that you can just steal or promote to gtnhlib.

@Dream-Master Dream-Master requested review from a team September 8, 2022 05:47
@Alexdoru
Copy link
Member

Alexdoru commented Sep 8, 2022

to be honest, it would be better to implement a simplified version of compact chat (that just checks the last message) rather than coding this for a single specific message

@Quarri6343
Copy link
Member Author

Compact chat may collapses important messages from other mods, especially debug messages
So I think specifying which message to delete is better in this situation
Adding addChatThrottled api is theoretically the best option but I don't want to port that just for three messages...

Copy link
Contributor

@Connor-Colenso Connor-Colenso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine for now. Thanks.

@Connor-Colenso Connor-Colenso merged commit 6ff95a3 into master Sep 14, 2022
@Connor-Colenso Connor-Colenso deleted the bed-patch branch September 14, 2022 00:03
@miozune miozune mentioned this pull request Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants