Added display name hook

This commit is contained in:
MachineMuse 2013-09-03 14:55:11 -06:00
parent d9b72a2282
commit 0e3037e85d
3 changed files with 28 additions and 0 deletions

View file

@ -75,4 +75,11 @@ public class ForgeEventFactory
MinecraftForge.EVENT_BUS.post(maxCanSpawnEvent);
return maxCanSpawnEvent.getResult() == Result.ALLOW ? maxCanSpawnEvent.maxPackSize : entity.getMaxSpawnedInChunk();
}
public static String getPlayerDisplayName(EntityPlayer player, String username)
{
PlayerEvent.NameFormat event = new PlayerEvent.NameFormat(player, username);
MinecraftForge.EVENT_BUS.post(event);
return event.displayname;
}
}

View file

@ -45,4 +45,16 @@ public class PlayerEvent extends LivingEvent
this.newSpeed = original;
}
}
public static class NameFormat extends PlayerEvent
{
public final String username;
public String displayname;
public NameFormat(EntityPlayer player, String username) {
super(player);
this.username = username;
this.displayname = username;
}
}
}

View file

@ -543,3 +543,12 @@
}
@SideOnly(Side.CLIENT)
@@ -2235,7 +2438,7 @@
*/
public String getTranslatedEntityName()
{
- return ScorePlayerTeam.formatPlayerName(this.getTeam(), this.username);
+ return ScorePlayerTeam.formatPlayerName(this.getTeam(), ForgeEventFactory.getPlayerDisplayName(this, this.username));
}
public void func_110149_m(float par1)