Add senderUUID to ClientChatReceivedEvent (#6881)

This commit is contained in:
Take Weiland authored and GitHub committed 2020-06-30 12:57:23 -07:00
1 parent ab29145328
commit d1016f752e
3 files changed
+29 -7

No files matched your search

@@ -30,7 +30,7 @@
public void func_147251_a(SChatPacket p_147251_1_) {
PacketThreadUtil.func_218797_a(p_147251_1_, this, this.field_147299_f);
- this.field_147299_f.field_71456_v.func_238450_a_(p_147251_1_.func_192590_c(), p_147251_1_.func_148915_c(), p_147251_1_.func_240810_e_());
+ net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_147251_1_.func_192590_c(), p_147251_1_.func_148915_c());
+ net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(p_147251_1_.func_192590_c(), p_147251_1_.func_148915_c(), p_147251_1_.func_240810_e_());
+ if (message == null) return;
+ this.field_147299_f.field_71456_v.func_238450_a_(p_147251_1_.func_192590_c(), message, p_147251_1_.func_240810_e_());
}
@@ -24,15 +24,27 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.eventbus.api.Cancelable;
import net.minecraftforge.eventbus.api.Event;
@net.minecraftforge.eventbus.api.Cancelable
public class ClientChatReceivedEvent extends net.minecraftforge.eventbus.api.Event
import javax.annotation.Nullable;
import java.util.UUID;
/**
* Fired on the client when a chat message is received.<br>
* If this event is cancelled, the message is not displayed in the chat message window.<br>
* Fired on {@link net.minecraftforge.common.MinecraftForge#EVENT_BUS}.
*/
@Cancelable
public class ClientChatReceivedEvent extends Event
{
private ITextComponent message;
private final ChatType type;
public ClientChatReceivedEvent(ChatType type, ITextComponent message)
@Nullable
private final UUID senderUUID;
public ClientChatReceivedEvent(ChatType type, ITextComponent message, @Nullable UUID senderUUID)
{
this.type = type;
this.setMessage(message);
this.message = message;
this.senderUUID = senderUUID;
}
public ITextComponent getMessage()
@@ -49,4 +61,14 @@ public class ClientChatReceivedEvent extends net.minecraftforge.eventbus.api.Eve
{
return type;
}
/**
* The UUID of the player or entity that sent this message, or null if not known.
* This will be equal to {@link net.minecraft.util.Util#field_240973_b_} for system messages.
*/
@Nullable
public UUID getSenderUUID()
{
return senderUUID;
}
}
@@ -330,9 +330,9 @@ public class ForgeEventFactory
}
@Nullable
public static ITextComponent onClientChat(ChatType type, ITextComponent message)
public static ITextComponent onClientChat(ChatType type, ITextComponent message, @Nullable UUID senderUUID)
{
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message);
ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message, senderUUID);
return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage();
}