use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class RCTextStyle method visitFile.
@Nonnull
public static ITextComponent visitFile(String id) {
ITextComponent submit = ServerTranslations.get("reccomplex.save.submit");
submit.getStyle().setColor(TextFormatting.AQUA);
submit.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("reccomplex.save.submit.hover")));
submit.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Repository.submitURL(id)));
return submit;
}
use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class GuiHider method hideGUI.
public static boolean hideGUI() {
if (!canHide())
return false;
Minecraft mc = Minecraft.getMinecraft();
hiddenGUI = mc.currentScreen;
if (hiddenGUI == null)
return false;
mc.displayGuiScreen(null);
ITextComponent reopen = new TextComponentString("/" + RCCommands.reopen.getName());
reopen.getStyle().setColor(TextFormatting.GREEN);
reopen.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + RCCommands.reopen.getName()));
reopen.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ServerTranslations.get("commands.rcreopen.run")));
mc.player.sendMessage(ServerTranslations.format("commands.rc.didhide", reopen));
return true;
}
use of net.minecraft.util.text.event.HoverEvent in project AgriCraft by AgriCraft.
the class DebugModeIGrowable method debugActionBlockClicked.
@Override
public void debugActionBlockClicked(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (world.isRemote) {
return;
}
// Start with the position of the block that was clicked on. '7' is gray. Btw, the chat font is not fixed width. :(
StringBuilder outputRaw = new StringBuilder(String.format("`7%1$4d,%2$4d,%3$4d`r ", pos.getX(), pos.getY(), pos.getZ()));
// Check if the clicked on block has the IGrowable interface.
final IGrowable crop = WorldHelper.getBlock(world, pos, IGrowable.class).orElse(null);
if (crop == null) {
// If it does not, add a nicely formatted report, then skip onward.
outputRaw.append(chatNotIG);
} else {
// Otherwise run the tests and record the results.
IBlockState state = world.getBlockState(pos);
// canGrow
outputRaw.append(crop.canGrow(world, pos, state, false) ? chatTrue : chatFalse);
// canUseBonemeal
outputRaw.append(crop.canUseBonemeal(world, world.rand, pos, state) ? chatTrue : chatFalse);
// grow
crop.grow(world, world.rand, pos, state);
// It's also helpful to also make clear what block was being tested.
// '3' is dark aqua.
outputRaw.append("`3");
outputRaw.append(crop.toString().replaceFirst("Block", ""));
outputRaw.append("`r");
}
// Ellipsis are added as a clue that there's more text.
// '8' is dark gray.
outputRaw.append(" `8[...]`r");
// Create a hover box with explanatory information.
TextComponentString hoverComponent = new TextComponentString(MessageUtil.colorize(chatInfo));
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent);
// Turn the output String into a chat message.
TextComponentString outputComponent = new TextComponentString(MessageUtil.colorize(outputRaw.toString()));
// Add the hover box to the chat message.
outputComponent.getStyle().setHoverEvent(hoverEvent);
// Now send the completed chat message.
player.sendMessage(outputComponent);
}
use of net.minecraft.util.text.event.HoverEvent in project Wizardry by TeamWizardry.
the class VersionChecker method onTick.
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onTick(TickEvent.ClientTickEvent event) {
EntityPlayer player = Minecraft.getMinecraft().player;
if (!ConfigValues.versionCheckerEnabled)
return;
if (doneChecking && event.phase == TickEvent.Phase.END && player != null && !triedToWarnPlayer) {
ITextComponent component = new TextComponentString("[").setStyle(new Style().setColor(TextFormatting.GREEN)).appendSibling(new TextComponentTranslation("wizardry.misc.update_link").setStyle(new Style().setColor(TextFormatting.GRAY))).appendSibling(new TextComponentString("]").setStyle(new Style().setColor(TextFormatting.GREEN)));
component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(updateMessage))).setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://minecraft.curseforge.com/projects/wizardry-mod/files"));
if (onlineVersion != null && !onlineVersion.isEmpty()) {
String clientBuild = Wizardry.VERSION;
if (Utils.compareVersions(onlineVersion, clientBuild) == 1) {
ArrayList<String> messages = new ArrayList<>();
String base = "wizardry.update";
int n = 0;
while (LibrarianLib.PROXY.canTranslate(base + n)) messages.add(base + n++);
if (!messages.isEmpty())
player.sendMessage(new TextComponentTranslation(messages.get(RandUtil.nextInt(messages.size() - 1))).setStyle(new Style().setColor(TextFormatting.YELLOW)));
player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker0").setStyle(new Style().setColor(TextFormatting.GREEN)));
player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker1").setStyle(new Style().setColor(TextFormatting.GREEN)).appendText(" ").appendSibling(new TextComponentString(" " + clientBuild).setStyle(new Style().setColor(TextFormatting.RED))));
player.sendMessage(new TextComponentTranslation("wizardry.misc.update_checker2").setStyle(new Style().setColor(TextFormatting.GREEN)).appendText(" ").appendSibling(new TextComponentString(" " + onlineVersion).setStyle(new Style().setColor(TextFormatting.YELLOW))));
if (updateMessage != null && !updateMessage.isEmpty())
player.sendMessage(component);
} else if (updateMessage != null && !updateMessage.isEmpty())
player.sendMessage(component);
}
triedToWarnPlayer = true;
}
}
use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class CommandListStructures method linkToPage.
public static void linkToPage(ITextComponent component, int page, ITextComponent hoverTitle) {
component.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, String.format("/%s", RCCommands.structures.list(page))));
component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverTitle));
component.getStyle().setColor(TextFormatting.AQUA);
}
Aggregations