private static String removeChatFormatting(String string) { String withoutFormattingCodes = TextFormatting.getTextWithoutFormattingCodes(string); return (withoutFormattingCodes == null) ? "" : withoutFormattingCodes; }
private static String removeChatFormatting(String string) { String withoutFormattingCodes = TextFormatting.getTextWithoutFormattingCodes(string); return (withoutFormattingCodes == null) ? "" : withoutFormattingCodes; }
private String getWord(String line, int index) { if(index >= line.length() || line.charAt(index) == ' ') return null; int startIndex = index; while(startIndex > 0 && line.charAt(startIndex - 1) != ' ') --startIndex; int endIndex = index; while(endIndex + 1 < line.length() && line.charAt(endIndex + 1) != ' ') ++endIndex; endIndex = Math.min(endIndex + 1, line.length()); return TextFormatting.getTextWithoutFormattingCodes(line.substring(startIndex, endIndex)); }
@Override protected ResourceLocation getEntityTexture(EntitySnail entity) { String s = TextFormatting.getTextWithoutFormattingCodes(entity.getName()); if (s != null && "Gary".equals(s)) { return GARY; } else { return NORMAL; } } }
private boolean isSmallText(String string) { List<String> lines = Lists.newArrayList(); SpecialTooltipHandler.addDetailedTooltipFromResources(lines, stack.getUnlocalizedName()); return lines.contains(TextFormatting.getTextWithoutFormattingCodes(string)); }
@Override protected ResourceLocation getEntityTexture(T entity) { if (entity.hasCustomName() && NAMES.contains(TextFormatting.getTextWithoutFormattingCodes(entity.getCustomNameTag().toLowerCase()))) { return TEXTURE_COLORLESS; } else if (hologram) { return TEXTURE_HOLOGRAM; } else { return TEXTURE; } }
/** * Format into "ratio" attribute localization * * @param txt current attribute local * @param type the attribute index * @return the new localization */ private String reformat(String txt, int type) { String result = TextFormatting.getTextWithoutFormattingCodes(txt); if(result == null) return txt; Matcher matcher = FLOAT.matcher(result); if (matcher.find()) { int start = matcher.start(); int end = matcher.end(); String temp = result.substring(start, end).replace(",", "."); try { float value = Float.valueOf(temp) * 100; temp = ".plus.1"; if (start > 0 && result.charAt(start - 1) == '-') { temp = ".take.1"; } return I18n.format("attribute.modifier" + temp, ItemStack.DECIMALFORMAT.format(value), attributeNames[type]); } catch (NumberFormatException notNumber) { notNumber.printStackTrace(); } } return result; }
@Override protected void preRenderCallback(T entity, float partialTicks) { if (entity.getIsLegendary()) { GlStateManager.scale(1.5, 1.5, 1.5); } if (entity.hasCustomName() && NAMES.contains(TextFormatting.getTextWithoutFormattingCodes(entity.getCustomNameTag().toLowerCase()))) { float speed = 360 * 0.2f; int hsb = (int) (entity.world.getTotalWorldTime() % speed); Color color = Color.getHSBColor(hsb / speed, 0.5f, 1f); GlStateManager.color(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1.0f); } super.preRenderCallback(entity, partialTicks); }
@Nullable @Override public String getModNameTooltipFormatting() { try { ItemStack itemStack = new ItemStack(Items.APPLE); EntityPlayerSP player = Minecraft.getMinecraft().player; List<String> tooltip = new ArrayList<>(); tooltip.add("JEI Tooltip Testing for mod name formatting"); ItemTooltipEvent tooltipEvent = ForgeEventFactory.onItemTooltip(itemStack, player, tooltip, ITooltipFlag.TooltipFlags.NORMAL); tooltip = tooltipEvent.getToolTip(); if (tooltip.size() > 1) { for (int lineNum = 1; lineNum < tooltip.size(); lineNum++) { String line = tooltip.get(lineNum); if (line.contains(Constants.MINECRAFT_NAME)) { String withoutFormatting = TextFormatting.getTextWithoutFormattingCodes(line); if (withoutFormatting != null) { if (line.equals(withoutFormatting)) { return ""; } else if (line.contains(withoutFormatting)) { return StringUtils.replaceOnce(line, Constants.MINECRAFT_NAME, MOD_NAME_FORMAT_CODE); } } } } } } catch (LinkageError | RuntimeException e) { Log.get().error("Error while Testing for mod name formatting", e); } return null; }
int endingLineIndex = Math.min(splitText.size(), getStartingLine(page + 1, DescriptionCategory.MAX_LINES_PER_PAGE, firstPageMaxLines)); List<String> pageText = splitText.subList(startingLineIndex, endingLineIndex); while (!pageText.isEmpty() && TextFormatting.getTextWithoutFormattingCodes(pageText.get(0)).isEmpty()) pageText.remove(0);
/** * Change attribute format when displayed on item tooltip * * @param event */ @SubscribeEvent public void onItemTooltip(ItemTooltipEvent event) { for (String txt : event.getToolTip()) { if (txt.startsWith(TextFormatting.BLUE.toString())) { if (txt.contains(attributeNames[0]) || txt.contains(attributeNames[2])) event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + TextFormatting.getTextWithoutFormattingCodes(txt)); else if (txt.contains(attributeNames[3])) event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + reformat(txt, 3)); else if (txt.contains(attributeNames[1])) event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.GOLD + reformat(txt, 1)); } } if(event.getItemStack().getItem() instanceof IBackStabbable){ event.getToolTip().add(TextFormatting.GOLD + I18n.format("attribute.name.weapon.backstab")); } }
final TileEntitySign teLevelSign = (TileEntitySign) te; teLevelSign.signText[0] = new TextComponentString(TextFormatting.getTextWithoutFormattingCodes( LanguageHandler.format("com.minecolonies.coremod.gui.workerHuts.minerMineNode") + ": " + levelId)); teLevelSign.signText[1] = new TextComponentString(TextFormatting.getTextWithoutFormattingCodes("Y: " + (level.getDepth() + 1))); teLevelSign.signText[2] = new TextComponentString(TextFormatting.getTextWithoutFormattingCodes(LanguageHandler.format("com.minecolonies.coremod.gui.workerHuts.minerNode") + ": " + level.getNumberOfBuiltNodes())); teLevelSign.signText[3] = new TextComponentString(TextFormatting.getTextWithoutFormattingCodes(""));
public static boolean namesMatch(ItemStack stack, String search) { search = TextFormatting.getTextWithoutFormattingCodes(search.trim().toLowerCase()); if(search.isEmpty()) return true; name = TextFormatting.getTextWithoutFormattingCodes(name.trim().toLowerCase()); PotionUtils.addPotionTooltip(stack, potionNames, 1F); for(String s : potionNames) if(matcher.matches(TextFormatting.getTextWithoutFormattingCodes(s.trim().toLowerCase()), search)) return true;
@SubscribeEvent public static void onTooltip(WailaTooltipEvent event) { if (!ConfigHandler.instance().showTooltip()) return; if (!getNarrator().active()) return; if (!ConfigHandler.instance().getConfig(Configuration.CATEGORY_GENERAL, Constants.CFG_WAILA_TTS, false)) return; if (Minecraft.getMinecraft().currentScreen != null || Minecraft.getMinecraft().isGamePaused()) return; String narrate = TextFormatting.getTextWithoutFormattingCodes(event.getCurrentTip().get(0)); if (lastNarration.equalsIgnoreCase(narrate)) return; if (event.getAccessor().getBlock() == Blocks.AIR && event.getAccessor().getEntity() == null) return; getNarrator().clear(); getNarrator().say(narrate); lastNarration = narrate; }
if(TextFormatting.getTextWithoutFormattingCodes(s).trim().isEmpty()) { y += 10 * (i - 1) + 1; break;
public boolean processInteract(EntityPlayer player, EnumHand hand) { ItemStack itemstack = player.getHeldItem(hand); String s = TextFormatting.getTextWithoutFormattingCodes(player.getName()); boolean isDev = s.equals("Alexthe666") || s.equals("Raptorfarian"); if (this.isTamed() && this.isOwner(player)) {