本文整理汇总了Java中net.minecraft.util.ChatComponentTranslation类的典型用法代码示例。如果您正苦于以下问题:Java ChatComponentTranslation类的具体用法?Java ChatComponentTranslation怎么用?Java ChatComponentTranslation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ChatComponentTranslation类属于net.minecraft.util包,在下文中一共展示了ChatComponentTranslation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisplayName
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public IChatComponent getDisplayName()
{
if (this.hasCustomName())
{
ChatComponentText chatcomponenttext = new ChatComponentText(this.entityName);
chatcomponenttext.getChatStyle().setChatHoverEvent(this.getHoverEvent());
chatcomponenttext.getChatStyle().setInsertion(this.getUniqueID().toString());
return chatcomponenttext;
}
else
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(this.getName(), new Object[0]);
chatcomponenttranslation.getChatStyle().setChatHoverEvent(this.getHoverEvent());
chatcomponenttranslation.getChatStyle().setInsertion(this.getUniqueID().toString());
return chatcomponenttranslation;
}
}
示例2: func_152892_c
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
public void func_152892_c(ErrorCode p_152892_1_)
{
if (p_152892_1_ == ErrorCode.TTV_EC_SOUNDFLOWER_NOT_INSTALLED)
{
IChatComponent ichatcomponent = new ChatComponentTranslation("stream.unavailable.soundflower.chat.link", new Object[0]);
ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://help.mojang.com/customer/portal/articles/1374877-configuring-soundflower-for-streaming-on-apple-computers"));
ichatcomponent.getChatStyle().setUnderlined(Boolean.valueOf(true));
IChatComponent ichatcomponent1 = new ChatComponentTranslation("stream.unavailable.soundflower.chat", new Object[] {ichatcomponent});
ichatcomponent1.getChatStyle().setColor(EnumChatFormatting.DARK_RED);
this.mc.ingameGUI.getChatGUI().printChatMessage(ichatcomponent1);
}
else
{
IChatComponent ichatcomponent2 = new ChatComponentTranslation("stream.unavailable.unknown.chat", new Object[] {ErrorCode.getString(p_152892_1_)});
ichatcomponent2.getChatStyle().setColor(EnumChatFormatting.DARK_RED);
this.mc.ingameGUI.getChatGUI().printChatMessage(ichatcomponent2);
}
}
示例3: listObjectives
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
protected void listObjectives(ICommandSender p_147196_1_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
Collection<ScoreObjective> collection = scoreboard.getScoreObjectives();
if (collection.size() <= 0)
{
throw new CommandException("commands.scoreboard.objectives.list.empty", new Object[0]);
}
else
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.objectives.list.count", new Object[] {Integer.valueOf(collection.size())});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
p_147196_1_.addChatMessage(chatcomponenttranslation);
for (ScoreObjective scoreobjective : collection)
{
p_147196_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.objectives.list.entry", new Object[] {scoreobjective.getName(), scoreobjective.getDisplayName(), scoreobjective.getCriteria().getName()}));
}
}
}
示例4: initStats
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
private static void initStats()
{
for (Item item : Item.itemRegistry)
{
if (item != null)
{
int i = Item.getIdFromItem(item);
String s = func_180204_a(item);
if (s != null)
{
objectUseStats[i] = (new StatCrafting("stat.useItem.", s, new ChatComponentTranslation("stat.useItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
if (!(item instanceof ItemBlock))
{
itemStats.add((StatCrafting)objectUseStats[i]);
}
}
}
}
replaceAllSimilarBlocks(objectUseStats);
}
示例5: isEntityTypeValid
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
private static <T extends Entity> boolean isEntityTypeValid(ICommandSender commandSender, Map<String, String> params)
{
String s = func_179651_b(params, "type");
s = s != null && s.startsWith("!") ? s.substring(1) : s;
if (s != null && !EntityList.isStringValidEntityName(s))
{
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.generic.entity.invalidType", new Object[] {s});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
commandSender.addChatMessage(chatcomponenttranslation);
return false;
}
else
{
return true;
}
}
示例6: initItemDepleteStats
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
private static void initItemDepleteStats()
{
for (Item item : Item.itemRegistry)
{
if (item != null)
{
int i = Item.getIdFromItem(item);
String s = func_180204_a(item);
if (s != null && item.isDamageable())
{
objectBreakStats[i] = (new StatCrafting("stat.breakItem.", s, new ChatComponentTranslation("stat.breakItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
}
}
}
replaceAllSimilarBlocks(objectBreakStats);
}
示例7: initMiningStats
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
private static void initMiningStats()
{
for (Block block : Block.blockRegistry)
{
Item item = Item.getItemFromBlock(block);
if (item != null)
{
int i = Block.getIdFromBlock(block);
String s = func_180204_a(item);
if (s != null && block.getEnableStats())
{
mineBlockStatArray[i] = (new StatCrafting("stat.mineBlock.", s, new ChatComponentTranslation("stat.mineBlock", new Object[] {(new ItemStack(block)).getChatComponent()}), item)).registerStat();
objectMineStats.add((StatCrafting)mineBlockStatArray[i]);
}
}
}
replaceAllSimilarBlocks(mineBlockStatArray);
}
示例8: func_110669_a
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
private void func_110669_a(ICommandSender p_110669_1_, List<Entity> p_110669_2_, CommandSpreadPlayers.Position p_110669_3_, double p_110669_4_, double p_110669_6_, World worldIn, boolean p_110669_9_) throws CommandException
{
Random random = new Random();
double d0 = p_110669_3_.field_111101_a - p_110669_6_;
double d1 = p_110669_3_.field_111100_b - p_110669_6_;
double d2 = p_110669_3_.field_111101_a + p_110669_6_;
double d3 = p_110669_3_.field_111100_b + p_110669_6_;
CommandSpreadPlayers.Position[] acommandspreadplayers$position = this.func_110670_a(random, p_110669_9_ ? this.func_110667_a(p_110669_2_) : p_110669_2_.size(), d0, d1, d2, d3);
int i = this.func_110668_a(p_110669_3_, p_110669_4_, worldIn, random, d0, d1, d2, d3, acommandspreadplayers$position, p_110669_9_);
double d4 = this.func_110671_a(p_110669_2_, worldIn, acommandspreadplayers$position, p_110669_9_);
notifyOperators(p_110669_1_, this, "commands.spreadplayers.success." + (p_110669_9_ ? "teams" : "players"), new Object[] {Integer.valueOf(acommandspreadplayers$position.length), Double.valueOf(p_110669_3_.field_111101_a), Double.valueOf(p_110669_3_.field_111100_b)});
if (acommandspreadplayers$position.length > 1)
{
p_110669_1_.addChatMessage(new ChatComponentTranslation("commands.spreadplayers.info." + (p_110669_9_ ? "teams" : "players"), new Object[] {String.format("%.2f", new Object[]{Double.valueOf(d4)}), Integer.valueOf(i)}));
}
}
示例9: onDisconnect
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
/**
* Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination
*/
public void onDisconnect(IChatComponent reason)
{
logger.info(this.playerEntity.getName() + " lost connection: " + reason);
this.serverController.refreshStatusNextTick();
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("multiplayer.player.left", new Object[] {this.playerEntity.getDisplayName()});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW);
this.serverController.getConfigurationManager().sendChatMsg(chatcomponenttranslation);
this.playerEntity.mountEntityAndWakeUp();
this.serverController.getConfigurationManager().playerLoggedOut(this.playerEntity);
if (this.serverController.isSinglePlayer() && this.playerEntity.getName().equals(this.serverController.getServerOwner()))
{
logger.info("Stopping singleplayer server as player logged out");
this.serverController.initiateShutdown();
}
}
示例10: sendDemoReminder
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
/**
* Sends a message to the player reminding them that this is the demo version
*/
private void sendDemoReminder()
{
if (this.field_73104_e > 100)
{
this.thisPlayerMP.addChatMessage(new ChatComponentTranslation("demo.reminder", new Object[0]));
this.field_73104_e = 0;
}
}
示例11: displayGUIChest
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
/**
* Displays the GUI for interacting with a chest inventory. Args: chestInventory
*/
public void displayGUIChest(IInventory chestInventory)
{
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
}
if (chestInventory instanceof ILockableContainer)
{
ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;
if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
{
this.playerNetServerHandler.sendPacket(new S02PacketChat(new ChatComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
this.playerNetServerHandler.sendPacket(new S29PacketSoundEffect("random.door_close", this.posX, this.posY, this.posZ, 1.0F, 1.0F));
return;
}
}
this.getNextWindowId();
if (chestInventory instanceof IInteractionObject)
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
}
else
{
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
}
this.openContainer.windowId = this.currentWindowId;
this.openContainer.onCraftGuiOpened(this);
}
示例12: listPlayers
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
protected void listPlayers(ICommandSender p_147195_1_, String[] p_147195_2_, int p_147195_3_) throws CommandException
{
Scoreboard scoreboard = this.getScoreboard();
if (p_147195_2_.length > p_147195_3_)
{
String s = getEntityName(p_147195_1_, p_147195_2_[p_147195_3_]);
Map<ScoreObjective, Score> map = scoreboard.getObjectivesForEntity(s);
p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, map.size());
if (map.size() <= 0)
{
throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s});
}
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s});
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
p_147195_1_.addChatMessage(chatcomponenttranslation);
for (Score score : map.values())
{
p_147195_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.getObjective().getDisplayName(), score.getObjective().getName()}));
}
}
else
{
Collection<String> collection = scoreboard.getObjectiveNames();
p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size());
if (collection.size() <= 0)
{
throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]);
}
ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())});
chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN);
p_147195_1_.addChatMessage(chatcomponenttranslation1);
p_147195_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray())));
}
}
示例13: processCommand
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length >= 1 && args[0].equalsIgnoreCase("ips"))
{
sender.addChatMessage(new ChatComponentTranslation("commands.banlist.ips", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys().length)}));
sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedIPs().getKeys())));
}
else
{
sender.addChatMessage(new ChatComponentTranslation("commands.banlist.players", new Object[] {Integer.valueOf(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys().length)}));
sender.addChatMessage(new ChatComponentText(joinNiceString(MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().getKeys())));
}
}
示例14: initCraftableStats
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
/**
* Initializes statistics related to craftable items. Is only called after both block and item stats have been
* initialized.
*/
private static void initCraftableStats()
{
Set<Item> set = Sets.<Item>newHashSet();
for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList())
{
if (irecipe.getRecipeOutput() != null)
{
set.add(irecipe.getRecipeOutput().getItem());
}
}
for (ItemStack itemstack : FurnaceRecipes.instance().getSmeltingList().values())
{
set.add(itemstack.getItem());
}
for (Item item : set)
{
if (item != null)
{
int i = Item.getIdFromItem(item);
String s = func_180204_a(item);
if (s != null)
{
objectCraftStats[i] = (new StatCrafting("stat.craftItem.", s, new ChatComponentTranslation("stat.craftItem", new Object[] {(new ItemStack(item)).getChatComponent()}), item)).registerStat();
}
}
}
replaceAllSimilarBlocks(objectCraftStats);
}
示例15: processCommand
import net.minecraft.util.ChatComponentTranslation; //导入依赖的package包/类
/**
* Callback when the command is invoked
*/
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
if (args.length <= 0)
{
throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
}
else
{
WorldSettings.GameType worldsettings$gametype = this.getGameModeFromCommand(sender, args[0]);
EntityPlayer entityplayer = args.length >= 2 ? getPlayer(sender, args[1]) : getCommandSenderAsPlayer(sender);
entityplayer.setGameType(worldsettings$gametype);
entityplayer.fallDistance = 0.0F;
if (sender.getEntityWorld().getGameRules().getBoolean("sendCommandFeedback"))
{
entityplayer.addChatMessage(new ChatComponentTranslation("gameMode.changed", new Object[0]));
}
IChatComponent ichatcomponent = new ChatComponentTranslation("gameMode." + worldsettings$gametype.getName(), new Object[0]);
if (entityplayer != sender)
{
notifyOperators(sender, this, 1, "commands.gamemode.success.other", new Object[] {entityplayer.getName(), ichatcomponent});
}
else
{
notifyOperators(sender, this, 1, "commands.gamemode.success.self", new Object[] {ichatcomponent});
}
}
}