Class ClientChatReceivedEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.ClientChatReceivedEvent
- All Implemented Interfaces:
net.neoforged.bus.api.ICancellableEvent
- Direct Known Subclasses:
ClientChatReceivedEvent.Player
,ClientChatReceivedEvent.System
public class ClientChatReceivedEvent
extends net.neoforged.bus.api.Event
implements net.neoforged.bus.api.ICancellableEvent
Fired when a chat message is received on the client.
This can be used for filtering and detecting messages with specific words or phrases, and suppressing them.
This event is cancellable, and does not
.
If the event is cancelled, the message is not displayed in the chat message window.invalid reference
have a result
This event is fired on the main Forge event bus, only on the logical client.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Fired when a player chat message is received on the client.static class
Fired when a system chat message is received on the client. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final net.minecraft.network.chat.ChatType.Bound
private net.minecraft.network.chat.Component
private final UUID
-
Constructor Summary
ConstructorsConstructorDescriptionClientChatReceivedEvent
(net.minecraft.network.chat.ChatType.Bound boundChatType, net.minecraft.network.chat.Component message, UUID sender) -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.network.chat.ChatType.Bound
Returns the bound chat type of the chat message.net.minecraft.network.chat.Component
Returns the message that will be displayed in the chat message window, if the event is not cancelled.Returns the message sender.boolean
isSystem()
Returnstrue
if the message was sent by the system,false
otherwise.void
setMessage
(net.minecraft.network.chat.Component message) Sets the new message to be displayed in the chat message window, if the event is not cancelled.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
Field Details
-
message
private net.minecraft.network.chat.Component message -
boundChatType
@Nullable private final net.minecraft.network.chat.ChatType.Bound boundChatType -
sender
-
-
Constructor Details
-
ClientChatReceivedEvent
@Internal public ClientChatReceivedEvent(@Nullable net.minecraft.network.chat.ChatType.Bound boundChatType, net.minecraft.network.chat.Component message, UUID sender)
-
-
Method Details
-
getMessage
public net.minecraft.network.chat.Component getMessage()Returns the message that will be displayed in the chat message window, if the event is not cancelled.- Returns:
- the message that will be displayed in the chat message window, if the event is not cancelled
-
setMessage
public void setMessage(net.minecraft.network.chat.Component message) Sets the new message to be displayed in the chat message window, if the event is not cancelled.- Parameters:
message
- the new message to be displayed
-
getBoundChatType
@Nullable public net.minecraft.network.chat.ChatType.Bound getBoundChatType()Returns the bound chat type of the chat message.. This contains the chat type, display name of the sender, and nullable target name depending on the chat type.This may be
null
when the message doesn't have a specific source (i.e. for system messages).- Returns:
- the bound chat type of the chat message
-
getSender
Returns the message sender.. This will beUtil.NIL_UUID
if the message is a system message.- Returns:
- the message sender
-
isSystem
public boolean isSystem()Returnstrue
if the message was sent by the system,false
otherwise.- Returns:
true
if the message was sent by the system,false
otherwise
-