本文整理汇总了Java中net.minecraft.util.text.ITextComponent类的典型用法代码示例。如果您正苦于以下问题:Java ITextComponent类的具体用法?Java ITextComponent怎么用?Java ITextComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITextComponent类属于net.minecraft.util.text包,在下文中一共展示了ITextComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleChat
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
/**
* Prints a chatmessage in the chat GUI
*/
public void handleChat(SPacketChat packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(packetIn.getType(), packetIn.getChatComponent());
if (message == null) return;
if (packetIn.getType() == 2)
{
this.gameController.ingameGUI.setRecordPlaying(message, false);
}
else
{
this.gameController.ingameGUI.getChatGUI().printChatMessage(message);
}
}
示例2: displayVillagerTradeGui
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
ITextComponent itextcomponent = villager.getDisplayName();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = villager.getRecipes(this);
if (merchantrecipelist != null)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.currentWindowId);
merchantrecipelist.writeToBuf(packetbuffer);
this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
}
}
示例3: displayVillagerTradeGui
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
public void displayVillagerTradeGui(IMerchant villager)
{
this.getNextWindowId();
this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addListener(this);
net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
ITextComponent itextcomponent = villager.getDisplayName();
this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
MerchantRecipeList merchantrecipelist = villager.getRecipes(this);
if (merchantrecipelist != null)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.currentWindowId);
merchantrecipelist.writeToBuf(packetbuffer);
this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
}
}
示例4: getDeathMessage
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
/**
* Returns the message to be displayed on player death.
*/
@Override
public ITextComponent getDeathMessage(EntityLivingBase p_151519_1_) {
// ItemStack itemstack = this.damageSourceEntity instanceof
// EntityLivingBase ?
// ((EntityLivingBase)this.damageSourceEntity).getHeldItem(EnumHand.MAIN_HAND)
// : null;
if (this.getTrueSource() == TF2weapons.dummyEnt)
return new TextComponentTranslation("death.attack.explosion", p_151519_1_.getDisplayName());
String s = "death.attack." + this.damageType;
String s1 = s + ".item";
return weapon != null && I18n.canTranslate(s1)
? new TextComponentTranslation(s1,
new Object[] { p_151519_1_.getDisplayName(), this.getTrueSource().getDisplayName(),
weapon.getDisplayName() })
: new TextComponentTranslation(s,
new Object[] { p_151519_1_.getDisplayName(), this.getTrueSource().getDisplayName() });
}
示例5: notifyDataManagerChange
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
public void notifyDataManagerChange(DataParameter<?> key)
{
super.notifyDataManagerChange(key);
if (LAST_OUTPUT.equals(key))
{
try
{
this.commandBlockLogic.setLastOutput((ITextComponent)this.getDataManager().get(LAST_OUTPUT));
}
catch (Throwable var3)
{
;
}
}
else if (COMMAND.equals(key))
{
this.commandBlockLogic.setCommand((String)this.getDataManager().get(COMMAND));
}
}
示例6: execute
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
/**
* Callback for when the command is executed
*/
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
if (args.length < 2)
{
throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
}
else
{
EntityPlayer entityplayer = getPlayer(server, sender, args[0]);
String s = buildString(args, 1);
try
{
ITextComponent itextcomponent = ITextComponent.Serializer.jsonToComponent(s);
entityplayer.addChatMessage(TextComponentUtils.processComponent(sender, itextcomponent, entityplayer));
}
catch (JsonParseException jsonparseexception)
{
throw toSyntaxException(jsonparseexception);
}
}
}
示例7: onDisconnect
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
/**
* Invoked when disconnecting, the parameter is a ChatComponent describing the reason for termination
*/
public void onDisconnect(ITextComponent reason)
{
this.gameController.loadWorld((WorldClient)null);
if (this.guiScreenServer != null)
{
if (this.guiScreenServer instanceof GuiScreenRealmsProxy)
{
this.gameController.displayGuiScreen((new DisconnectedRealmsScreen(((GuiScreenRealmsProxy)this.guiScreenServer).getProxy(), "disconnect.lost", reason)).getProxy());
}
else
{
this.gameController.displayGuiScreen(new GuiDisconnected(this.guiScreenServer, "disconnect.lost", reason));
}
}
else
{
this.gameController.displayGuiScreen(new GuiDisconnected(new GuiMultiplayer(new GuiMainMenu()), "disconnect.lost", reason));
}
}
示例8: buildUpdateMessage
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
private static ITextComponent buildUpdateMessage(IVersionProvider provider, VersionData data)
{
ITextComponent msg = TextFormatter.addHoverText(
TextFormatter.style(TextFormatting.DARK_RED, "[%s] ", provider.getLocalizedName()),
TextFormatter.format("%s -> %s", provider.getVersion(), data.version));
msg.appendSibling(TextFormatter.translateAndStyle(TextFormatting.WHITE, "universalremote.version.update_available", data.version));
msg.appendSibling (
TextFormatter.addURLClick(
TextFormatter.addHoverText(
TextFormatter.style(TextFormatting.GOLD, " [%s]", TextFormatter.translate("universalremote.version.download").getUnformattedText()),
TextFormatter.translate("universalremote.version.click_to_download")),
data.downloadUrl)
);
return msg;
}
示例9: clickHeader
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
@Override
protected void clickHeader(int x, int y)
{
int offset = y;
if (logoPath != null) {
offset -= logoDims.height + 10;
}
if (offset <= 0)
return;
int lineIdx = offset / 10;
if (lineIdx >= lines.size())
return;
ITextComponent line = lines.get(lineIdx);
if (line != null)
{
int k = -4;
for (ITextComponent part : line) {
if (!(part instanceof TextComponentString))
continue;
k += GuiModList.this.fontRendererObj.getStringWidth(((TextComponentString)part).getText());
if (k >= x)
{
GuiModList.this.handleComponentClick(part);
break;
}
}
}
}
示例10: getChatComponentFromNthArg
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
public static ITextComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int index, boolean p_147176_3_) throws PlayerNotFoundException
{
ITextComponent itextcomponent = new TextComponentString("");
for (int i = index; i < args.length; ++i)
{
if (i > index)
{
itextcomponent.appendText(" ");
}
ITextComponent itextcomponent1 = net.minecraftforge.common.ForgeHooks.newChatWithLinks(args[i]); // Forge: links for messages
if (p_147176_3_)
{
ITextComponent itextcomponent2 = EntitySelector.matchEntitiesToTextComponent(sender, args[i]);
if (itextcomponent2 == null)
{
if (EntitySelector.hasArguments(args[i]))
{
throw new PlayerNotFoundException();
}
}
else
{
itextcomponent1 = itextcomponent2;
}
}
itextcomponent.appendSibling(itextcomponent1);
}
return itextcomponent;
}
示例11: getDifficultyText
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
public String getDifficultyText(EnumDifficulty p_175355_1_)
{
ITextComponent itextcomponent = new TextComponentString("");
itextcomponent.appendSibling(new TextComponentTranslation("options.difficulty", new Object[0]));
itextcomponent.appendText(": ");
itextcomponent.appendSibling(new TextComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0]));
return itextcomponent.getFormattedText();
}
示例12: drawScreen
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
this.inputField.drawTextBox();
ITextComponent itextcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());
if (itextcomponent != null && itextcomponent.getStyle().getHoverEvent() != null)
{
this.handleComponentHover(itextcomponent, mouseX, mouseY);
}
super.drawScreen(mouseX, mouseY, partialTicks);
}
示例13: getDisplayName
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
@Override
public ITextComponent getDisplayName() {
if (m_realPlayer == null) {
return super.getDisplayName();
} else {
return m_realPlayer.getDisplayName();
}
}
示例14: onServerChatEvent
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
public static ITextComponent onServerChatEvent(NetHandlerPlayServer net, String raw, ITextComponent comp)
{
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
if (MinecraftForge.EVENT_BUS.post(event))
{
return null;
}
return event.getComponent();
}
示例15: addChatComponentMessage
import net.minecraft.util.text.ITextComponent; //导入依赖的package包/类
public void addChatComponentMessage(ITextComponent chatComponent, boolean p_146105_2_)
{
if (p_146105_2_)
{
this.mc.ingameGUI.setRecordPlaying(chatComponent, false);
}
else
{
this.mc.ingameGUI.getChatGUI().printChatMessage(chatComponent);
}
}