use of net.minecraft.util.text.event.HoverEvent in project GregTech by GregTechCE.
the class AdvancedTextWidget method withHoverTextTranslate.
public static ITextComponent withHoverTextTranslate(ITextComponent textComponent, String hoverTranslation) {
Style style = textComponent.getStyle();
ITextComponent translation = new TextComponentTranslation(hoverTranslation);
translation.getStyle().setColor(TextFormatting.GRAY);
style.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, translation));
return textComponent;
}
use of net.minecraft.util.text.event.HoverEvent in project GregTech by GregTechCE.
the class MultiblockWithDisplayBase method addDisplayText.
/**
* Called serverside to obtain text displayed in GUI
* each element of list is displayed on new line
* to use translation, use TextComponentTranslation
*/
protected void addDisplayText(List<ITextComponent> textList) {
if (!isStructureFormed()) {
ITextComponent tooltip = new TextComponentTranslation("gregtech.multiblock.invalid_structure.tooltip");
tooltip.setStyle(new Style().setColor(TextFormatting.GRAY));
textList.add(new TextComponentTranslation("gregtech.multiblock.invalid_structure").setStyle(new Style().setColor(TextFormatting.RED).setHoverEvent(new HoverEvent(Action.SHOW_TEXT, tooltip))));
}
}
use of net.minecraft.util.text.event.HoverEvent in project GregTech by GregTechCE.
the class CoverFluidRegulator method getHoverString.
protected void getHoverString(List<ITextComponent> textList) {
switch(this.transferMode) {
case KEEP_EXACT:
ITextComponent keepComponent = new TextComponentString(getTransferSizeString());
TextComponentTranslation hoverKeep = new TextComponentTranslation("cover.fluid_regulator.keep_exact", this.keepAmount);
keepComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverKeep));
textList.add(keepComponent);
break;
case TRANSFER_EXACT:
ITextComponent supplyComponent = new TextComponentString(getTransferSizeString());
TextComponentTranslation hoverSupply = new TextComponentTranslation("cover.fluid_regulator.supply_exact", this.supplyAmount);
supplyComponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverSupply));
textList.add(supplyComponent);
break;
}
}
use of net.minecraft.util.text.event.HoverEvent in project Bookshelf by Darkhax-Minecraft.
the class CommandHand method hand.
private int hand(CommandContext<CommandSource> context) throws CommandSyntaxException {
final OutputType type = context.getArgument("type", OutputType.class);
final ServerPlayerEntity player = context.getSource().getPlayerOrException();
final String outputText = type.converter.apply(player.getMainHandItem());
final ITextComponent component = TextComponentUtils.wrapInSquareBrackets(new StringTextComponent(outputText).withStyle((style) -> {
return style.withColor(TextFormatting.GREEN).withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, outputText)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslationTextComponent("chat.copy.click"))).withInsertion(outputText);
}));
context.getSource().sendSuccess(component, false);
return 0;
}
use of net.minecraft.util.text.event.HoverEvent in project RecurrentComplex by Ivorforce.
the class RCTextStyle method copy.
public static ITextComponent copy(String text) {
ITextComponent comp = new TextComponentString(text);
comp.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, RecurrentComplex.translations.get("commands.rccopy.suggest")));
comp.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, text));
return comp;
}
Aggregations