Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MinecraftForge
GitHub Repository: MinecraftForge/MinecraftForge
Path: blob/1.21.x/patches/minecraft/net/minecraft/client/multiplayer/chat/ChatListener.java.patch
7412 views
1
--- a/net/minecraft/client/multiplayer/chat/ChatListener.java
2
+++ b/net/minecraft/client/multiplayer/chat/ChatListener.java
3
@@ -133,7 +_,9 @@
4
Instant instant = Instant.now();
5
this.handleMessage(null, () -> {
6
Component component = p_251256_.decorate(p_250375_);
7
- this.minecraft.gui.getChat().addMessage(component);
8
+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientChat(p_251256_, component, Util.NIL_UUID);
9
+ if (forgeComponent == null) return false;
10
+ this.minecraft.gui.getChat().addMessage(forgeComponent);
11
this.narrateChatMessage(p_251256_, p_250375_);
12
this.logSystemMessage(component, instant);
13
this.previousMessageTime = Util.getMillis();
14
@@ -152,12 +_,16 @@
15
MessageSignature messagesignature = p_249430_.signature();
16
FilterMask filtermask = p_249430_.filterMask();
17
if (filtermask.isEmpty()) {
18
- this.minecraft.gui.getChat().addMessage(p_249231_, messagesignature, guimessagetag);
19
+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(p_251766_, p_249231_, p_249430_, p_249430_.sender());
20
+ if (forgeComponent == null) return false;
21
+ this.minecraft.gui.getChat().addMessage(forgeComponent, messagesignature, guimessagetag);
22
this.narrateChatMessage(p_251766_, p_249430_.decoratedContent());
23
} else {
24
Component component = filtermask.applyWithFormatting(p_249430_.signedContent());
25
if (component != null) {
26
- this.minecraft.gui.getChat().addMessage(p_251766_.decorate(component), messagesignature, guimessagetag);
27
+ Component forgeComponent = net.minecraftforge.client.ForgeHooksClient.onClientPlayerChat(p_251766_, p_251766_.decorate(component), p_249430_, p_249430_.sender());
28
+ if (forgeComponent == null) return false;
29
+ this.minecraft.gui.getChat().addMessage(forgeComponent, messagesignature, guimessagetag);
30
this.narrateChatMessage(p_251766_, component);
31
}
32
}
33
@@ -190,6 +_,8 @@
34
35
public void handleSystemMessage(Component p_240522_, boolean p_240642_) {
36
if (!this.minecraft.options.hideMatchedNames().get() || !this.minecraft.isBlocked(this.guessChatUUID(p_240522_))) {
37
+ p_240522_ = net.minecraftforge.client.ForgeHooksClient.onClientSystemMessage(p_240522_, p_240642_);
38
+ if (p_240522_ == null) return;
39
if (p_240642_) {
40
this.minecraft.gui.setOverlayMessage(p_240522_, false);
41
this.minecraft.getNarrator().saySystemQueued(p_240522_);
42
43