The EntityPlayer class is part of the Minecraft Java Edition API and can be found in the net.minecraft.entity.player package. One of its methods is getDisplayName(), which returns the name that is displayed for the player in the game.
Example 1:
EntityPlayer player = ...; // get reference to a player String displayName = player.getDisplayName().getFormattedText(); // gets the display name of the player as a string
Example 2:
EntityPlayer player = ...; // get reference to a player ITextComponent displayName = player.getDisplayName(); // gets the display name of the player as an ITextComponent object, which provides formatting options
In both examples, we are using the getDisplayName() method to retrieve the name of a player. The first example retrieves the name as a string, while the second example retrieves it as an ITextComponent object.
The package library for this class is net.minecraft.entity.player.
Java EntityPlayer.getDisplayName - 25 examples found. These are the top rated real world Java examples of net.minecraft.entity.player.EntityPlayer.getDisplayName extracted from open source projects. You can rate examples to help us improve the quality of examples.