net.minecraft.util.ChatStyle#net.minecraft.event.HoverEvent源码实例Demo

下面列出了net.minecraft.util.ChatStyle#net.minecraft.event.HoverEvent 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: LiquidBounce   文件: MixinGuiScreen.java
@Inject(method = "handleComponentHover", at = @At("HEAD"))
private void handleHoverOverComponent(IChatComponent component, int x, int y, final CallbackInfo callbackInfo) {
    if (component == null || component.getChatStyle().getChatClickEvent() == null || !LiquidBounce.moduleManager.getModule(ComponentOnHover.class).getState())
        return;

    final ChatStyle chatStyle = component.getChatStyle();

    final ClickEvent clickEvent = chatStyle.getChatClickEvent();
    final HoverEvent hoverEvent = chatStyle.getChatHoverEvent();

    drawHoveringText(Collections.singletonList("§c§l" + clickEvent.getAction().getCanonicalName().toUpperCase() + ": §a" + clickEvent.getValue()), x, y - (hoverEvent != null ? 17 : 0));
}
 
源代码2 项目: LiquidBounce   文件: MixinGuiScreen.java
@Inject(method = "handleComponentHover", at = @At("HEAD"))
private void handleHoverOverComponent(IChatComponent component, int x, int y, final CallbackInfo callbackInfo) {
    if (component == null || component.getChatStyle().getChatClickEvent() == null || !LiquidBounce.moduleManager.getModule(ComponentOnHover.class).getState())
        return;

    final ChatStyle chatStyle = component.getChatStyle();

    final ClickEvent clickEvent = chatStyle.getChatClickEvent();
    final HoverEvent hoverEvent = chatStyle.getChatHoverEvent();

    drawHoveringText(Collections.singletonList("§c§l" + clickEvent.getAction().getCanonicalName().toUpperCase() + ": §a" + clickEvent.getValue()), x, y - (hoverEvent != null ? 17 : 0));
}
 
源代码3 项目: Hyperium   文件: CommandNickHider.java
public void sendMessage(String message, String hover, String click) {
    ChatComponentText chatComponent = new ChatComponentText(ChatColor.YELLOW + message);
    if (hover != null && !hover.isEmpty()) {
        chatComponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
            new ChatComponentText(ChatColor.AQUA + hover + (!click.isEmpty() ? "\n" + click : ""))));
    }

    if (click != null && !click.isEmpty()) {
        chatComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, click));
    }

    Minecraft.getMinecraft().thePlayer.addChatComponentMessage(chatComponent);
}
 
源代码4 项目: MediaMod   文件: MediaModCommand.java
@Override
public void processCommand(ICommandSender sender, String[] args) {
    if(args.length <= 0) {
        TickScheduler.INSTANCE.schedule(1, () -> FMLClientHandler.instance().getClient().displayGuiScreen(new GuiMediaModSettings()));
    } else {
        String subcommand = args[0];
        if(subcommand.equalsIgnoreCase("party")) {
            if(args.length >= 2) {
                String function = args[1];
                if(function.equalsIgnoreCase("start")) {
                    if(!MediaMod.INSTANCE.partyManager.canStartParty()) {
                        PlayerMessager.sendMessage(ChatColor.RED + "You are already in a party!", true);
                        return;
                    }

                    PlayerMessager.sendMessage(ChatColor.GRAY + "Creating MediaMod Party... " + "(note: this only works with spotify at the moment)", true);

                    String code = MediaMod.INSTANCE.partyManager.startParty();
                    if(code.equals("")) {
                        PlayerMessager.sendMessage(ChatColor.RED + "An error occurred whilst creating your MediaMod party!", true);
                    } else {
                        IChatComponent urlComponent = new ChatComponentText(ChatColor.WHITE + "" + ChatColor.BOLD + code);
                        urlComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, code));
                        urlComponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Copy Code")));
                        PlayerMessager.sendMessage(new ChatComponentText(ChatColor.GRAY + "Share this code with your friends to invite them to your party: ").appendSibling(urlComponent), true);
                    }
                } else if (function.equalsIgnoreCase("leave")) {
                    if(!MediaMod.INSTANCE.partyManager.canStartParty()) {
                        boolean success = MediaMod.INSTANCE.partyManager.leaveParty();
                        if(success) {
                            PlayerMessager.sendMessage((ChatColor.GRAY + "You have left the party"), true);
                        } else {
                            PlayerMessager.sendMessage(ChatColor.RED + "An error occurred whilst trying to leave the party!", true);
                        }
                    } else {
                        PlayerMessager.sendMessage(ChatColor.RED + "You are not in a party!");
                    }
                }
            } else {
                PlayerMessager.sendMessage(ChatColor.RED + "Incorrect syntax! Usage: /mm party <start/invite/info/join/leave>");
            }
        }
    }
}
 
