use of net.minecraft.event.HoverEvent in project Hyperium by HyperiumClient.
the class LevelheadChatRenderer method chat.
@InvokeEvent
public void chat(ServerChatEvent event) {
if (!levelhead.getDisplayManager().getMasterConfig().isEnabled())
return;
LevelheadDisplay chat = Levelhead.getInstance().getDisplayManager().getChat();
if (chat == null || !levelhead.getLevelheadPurchaseStates().isChat() || !chat.getConfig().isEnabled())
return;
List<IChatComponent> siblings = event.getChat().getSiblings();
if (siblings.size() == 0)
return;
IChatComponent chatComponent = siblings.get(0);
if (chatComponent instanceof ChatComponentText) {
ChatStyle style = chatComponent.getChatStyle();
ClickEvent clickEvent = style.getChatClickEvent();
if (clickEvent != null && clickEvent.getAction() == ClickEvent.Action.RUN_COMMAND) {
String value = clickEvent.getValue();
HoverEvent hoverEvent = style.getChatHoverEvent();
if (hoverEvent != null && hoverEvent.getAction() == HoverEvent.Action.SHOW_TEXT) {
String[] split = value.split(" ");
if (split.length == 2) {
String uuid = split[1];
UUID key = UUID.fromString(uuid);
String tag = chat.getTrueValueCache().get(key);
if (tag != null) {
event.setChat(modifyChat(event.getChat(), tag, chat.getConfig()));
} else if (!(chat.getCache().get(key) instanceof NullLevelheadTag)) {
levelhead.fetch(key, chat, false);
}
}
}
}
}
}
use of net.minecraft.event.HoverEvent in project Hyperium by HyperiumClient.
the class UniversalUtil method newComponent.
private static IChatComponent newComponent(String text, String url, String hoverText) {
ChatStyle chatStyle = new ChatStyle();
ClickEvent clickEvent;
HoverEvent hoverEvent;
if (url != null && !url.equals("")) {
clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, url);
chatStyle.setChatClickEvent(clickEvent);
}
if (hoverText != null && !hoverText.equals("")) {
hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, newComponent(hoverText));
chatStyle.setChatHoverEvent(hoverEvent);
}
IChatComponent chatComponent = newComponent(text);
chatComponent.setChatStyle(chatStyle);
return chatComponent;
}
use of net.minecraft.event.HoverEvent in project Armourers-Workshop by RiskyKen.
the class ModClientFMLEventHandler method onPlayerTickEndEvent.
public void onPlayerTickEndEvent() {
EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
if (!shownUpdateInfo && UpdateCheck.updateFound) {
shownUpdateInfo = true;
ChatComponentText updateMessage = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateAvailable", UpdateCheck.remoteModVersion) + " ");
ChatComponentText updateURL = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateDownload"));
updateURL.getChatStyle().setUnderlined(true);
updateURL.getChatStyle().setColor(EnumChatFormatting.BLUE);
updateURL.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:updateDownloadRollover"))));
updateURL.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, LibModInfo.DOWNLOAD_URL));
updateMessage.appendSibling(updateURL);
player.addChatMessage(updateMessage);
}
if (!showmDevWarning && LibModInfo.DEVELOPMENT_VERSION) {
ChatComponentText devWarning = new ChatComponentText(TranslateUtils.translate("chat.armourersworkshop:devWarning"));
devWarning.getChatStyle().setColor(EnumChatFormatting.RED);
player.addChatMessage(devWarning);
showmDevWarning = true;
}
}
use of net.minecraft.event.HoverEvent in project Hyperium by HyperiumClient.
the class LevelheadGui method doHead.
private void doHead(DisplayConfig config, Levelhead instance, int editWidth, int mouseX, int mouseY) {
List<AboveHeadDisplay> aboveHead = instance.getDisplayManager().getAboveHead();
textField.drawTextBox();
if (!textField.getText().equalsIgnoreCase(config.getCustomHeader())) {
config.setCustomHeader(textField.getText());
updatePeopleToValues();
}
reg(new GuiButton(++currentID, width / 3 - 100, height - 137, 200, 20, YELLOW + "Purchase Additional Above Head Layer"), button -> attemptPurchase("head"));
reg(new GuiButton(++currentID, width - editWidth * 2 - 3, 29, editWidth, 20, YELLOW + "Editing Layer: " + AQUA + (aboveHead.indexOf(currentlyBeingEdited) + 1)), button -> {
int i = aboveHead.indexOf(currentlyBeingEdited);
i++;
if (i >= aboveHead.size()) {
i = 0;
}
currentlyBeingEdited = aboveHead.get(i);
textField.setText(currentlyBeingEdited.getConfig().getCustomHeader());
});
reg(new GuiButton(++currentID, width - editWidth * 2 - 3, 50, editWidth, 20, YELLOW + "Show On Self: " + AQUA + (currentlyBeingEdited.getConfig().isShowSelf() ? "YES" : "NO")), button -> currentlyBeingEdited.getConfig().setShowSelf(!currentlyBeingEdited.getConfig().isShowSelf()));
int colorConfigStart = 93 + 2;
reg(new GuiButton(++currentID, width - editWidth * 2 - 2, colorConfigStart, editWidth, 20, YELLOW + "Header Mode: " + AQUA + getMode(true)), button -> {
if (config.isHeaderRgb()) {
config.setHeaderRgb(false);
config.setHeaderChroma(true);
} else if (config.isHeaderChroma()) {
config.setHeaderRgb(false);
config.setHeaderChroma(false);
} else {
config.setHeaderRgb(true);
config.setHeaderChroma(false);
}
updatePeopleToValues();
});
if (config.isHeaderRgb()) {
regSlider(new GuiSlider(++currentID, width - editWidth * 2 - 2, colorConfigStart + 22, editWidth, 20, YELLOW + "Header Red: " + AQUA, "", 0, 255, config.getHeaderRed(), false, true, slider -> {
config.setHeaderRed(slider.getValueInt());
updatePeopleToValues();
}));
regSlider(new GuiSlider(++currentID, width - editWidth * 2 - 2, colorConfigStart + 44, editWidth, 20, YELLOW + "Header Green: " + AQUA, "", 0, 255, config.getHeaderGreen(), false, true, slider -> {
config.setHeaderGreen(slider.getValueInt());
updatePeopleToValues();
}));
regSlider(new GuiSlider(++currentID, width - editWidth * 2 - 2, colorConfigStart + 66, editWidth, 20, YELLOW + "Header Blue: " + AQUA, "", 0, 255, config.getHeaderBlue(), false, true, slider -> {
config.setHeaderBlue(slider.getValueInt());
updatePeopleToValues();
}));
} else if (!config.isHeaderChroma()) {
reg(new GuiButton(++currentID, width - editWidth * 2 - 2, colorConfigStart + 22, editWidth, 20, config.getHeaderColor() + "Rotate Header Color"), button -> {
int primaryId = colors.indexOf(removeColorChar(config.getHeaderColor()));
if (++primaryId == colors.length()) {
primaryId = 0;
}
config.setHeaderColor(COLOR_CHAR + colors.charAt(primaryId));
updatePeopleToValues();
});
}
reg(new GuiButton(++currentID, width - editWidth - 1, colorConfigStart, editWidth, 20, YELLOW + "Footer Mode: " + AQUA + getMode(false)), button -> {
updateFooterColorState(config);
button.displayString = "Footer Mode: " + getMode(false);
updatePeopleToValues();
});
if (config.isFooterRgb()) {
regSlider(new GuiSlider(++currentID, width - editWidth - 1, colorConfigStart + 22, editWidth, 20, YELLOW + "Footer Red: " + AQUA, "", 0, 255, config.getFooterRed(), false, true, slider -> {
config.setFooterRed(slider.getValueInt());
updatePeopleToValues();
}));
regSlider(new GuiSlider(++currentID, width - editWidth - 1, colorConfigStart + 44, editWidth, 20, YELLOW + "Footer Green: " + AQUA, "", 0, 255, config.getFooterGreen(), false, true, slider -> {
config.setFooterGreen(slider.getValueInt());
updatePeopleToValues();
}));
regSlider(new GuiSlider(++currentID, width - editWidth - 1, colorConfigStart + 66, editWidth, 20, YELLOW + "Footer Blue: " + AQUA, "", 0, 255, config.getFooterBlue(), false, true, slider -> {
config.setFooterBlue(slider.getValueInt());
updatePeopleToValues();
}));
} else if (!config.isFooterChroma()) {
reg(new GuiButton(++currentID, width - editWidth - 1, colorConfigStart + 22, editWidth, 20, config.getFooterColor() + "Rotate Footer Color"), button -> incrementColor(config, false));
}
regSlider(new GuiSlider(++currentID, width - editWidth * 2 - 2, colorConfigStart + 88, editWidth, 20, YELLOW + "Vertical Offset: " + AQUA, "", -50, 100, instance.getDisplayManager().getMasterConfig().getOffset() * 100D, false, true, slider -> instance.getDisplayManager().getMasterConfig().setOffset(slider.getValue() / 100D)));
regSlider(new GuiSlider(++currentID, width - editWidth - 1, colorConfigStart + 88, editWidth, 20, YELLOW + "Font Size: " + AQUA, "", 1, 20, instance.getDisplayManager().getMasterConfig().getFontSize() * 10D, false, true, slider -> {
instance.getDisplayManager().getMasterConfig().setFontSize(slider.getValue() / 10D);
updatePeopleToValues();
}));
if (isCustom) {
reg(new GuiButton(++currentID, width - editWidth * 2 - 2, colorConfigStart + 88 + 22, editWidth * 2 + 1, 20, YELLOW + "Export Colors to Custom Levelhead"), guiButton -> {
final LevelheadJsonHolder object;
String encode;
String url;
ChatComponentText text;
ChatStyle style;
ChatComponentText valueIn;
ChatStyle style2;
object = new LevelheadJsonHolder();
object.put("header_obj", currentlyBeingEdited.getHeaderConfig());
object.put("footer_obj", currentlyBeingEdited.getFooterConfig());
try {
encode = URLEncoder.encode(object.toString(), "UTF-8");
url = "https://sk1er.club/user?levelhead_color=" + encode;
text = new ChatComponentText("Click here to update your custom Levelhead colors");
style = new ChatStyle();
style.setBold(true);
style.setColor(EnumChatFormatting.YELLOW);
style.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
valueIn = new ChatComponentText("Please be logged in to your Sk1er.club for this to work. Do /levelhead dumpcache after clicking to see new colors!");
valueIn.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));
style2 = new ChatStyle();
style2.setColor(EnumChatFormatting.RED);
valueIn.setChatStyle(style2);
style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, valueIn));
text.setChatStyle(style);
mc.thePlayer.addChatComponentMessage(valueIn);
mc.thePlayer.addChatComponentMessage(text);
} catch (UnsupportedEncodingException e2) {
e2.printStackTrace();
}
mc.displayGuiScreen(null);
});
}
GlStateManager.pushMatrix();
GlStateManager.color(1, 1, 1);
RenderHelper.enableStandardItemLighting();
GlStateManager.enableAlpha();
GlStateManager.shadeModel(7424);
GlStateManager.enableAlpha();
GlStateManager.enableDepth();
GlStateManager.translate(0, 0, 50);
ScaledResolution current = new ScaledResolution(mc);
int posX = current.getScaledWidth() / 3;
int posY = current.getScaledHeight() / 2;
GuiInventory.drawEntityOnScreen(posX, posY + 50, 50, posX - mouseX, posY - mouseY, mc.thePlayer);
GlStateManager.depthFunc(515);
GlStateManager.resetColor();
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.disableDepth();
GlStateManager.popMatrix();
drawScaledText("Custom Prefix: ", width - editWidth * 3 / 2 - 3, 77, 1.5, -1, true, true);
}
use of net.minecraft.event.HoverEvent in project Hyperium by HyperiumClient.
the class CommandNickHider method sendMessage.
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);
}
Aggregations