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()));
|
||||
}
|
||||
@@ -764,7 +792,9 @@
|
||||
@@ -764,8 +792,10 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- 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));
|
||||
+ chatcomponenttranslation1 = ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1);
|
||||
+ if (chatcomponenttranslation1 == null) return;
|
||||
this.field_147367_d.func_71203_ab().func_148544_a(chatcomponenttranslation1, false);
|
||||
+ IChatComponent chat = ForgeHooks.onServerChatEvent(this, s, chatcomponenttranslation1);
|
||||
+ if (chat == null) return;
|
||||
+ this.field_147367_d.func_71203_ab().func_148544_a(chat, false);
|
||||
}
|
||||
|
||||
this.field_147374_l += 20;
|
||||
@@ -907,7 +937,7 @@
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.IChatComponent;
|
||||
|
||||
/**
|
||||
* ServerChatEvent is fired whenever a C01PacketChatMessage is processed. <br>
|
||||
|
@ -27,6 +28,7 @@ public class ServerChatEvent extends Event
|
|||
{
|
||||
public final String message, username;
|
||||
public final EntityPlayerMP player;
|
||||
@Deprecated //Use methods below
|
||||
public 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.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