Java Code Examples for net.minecraft.util.EnumChatFormatting#getTextWithoutFormattingCodes()

The following examples show how to use net.minecraft.util.EnumChatFormatting#getTextWithoutFormattingCodes() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
public void transform(EntityLivingBase bat) {
    String s = EnumChatFormatting.getTextWithoutFormattingCodes(bat.getName());
    Integer state = rotateState.get(bat.getUniqueID());
    if (CosmeticsUtil.shouldHide(EnumPurchaseType.FLIP_COSMETIC)) return;
    if ((state != null && state == 2) || s != null && (s.equals("Dinnerbone") ||
        s.equals("Grumm")) && (!(bat instanceof EntityPlayer) || ((EntityPlayer) bat).isWearing(EnumPlayerModelParts.CAPE))) {
        float y = bat.height + 0.1F;
        GlStateManager.translate(0.0F, y / 2, 0.0F);
        double l = System.currentTimeMillis() % (360 * 1.75) / 1.75;
        GlStateManager.rotate((float) l, .1F, 0.0F, 0.0F);
        GlStateManager.translate(0.0F, -y / 2, 0.0F);
    } else if ((state != null && state == 1) || s != null && (s.equals("Dinnerbone") ||
        s.equals("Grumm")) && (!(bat instanceof EntityPlayer) || ((EntityPlayer) bat).isWearing(EnumPlayerModelParts.CAPE))) {
        {
            GlStateManager.translate(0.0F, bat.height + 0.1F, 0.0F);
            GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
        }
    }
}
 
Example 2
@InvokeEvent
public void bookCheck(TickEvent event) {
    GuiScreen currentScreen = Minecraft.getMinecraft().currentScreen;
    if (currentScreen == null) return;

    if (currentScreen instanceof GuiScreenBook) {
        NBTTagList bookPages = ((IMixinGuiScreenBook) currentScreen).getBookPages();
        int currPage = ((IMixinGuiScreenBook) currentScreen).getCurrPage();

        if (currPage < bookPages.tagCount()) {
            try {
                String textWithoutFormattingCodes = EnumChatFormatting.getTextWithoutFormattingCodes(
                    IChatComponent.Serializer.jsonToComponent(bookPages.getStringTagAt(currPage)).getUnformattedText().replace("\n", " "));
                Matcher matcher = newNick.matcher(textWithoutFormattingCodes);
                if (matcher.find()) {
                    String nick = matcher.group("nick");
                    remap(nick, override == null ? Minecraft.getMinecraft().getSession().getProfile().getName() : override);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
 
Example 3
Source Project: Et-Futurum   File: RabbitRenderer.java    License: The Unlicense 6 votes vote down vote up
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	EntityRabbit rabbit = (EntityRabbit) entity;
	String s = EnumChatFormatting.getTextWithoutFormattingCodes(rabbit.getCommandSenderName());

	if (s != null && s.equals("Toast"))
		return TOAST;
	else
		switch (rabbit.getRabbitType()) {
			case 0:
			default:
				return BROWN;
			case 1:
				return WHITE;
			case 2:
				return BLACK;
			case 3:
				return WHITE_SPLOTCHED;
			case 4:
				return GOLD;
			case 5:
				return SALT;
		}
}
 
Example 4
@InvokeEvent
public void checkForEvents(ServerChatEvent event) {
    String raw = EnumChatFormatting.getTextWithoutFormattingCodes(event.getChat().getUnformattedText());
    Matcher achMatcher = ACHIEVEMENT_PATTERN.matcher(raw);
    if (achMatcher.matches()) {
        String ach = achMatcher.group("achievement");
        //Check to stop spamming of gchat if achievement is broken and you get it many times.
        if (!achievementsGotten.contains(ach)) {
            EventBus.INSTANCE.post(new AchievementGetEvent(ach));
            achievementsGotten.add(ach);
        }
    }

}
 
Example 5
Source Project: NotEnoughItems   File: ItemInfo.java    License: MIT License 5 votes vote down vote up
public static String getSearchName(ItemStack stack) {
    String s = itemSearchNames.get(stack);
    if(s == null) {
        s = EnumChatFormatting.getTextWithoutFormattingCodes(GuiContainerManager.concatenatedDisplayName(stack, true).toLowerCase());
        itemSearchNames.put(stack, s);
    }
    return s;
}
 
Example 6
Source Project: NotEnoughItems   File: GuiContainerManager.java    License: MIT License 5 votes vote down vote up
/**
 * Concatenates the multiline display name into one line for easy searching using string and {@link Pattern} functions.
 *
 * @param itemstack The stack to get the name for
 * @return The multiline display name of this item separated by '#'
 */
public static String concatenatedDisplayName(ItemStack itemstack, boolean includeHandlers) {
    List<String> list = itemDisplayNameMultiline(itemstack, null, includeHandlers);
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (String name : list) {
        if (first) {
            first = false;
        } else {
            sb.append("#");
        }
        sb.append(name);
    }
    return EnumChatFormatting.getTextWithoutFormattingCodes(sb.toString());
}
 
Example 7
public static String getUnformattedText(ServerChatEvent event) {
    return EnumChatFormatting.getTextWithoutFormattingCodes(event.getChat().getUnformattedText());
}
 
Example 8
@ModifyArg(method = "onAutocompleteResponse", at = @At(value = "INVOKE", target = "Ljava/lang/String;equalsIgnoreCase(Ljava/lang/String;)Z"))
private String removeChatFormattingOfCommonPrefix(String commonPrefix) {
    return EnumChatFormatting.getTextWithoutFormattingCodes(commonPrefix);
}
 
Example 9
@SuppressWarnings("all")
@ModifyArg(method = {"autocompletePlayerNames", "onAutocompleteResponse"}, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiTextField;writeText(Ljava/lang/String;)V"))
private String removeChatFormattingOfCompletion(String completion) {
    return EnumChatFormatting.getTextWithoutFormattingCodes(completion);
}
 
Example 10
private String func_146235_b(String p_146235_1_) {
    return Minecraft.getMinecraft().gameSettings.chatColours ? p_146235_1_ : EnumChatFormatting.getTextWithoutFormattingCodes(p_146235_1_);
}
 
Example 11
Source Project: NotEnoughItems   File: SearchField.java    License: MIT License 4 votes vote down vote up
@Override
public String filterText(String s) {
    return EnumChatFormatting.getTextWithoutFormattingCodes(s);
}