Loosen up ServerChatEvent to support IChatComponent Closes #1893
This commit is contained in:
parent
8d7b999506
commit
df5e594e95
2 changed files with 22 additions and 5 deletions
|
@ -130,17 +130,19 @@
|
||||||
{
|
{
|
||||||
this.func_147359_a(new S2FPacketSetSlot(this.field_147369_b.field_71070_bA.field_75152_c, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g()));
|
this.func_147359_a(new S2FPacketSetSlot(this.field_147369_b.field_71070_bA.field_75152_c, slot.field_75222_d, this.field_147369_b.field_71071_by.func_70448_g()));
|
||||||
}
|
}
|
||||||
@@ -764,7 +792,9 @@
|
@@ -764,8 +792,10 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
- ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", new Object[] {this.field_147369_b.func_145748_c_(), s});
|
- ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", new Object[] {this.field_147369_b.func_145748_c_(), s});
|
||||||
|
- this.field_147367_d.func_71203_ab().func_148544_a(chatcomponenttranslation1, false);
|
||||||
+ ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", this.field_147369_b.func_145748_c_(), ForgeHooks.newChatWithLinks(s));
|
+ ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("chat.type.text", this.field_147369_b.func_145748_c_(), ForgeHooks.newChatWithLinks(s));
|
||||||
+ chatcomponenttranslation1 = ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1);
|
+ IChatComponent chat = ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1);
|
||||||
+ if (chatcomponenttranslation1 == null) return;
|
+ if (chat == null) return;
|
||||||
this.field_147367_d.func_71203_ab().func_148544_a(chatcomponenttranslation1, false);
|
+ this.field_147367_d.func_71203_ab().func_148544_a(chat, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.field_147374_l += 20;
|
||||||
@@ -907,7 +937,7 @@
|
@@ -907,7 +937,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,11 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.util.ChatComponentTranslation;
|
import net.minecraft.util.ChatComponentTranslation;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServerChatEvent is fired whenever a C01PacketChatMessage is processed. <br>
|
* ServerChatEvent is fired whenever a C01PacketChatMessage is processed. <br>
|
||||||
* This event is fired via {@link ForgeHooks#onServerChatEvent(net.minecraft.network.NetHandlerPlayServer, String, ChatComponentTranslation)},
|
* This event is fired via {@link ForgeHooks#onServerChatEvent(net.minecraft.network.NetHandlerPlayServer, String, ChatComponentTranslation)},
|
||||||
* which is executed by the NetHandlerPlayServer#processChatMessage(net.minecraft.network.play.client.C01PacketChatMessage)<br>
|
* which is executed by the NetHandlerPlayServer#processChatMessage(net.minecraft.network.play.client.C01PacketChatMessage)<br>
|
||||||
* <br>
|
* <br>
|
||||||
* {@link #username} contains the username of the player sending the chat message.<br>
|
* {@link #username} contains the username of the player sending the chat message.<br>
|
||||||
|
@ -27,6 +28,7 @@ public class ServerChatEvent extends Event
|
||||||
{
|
{
|
||||||
public final String message, username;
|
public final String message, username;
|
||||||
public final EntityPlayerMP player;
|
public final EntityPlayerMP player;
|
||||||
|
@Deprecated //Use methods below
|
||||||
public ChatComponentTranslation component;
|
public ChatComponentTranslation component;
|
||||||
public ServerChatEvent(EntityPlayerMP player, String message, ChatComponentTranslation component)
|
public ServerChatEvent(EntityPlayerMP player, String message, ChatComponentTranslation component)
|
||||||
{
|
{
|
||||||
|
@ -36,4 +38,17 @@ public class ServerChatEvent extends Event
|
||||||
this.username = player.getGameProfile().getName();
|
this.username = player.getGameProfile().getName();
|
||||||
this.component = component;
|
this.component = component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setComponent(IChatComponent e)
|
||||||
|
{
|
||||||
|
if (e instanceof ChatComponentTranslation)
|
||||||
|
this.component = (ChatComponentTranslation)e;
|
||||||
|
else
|
||||||
|
this.component = new ChatComponentTranslation("%s", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IChatComponent getComponent()
|
||||||
|
{
|
||||||
|
return this.component;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue