Search in sources :

Example 1 with IMixinGuiScreenBook

use of cc.hyperium.mixins.client.gui.IMixinGuiScreenBook in project Hyperium by HyperiumClient.

the class NickHider method bookCheck.

@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();
            }
        }
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IMixinGuiScreenBook(cc.hyperium.mixins.client.gui.IMixinGuiScreenBook) Matcher(java.util.regex.Matcher) GuiScreen(net.minecraft.client.gui.GuiScreen) GuiScreenBook(net.minecraft.client.gui.GuiScreenBook) IMixinGuiScreenBook(cc.hyperium.mixins.client.gui.IMixinGuiScreenBook) InvokeEvent(cc.hyperium.event.InvokeEvent)

Aggregations

InvokeEvent (cc.hyperium.event.InvokeEvent)1 IMixinGuiScreenBook (cc.hyperium.mixins.client.gui.IMixinGuiScreenBook)1 Matcher (java.util.regex.Matcher)1 GuiScreen (net.minecraft.client.gui.GuiScreen)1 GuiScreenBook (net.minecraft.client.gui.GuiScreenBook)1 NBTTagList (net.minecraft.nbt.NBTTagList)1