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

The following examples show how to use net.minecraft.util.EnumChatFormatting#getTextWithoutFormattingCodes() . 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 check out the related API usage on the sidebar.
Example 1
Source File: FlipHandler.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
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
Source File: NickHider.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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 File: RabbitRenderer.java    From Et-Futurum with 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
Source File: BroadcastEvents.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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 File: ItemInfo.java    From NotEnoughItems with 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 File: GuiContainerManager.java    From NotEnoughItems with 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
Source File: UniversalUtil.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String getUnformattedText(ServerChatEvent event) {
    return EnumChatFormatting.getTextWithoutFormattingCodes(event.getChat().getUnformattedText());
}
 
Example 8
Source File: MixinGuiChat.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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
Source File: MixinGuiChat.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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
Source File: ConsoleGui.java    From ehacks-pro with GNU General Public License v3.0 4 votes vote down vote up
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 File: SearchField.java    From NotEnoughItems with MIT License 4 votes vote down vote up
@Override
public String filterText(String s) {
    return EnumChatFormatting.getTextWithoutFormattingCodes(s);
}