本文整理匯總了Java中net.minecraft.util.text.TextFormatting類的典型用法代碼示例。如果您正苦於以下問題:Java TextFormatting類的具體用法?Java TextFormatting怎麽用?Java TextFormatting使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TextFormatting類屬於net.minecraft.util.text包,在下文中一共展示了TextFormatting類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onItemRightClick
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
{
Stats statsCap = (Stats) player.getCapability(CapabilityPlayerStats.STATS, null);
PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
if (statsCap != null && playerInfo != null)
{
if (statsCap.getMana() - this.manaPerUse >= 0 && playerInfo.getPlayerLevel() >= NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
{
player.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, player.inventory.getCurrentItem());
}
}
if (playerInfo.getPlayerLevel() < NBTHelper.loadStackNBT(player.inventory.getCurrentItem()).getInteger("Level"))
{
player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will take significantly more damage if it is not removed."));
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL, player.inventory.getCurrentItem());
}
示例2: isEntityTypeValid
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
private static <T extends Entity> boolean isEntityTypeValid(ICommandSender commandSender, Map<String, String> params)
{
String s = getArgument(params, field_190849_w);
if (s == null)
{
return true;
}
else
{
ResourceLocation resourcelocation = new ResourceLocation(s.startsWith("!") ? s.substring(1) : s);
if (EntityList.isStringValidEntityName(resourcelocation))
{
return true;
}
else
{
TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("commands.generic.entity.invalidType", new Object[] {resourcelocation});
textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
commandSender.addChatMessage(textcomponenttranslation);
return false;
}
}
}
示例3: onPlayerLogin
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event){
if(DifficultyManager.enabled && ProgressiveDifficulty.oldConfigExists){
TextComponentString linkComponent = new TextComponentString("[Progressive Difficulty Wiki]");
ITextComponent[] chats = new ITextComponent[]{
new TextComponentString("[ProgressiveDifficulty] It looks like you have a version 1.0 " +
"config file. Please check out the Progressive Difficulty Wiki for instructions on how" +
" to migrate to a version 2.0 config file."),
linkComponent
};
ClickEvent goLinkEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,"https://github.com/talandar/ProgressiveDifficulty/wiki/2.0-Transition");
linkComponent.getStyle().setClickEvent(goLinkEvent);
linkComponent.getStyle().setColor(TextFormatting.BLUE);
linkComponent.getStyle().setUnderlined(true);
ChatUtil.sendChat(event.player,chats);
}
}
示例4: addProbeInfo
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
/**
* Called by TOP compatibility handler
* @param mode
* @param probeInfo
* @param player
* @param world
* @param blockState
* @param data
*/
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
TileEntity te = world.getTileEntity(data.getPos());
if (te instanceof TileEntityChunkProtector) {
TileEntityChunkProtector chunkprotector = (TileEntityChunkProtector) te;
int secondsLeft = chunkprotector.getSecondsBeforeDestroyed();
int ticksLeft = chunkprotector.getTicksBeforeDestroyed();
if (ticksLeft != -1) {
if (mode == ProbeMode.NORMAL) {
probeInfo.text(TextFormatting.BLUE + Integer.toString(secondsLeft) + " seconds left in world");
} else if (mode == ProbeMode.EXTENDED) {
probeInfo.text(TextFormatting.BLUE + Integer.toString(ticksLeft) + " ticks left in world");
} else if (mode == ProbeMode.DEBUG) {
probeInfo.text(TextFormatting.BLUE + Integer.toString(secondsLeft) + " seconds left in world");
probeInfo.text(TextFormatting.BLUE + Integer.toString(ticksLeft) + " ticks left in world");
}
} else probeInfo.text(TextFormatting.GRAY + "Won't decay");
}
}
示例5: onMessage
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public IMessage onMessage(TeleportRequest message, MessageContext ctx) {
EntityPlayerMP player = ctx.getServerHandler().player;
if(Perms.isOP(player) == false){
Main.LOGGER.info(player.getName() + " tried to teleport, but was denied to do so!");
return null;
}
new RunInServerThread(new Runnable() {
@Override
public void run() {
Entity e = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityFromUuid(message.uuid);
if(e == null){
player.sendMessage(new TextComponentString(TextFormatting.RED + "Woops! This tile entity no longer exists!"));
return;
}
Teleport.teleportPlayer(player, e.dimension, e.posX, e.posY, e.posZ);
}
});
return null;
}
示例6: addInformation
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
tooltip.add("Extra storage for your money!");
if (stack.hasTagCompound()) {
InventoryItem inventory = new InventoryItem(stack);
float value = 0;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
if (inventory.getStackInSlot(i) != ItemStack.EMPTY && inventory.getStackInSlot(i).getItem() instanceof ItemMoneyBase) {
value += ((ItemMoneyBase) inventory.getStackInSlot(i).getItem()).getValue() * inventory.getStackInSlot(i).getCount();
}
}
tooltip.add("Currently storing: " + NumberFormat.getCurrencyInstance(Locale.US).format(value));
}
tooltip.add(TextFormatting.BLUE + "Only holds currency.");
}
示例7: drawForegroundLayer
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public void drawForegroundLayer(BasicTeslaGuiContainer container, int guiX, int guiY, int mouseX, int mouseY) {
super.drawForegroundLayer(container, guiX, guiY, mouseX, mouseY);
if (this.tile != null) {
long timeLeft = 0;
long generatingRate = 0;
if (this.tile.getGeneratedPowerStored() > 0) {
timeLeft = ((this.tile.getGeneratedPowerStored() / 2) / this.tile.getGeneratedPowerReleaseRate()) / 20;
generatingRate = this.tile.getGeneratedPowerReleaseRate();
}
FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
GlStateManager.pushMatrix();
GlStateManager.translate(this.getLeft() + 2, this.getTop() + 2, 0);
GlStateManager.scale(1, 1, 1);
renderer.drawString(TextFormatting.DARK_GRAY + new TextComponentTranslation("text.industrialforegoing.display.burning").getFormattedText(), 4, 4, 0xFFFFFF);
renderer.drawString(TextFormatting.DARK_GRAY + getFormatedTime(timeLeft * 1000), 8, (renderer.FONT_HEIGHT) + 5, 0xFFFFFF);
renderer.drawString(TextFormatting.DARK_GRAY + new TextComponentTranslation("text.industrialforegoing.display.producing").getFormattedText(), 4, 2 * (renderer.FONT_HEIGHT) + 9, 0xFFFFFF);
renderer.drawString(TextFormatting.DARK_GRAY + "" + generatingRate + " RF/tick", 8, 3 * (renderer.FONT_HEIGHT) + 10, 0xFFFFFF);
GlStateManager.popMatrix();
}
}
示例8: addTipToMachine
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
public static void addTipToMachine(List<String> currenttip, IWailaDataAccessor accessor) {
NBTTagCompound tag = accessor.getNBTData();
//This is used so that we can split values later easier and have them all in the same layout.
Map<String, String> values = new HashMap<>();
if (tag.hasKey("redstoneMode")) {
int mode = tag.getInteger("redstoneMode");
GuiPneumaticContainerBase gui = (GuiPneumaticContainerBase) PneumaticCraftRepressurized.proxy.getClientGuiElement(((BlockPneumaticCraft) accessor.getBlock()).getGuiID().ordinal(),
accessor.getPlayer(), accessor.getWorld(), accessor.getPosition().getX(), accessor.getPosition().getY(), accessor.getPosition().getZ());
TileEntity te = accessor.getTileEntity();
if (te instanceof TileEntityBase) {
values.put(((TileEntityBase) te).getRedstoneString(), ((TileEntityBase) te).getRedstoneButtonText(mode));
}
}
//Get all the values from the map and put them in the list.
for (Map.Entry<String, String> entry : values.entrySet()) {
currenttip.add(TextFormatting.RED + I18n.format(entry.getKey()) + ": " + I18n.format(entry.getValue()));
}
}
示例9: itemInteractionForEntity
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public boolean itemInteractionForEntity(ItemStack iStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) {
if (!player.world.isRemote) {
if (entity instanceof IManoMeasurable) {
if (((IPressurizable) iStack.getItem()).getPressure(iStack) > 0F) {
List<String> curInfo = new ArrayList<String>();
((IManoMeasurable) entity).printManometerMessage(player, curInfo);
if (curInfo.size() > 0) {
((IPressurizable) iStack.getItem()).addAir(iStack, -30);
for (String s : curInfo) {
player.sendStatusMessage(new TextComponentTranslation(s), false);
}
return true;
}
} else {
player.sendStatusMessage(new TextComponentTranslation(TextFormatting.RED + "The Manometer doesn't have any charge!"), false);
}
}
}
return false;
}
示例10: handleGUIButtonPress
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public void handleGUIButtonPress(int buttonID, EntityPlayer player) {
if (buttonID == 0) {
redstoneMode++;
if (redstoneMode > 2) redstoneMode = 0;
updateNeighbours();
} else if (buttonID == 2) {
rebootStation();
} else if (buttonID == 3) {
if (!hasValidNetwork()) {
player.sendStatusMessage(new TextComponentTranslation(TextFormatting.GREEN + "This Security Station is out of order: Its network hasn't been properly configured."), false);
} else {
player.openGui(PneumaticCraftRepressurized.instance, EnumGuiId.HACKING.ordinal(), getWorld(), getPos().getX(), getPos().getY(), getPos().getZ());
}
} else if (buttonID > 3 && buttonID - 4 < sharedUsers.size()) {
sharedUsers.remove(buttonID - 4);
}
sendDescriptionPacket();
}
示例11: addInformation
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
if(!stack.hasTagCompound() || !stack.getTagCompound().hasKey("defieritem")){
tooltip.add("Blank Pattern");
}else{
ItemStack stored = new ItemStack(stack.getTagCompound().getCompoundTag("defieritem"));
DefierRecipe recipe = DefierRecipeRegistry.findRecipeForStack(stored);
if(recipe == null){
tooltip.add(TextFormatting.RED + "Unknown Recipe");
}else{
stored.clearCustomName();
tooltip.add("Item: " + stored.getDisplayName());
tooltip.add("Energy Cost: " + Defier.LARGE_NUMBER.format(recipe.getCost()) + "RF");
}
}
}
示例12: addInformation
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn)
{
if (stack.hasTagCompound())
{
if (stack.getTagCompound().hasKey("papyrus_id"))
{
PapyrusData dat = PurMag.INSTANCE.getPapyrusRegistry().getPapyrus(stack.getTagCompound().getString("papyrus_id"));
if (dat != null)
tooltip.add(TextFormatting.GOLD + dat.getDisplayName() + TextFormatting.RESET);
}
}
}
示例13: addInformation
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
Collections.addAll(tooltip, StringUtils.split(I18n.format("message.meecreeps.tooltip.cube_intro"), "\n"));
MeeCreepActionType lastAction = getLastAction(stack);
if (lastAction != null) {
MeeCreepsApi.Factory factory = MeeCreeps.api.getFactory(lastAction);
tooltip.add(TextFormatting.YELLOW + " (" + I18n.format(factory.getMessage()) + ")");
}
if (isLimited()) {
Collections.addAll(tooltip, StringUtils.split(I18n.format("message.meecreeps.tooltip.cube_uses", Integer.toString(Config.meeCreepBoxMaxUsage - getUsages(stack))), "\n"));
}
}
示例14: drawBauble
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
private void drawBauble(ArrayList<String> tooltip, ItemStack stack, NBTTagCompound nbt, EntityPlayer player, PlayerInformation info)
{
/*
* NAME
* Level
*
* Attributes
*/
// Level
if (info.getPlayerLevel() < nbt.getInteger("Level")) tooltip.add(1, TextFormatting.RED + "Level: " + nbt.getInteger("Level"));
else tooltip.add(1, "Level: " + nbt.getInteger("Level"));
tooltip.add("");
// Attributes
DecimalFormat format = new DecimalFormat("#.##");
tooltip.add(TextFormatting.ITALIC + "Attributes");
for (JewelryAttribute attribute : JewelryAttribute.values())
{
if (attribute.hasAttribute(nbt) && attribute.getAmount(nbt) < 1)
tooltip.add(TextFormatting.BLUE + " +" + String.format("%.0f%%", attribute.getAmount(nbt) * 100) + " " + attribute.getName());
else if (attribute.hasAttribute(nbt) && attribute.getAmount(nbt) >= 1)
tooltip.add(TextFormatting.BLUE + " +" + format.format(attribute.getAmount(nbt)) + " " + attribute.getName());
}
tooltip.add("");
}
示例15: execute
import net.minecraft.util.text.TextFormatting; //導入依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (!RulesManager.readCustomLoot(args[0])) {
ChatTools.addChatMessage(sender, new TextComponentString(TextFormatting.RED + "Error reading file '" + args[0] + "'!"));
InControl.logger.warn("Error reading file '" + args[0] + "'!");
}
}