net.minecraft.event.HoverEvent Java Examples
The following examples show how to use
net.minecraft.event.HoverEvent.
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: MixinGuiScreen.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@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)); }
Example #2
Source File: MixinGuiScreen.java From LiquidBounce with GNU General Public License v3.0 | 5 votes |
@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)); }
Example #3
Source File: CommandNickHider.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
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); }
Example #4
Source File: MediaModCommand.java From MediaMod with GNU General Public License v3.0 | 4 votes |
@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>"); } } } }
Example #5
Source File: MixinChatStyle.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
/** * @author Sk1er */ @Inject(method = "setChatHoverEvent", at = @At("HEAD")) private void setChatHoverEvent(HoverEvent boldIn, CallbackInfoReturnable<ChatStyle> callbackInfoReturnable) { hyperiumChatStyle.resetCache(); }
Example #6
Source File: ConsoleInputGui.java From ehacks-pro with GNU General Public License v3.0 | 4 votes |
/** * 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_); }
Example #7
Source File: IMixinEntity.java From Hyperium with GNU Lesser General Public License v3.0 | votes |
@Invoker HoverEvent callGetHoverEvent();