源代码5 项目: Hyperium   文件: MixinChatStyle.java
/**
 * @author Sk1er
 */
@Inject(method = "setChatHoverEvent", at = @At("HEAD"))
private void setChatHoverEvent(HoverEvent boldIn, CallbackInfoReturnable<ChatStyle> callbackInfoReturnable) {
    hyperiumChatStyle.resetCache();
}
 
源代码6 项目: ehacks-pro   文件: ConsoleInputGui.java
/**
 * Draws the screen and all the components in it.
 */
@SuppressWarnings("unchecked")
@Override
public void drawScreen(int p_73863_1_, int p_73863_2_, float p_73863_3_) {
    drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
    if (this.inputField.getText().length() == 0) {
        this.inputField.setText("/");
    }
    if (this.inputField.getText().charAt(0) != '/') {
        this.inputField.setText("/" + this.inputField.getText());
    }
    this.inputField.drawTextBox();
    IChatComponent ichatcomponent = EHacksGui.clickGui.consoleGui.getChatComponent(Mouse.getX(), Mouse.getY());

    if (ichatcomponent != null && ichatcomponent.getChatStyle().getChatHoverEvent() != null) {
        HoverEvent hoverevent = ichatcomponent.getChatStyle().getChatHoverEvent();

        if (null != hoverevent.getAction()) {
            switch (hoverevent.getAction()) {
                case SHOW_ITEM:
                    ItemStack itemstack = null;
                    try {
                        NBTBase nbtbase = JsonToNBT.func_150315_a(hoverevent.getValue().getUnformattedText());

                        if (nbtbase instanceof NBTTagCompound) {
                            itemstack = ItemStack.loadItemStackFromNBT((NBTTagCompound) nbtbase);
                        }
                    } catch (NBTException ignored) {
                    }
                    if (itemstack != null) {
                        this.renderToolTip(itemstack, p_73863_1_, p_73863_2_);
                    } else {
                        this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid Item!", p_73863_1_, p_73863_2_);
                    }
                    break;
                case SHOW_TEXT:
                    this.func_146283_a(Splitter.on("\n").splitToList(hoverevent.getValue().getFormattedText()), p_73863_1_, p_73863_2_);
                    break;
                case SHOW_ACHIEVEMENT:
                    StatBase statbase = StatList.func_151177_a(hoverevent.getValue().getUnformattedText());
                    if (statbase != null) {
                        IChatComponent ichatcomponent1 = statbase.func_150951_e();
                        ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("stats.tooltip.type." + (statbase.isAchievement() ? "achievement" : "statistic"));
                        chatcomponenttranslation.getChatStyle().setItalic(Boolean.TRUE);
                        String s = statbase instanceof Achievement ? ((Achievement) statbase).getDescription() : null;
                        ArrayList<String> arraylist = Lists.newArrayList(ichatcomponent1.getFormattedText(), chatcomponenttranslation.getFormattedText());

                        if (s != null) {
                            arraylist.addAll(this.fontRendererObj.listFormattedStringToWidth(s, 150));
                        }

                        this.func_146283_a(arraylist, p_73863_1_, p_73863_2_);
                    } else {
                        this.drawCreativeTabHoveringText(EnumChatFormatting.RED + "Invalid statistic/achievement!", p_73863_1_, p_73863_2_);
                    }
                    break;
                default:
                    break;
            }
        }

        GL11.glDisable(GL11.GL_LIGHTING);
    }

    super.drawScreen(p_73863_1_, p_73863_2_, p_73863_3_);
}
 
源代码7 项目: Hyperium   文件: IMixinEntity.java
@Invoker HoverEvent callGetHoverEvent();