当前位置: 首页>>代码示例>>Java>>正文


Java HoverEvent类代码示例

本文整理汇总了Java中net.minecraft.util.text.event.HoverEvent的典型用法代码示例。如果您正苦于以下问题:Java HoverEvent类的具体用法?Java HoverEvent怎么用?Java HoverEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HoverEvent类属于net.minecraft.util.text.event包,在下文中一共展示了HoverEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTextComponent

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
/**
 * Get a ChatComponent for this Item's display name that shows this Item on hover
 */
public ITextComponent getTextComponent()
{
    TextComponentString textcomponentstring = new TextComponentString(this.getDisplayName());

    if (this.hasDisplayName())
    {
        textcomponentstring.getStyle().setItalic(Boolean.valueOf(true));
    }

    ITextComponent itextcomponent = (new TextComponentString("[")).appendSibling(textcomponentstring).appendText("]");

    if (!this.field_190928_g)
    {
        NBTTagCompound nbttagcompound = this.writeToNBT(new NBTTagCompound());
        itextcomponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new TextComponentString(nbttagcompound.toString())));
        itextcomponent.getStyle().setColor(this.getRarity().rarityColor);
    }

    return itextcomponent;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:ItemStack.java

示例2: getTextComponent

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
/**
 * Get a ChatComponent for this Item's display name that shows this Item on hover
 */
public ITextComponent getTextComponent()
{
    TextComponentString textcomponentstring = new TextComponentString(this.getDisplayName());

    if (this.hasDisplayName())
    {
        textcomponentstring.getStyle().setItalic(Boolean.valueOf(true));
    }

    ITextComponent itextcomponent = (new TextComponentString("[")).appendSibling(textcomponentstring).appendText("]");

    if (this.item != null)
    {
        NBTTagCompound nbttagcompound = this.writeToNBT(new NBTTagCompound());
        itextcomponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new TextComponentString(nbttagcompound.toString())));
        itextcomponent.getStyle().setColor(this.getRarity().rarityColor);
    }

    return itextcomponent;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:ItemStack.java

示例3: tryParsePlaceMessage

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
private boolean tryParsePlaceMessage(ITextComponent msg)
{
    List<ITextComponent> siblings = msg.getSiblings();
    if (siblings.size() <= 0)
        return false;

    ITextComponent hoverComponent = siblings.get(0);

    HoverEvent hover = hoverComponent.getStyle().getHoverEvent();
    if (hover != null)
    {
        String text = hover.getValue().getUnformattedComponentText();
        Snitch snitch = parseSnitchFromChat(text);
        if (snitch != null)
        {
            manager.submitSnitch(snitch);
            return true;
        }
    }

    return false;
}
 
开发者ID:MrLittleKitty,项目名称:Snitch-Master,代码行数:23,代码来源:ChatSnitchParser.java

示例4: append

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
/**
 * Appends a string with the specified color(s) and an event
 * triggered on text click and on text hover. Only one actual
 * color should be specified, any other {@code TextFormatting}
 * type should be styling. (Bold, Italic, Underline, Strikethrough,
 * and Obfuscated)
 *
 * @param text The string being appended
 * @param clickEvent Click event to be used
 * @param hoverEvent Hover event to be used
 * @param colors Color formatting
 * @return This builder
 */
public final ChatBuilder append(String text, @Nullable ClickEvent clickEvent, @Nullable HoverEvent hoverEvent, TextFormatting... colors) {
    TextComponentString component = new TextComponentString(text);
    Style style = component.getStyle();
    Arrays.stream(colors).forEach(color -> {
        switch (color) {
            case BOLD: {
                style.setBold(true);
                break;
            }
            case ITALIC: {
                style.setItalic(true);
                break;
            }
            case UNDERLINE: {
                style.setUnderlined(true);
                break;
            }
            case STRIKETHROUGH: {
                style.setStrikethrough(true);
                break;
            }
            case OBFUSCATED: {
                style.setObfuscated(true);
                break;
            }
            default: {
                style.setColor(color);
                break;
            }
        }
    });
    // noinspection ConstantConditions
    style.setClickEvent(clickEvent).setHoverEvent(hoverEvent);
    this.component.appendSibling(component);
    return this;
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:50,代码来源:ChatBuilder.java

示例5: addHoverText

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
public static ITextComponent addHoverText(ITextComponent component, ITextComponent hoverComponent)
{
	Style s = component.getStyle();
	s.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverComponent));
	component.setStyle(s);
	return component;
}
 
开发者ID:orbwoi,项目名称:UniversalRemote,代码行数:8,代码来源:TextFormatter.java

示例6: getHoverEvent

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
protected HoverEvent getHoverEvent()
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    ResourceLocation resourcelocation = EntityList.func_191301_a(this);
    nbttagcompound.setString("id", this.getCachedUniqueIdString());

    if (resourcelocation != null)
    {
        nbttagcompound.setString("type", resourcelocation.toString());
    }

    nbttagcompound.setString("name", this.getName());
    return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new TextComponentString(nbttagcompound.toString()));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:Entity.java

示例7: getStatName

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
public ITextComponent getStatName()
{
    ITextComponent itextcomponent = this.statName.createCopy();
    itextcomponent.getStyle().setColor(TextFormatting.GRAY);
    itextcomponent.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ACHIEVEMENT, new TextComponentString(this.statId)));
    return itextcomponent;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:8,代码来源:StatBase.java

示例8: getHoverEvent

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
@Nullable

    /**
     * The effective chat hover event.
     */
    public HoverEvent getHoverEvent()
    {
        return this.hoverEvent == null ? this.getParent().getHoverEvent() : this.hoverEvent;
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:10,代码来源:Style.java

示例9: getHoverEvent

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
protected HoverEvent getHoverEvent()
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    String s = EntityList.getEntityString(this);
    nbttagcompound.setString("id", this.getCachedUniqueIdString());

    if (s != null)
    {
        nbttagcompound.setString("type", s);
    }

    nbttagcompound.setString("name", this.getName());
    return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new TextComponentString(nbttagcompound.toString()));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:Entity.java

示例10: parseHover

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
private ITextComponent parseHover(SnitchAlert alert)
{
    try
    {
        //If we are parsing a hover then the current index is for the hover instruction
        //That means that we have 2 parts: 1-TEXT YOU SEE IN CHAT, 2-TEXT THAT YOU SEE WHEN YOU HOVER
        //Either of those 2 could be a string substitution or a variable instruction

        String text;
        //Move index to the first instruction part (text to show in chat)
        index++;
        String showText = getTextForCurrentInstruction(alert);
        //Move index to second instruction part (text shown on hover)
        index++;
        String hoverText = getTextForCurrentInstruction(alert);
        index++;

        HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(hoverText));
        ITextComponent hoverComponent = new TextComponentString(showText).setStyle(new Style().setColor(TextFormatting.AQUA).setHoverEvent(hoverEvent));

        index--;//????
        return hoverComponent;
    }
    catch (Exception e)
    {
        return null;
    }
}
 
开发者ID:MrLittleKitty,项目名称:Snitch-Master,代码行数:29,代码来源:QuietTimeHandler.java

示例11: sendRecordMessage

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
/**
 * Send record message to the player
 */
private void sendRecordMessage()
{
    EntityPlayer player = this.mc.thePlayer;

    if (this.filename.getText().isEmpty())
    {
        L10n.error(player, "recording.fill_filename");

        return;
    }

    String command = "/action record " + this.filename.getText() + " " + this.pos.getX() + " " + this.pos.getY() + " " + this.pos.getZ();

    ITextComponent component = new TextComponentString(stringClickhere);
    component.getStyle().setClickEvent(new ClickEvent(Action.RUN_COMMAND, command));
    component.getStyle().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString(command)));
    component.getStyle().setColor(TextFormatting.GRAY).setUnderlined(true);

    L10n.info(player, "recording.message", this.filename.getText(), component);

    /* Add the command to the history */
    List<String> messages = this.mc.ingameGUI.getChatGUI().getSentMessages();

    boolean empty = messages.isEmpty();
    boolean lastMessageIsntCommand = !empty && !messages.get(messages.size() - 1).equals(command);

    if (lastMessageIsntCommand || empty)
    {
        messages.add(command);
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:35,代码来源:GuiReplay.java

示例12: playerDeath

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
@SubscribeEvent
public static void playerDeath(LivingDeathEvent event)
{
    if (event.getEntityLiving() instanceof EntityPlayer && printDeathCoords)
    {
        TextComponentString posText = new TextComponentString("X: " + MathHelper.floor(event.getEntityLiving().posX) + " Y: " + MathHelper.floor(event.getEntityLiving().posY + 0.5d) + " Z: " + MathHelper.floor(event.getEntityLiving().posZ));
        try
        {
            MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
            if (server.getCommandManager().getPossibleCommands(event.getEntityLiving()).contains(server.getCommandManager().getCommands().get("tp")))
            {
                posText.setStyle(new Style().setItalic(true)
                        .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Click to teleport!")))
                        .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + MathHelper.floor(event.getEntityLiving().posX) + " " + MathHelper.floor(event.getEntityLiving().posY + 0.5d) + " " + MathHelper.floor(event.getEntityLiving().posZ))));
            }
            if (server.getCommandManager().getPossibleCommands(event.getEntityLiving()).contains(server.getCommandManager().getCommands().get("tpx")))
            {
                posText.setStyle(new Style().setItalic(true)
                        .setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponentString("Click to teleport!")))
                        .setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpx " + ((EntityPlayer) event.getEntityLiving()).dimension + " " + MathHelper.floor(event.getEntityLiving().posX) + " " + MathHelper.floor(event.getEntityLiving().posY + 0.5d) + " " + MathHelper.floor(event.getEntityLiving().posZ))));
            }
        }
        catch (Exception ignored)
        {

        }            
        event.getEntityLiving().sendMessage(new TextComponentString("You died at ").setStyle(new Style().setColor(TextFormatting.AQUA)).appendSibling(posText));
    }
}
 
开发者ID:DoubleDoorDevelopment,项目名称:D3Core,代码行数:30,代码来源:EventHandler.java

示例13: drawScreen

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    this.drawDefaultBackground();
    super.drawScreen(mouseX, mouseY, partialTicks);

    if (!orderPressed || isSure)
    {
        for (TextFieldDetails field : this.fields)
        {
            if (loginMode)
            {
                if (field.getId() < 2)
                {
                    field.drawTextBox();
                }
            }
            else
            {
                field.drawTextBox();
            }
        }

        if (loginMode)
        {
            if (loggingIn)
            {
                this.drawCenteredString(fontRendererObj, Util.localize("details.login"), this.width / 2, (this.height / 2) - 20, 0xFFFFFF);
            }
            else if (!loggingInError.isEmpty())
            {
                this.drawCenteredString(fontRendererObj, Util.localize("details.loginerror") + loggingInError, this.width / 2, (this.height / 2) - 20, 0xFFFFFF);
            }
            else if (loggedIn)
            {
                this.drawCenteredString(fontRendererObj, Util.localize("details.loginsuccess"), this.width / 2, (this.height / 2) - 20, 0xFFFFFF);
            }
            else
            {
                this.drawCenteredString(fontRendererObj, Util.localize("details.accountexists"), this.width / 2, (this.height / 2) - 20, 0xFFFFFF);
            }
        }
    }
    else
    {
        int info2Start = (this.height / 2) - 50;

        this.drawCenteredString(fontRendererObj, Util.localize("order.info1"), this.width / 2, (this.height / 2) - 60, 0xFFFFFF);
        this.drawCenteredString(fontRendererObj, info2.getFormattedText(), this.width / 2, (this.height / 2) - 50, 0xFFFFFF);
        this.drawCenteredString(fontRendererObj, Util.localize("order.info3"), this.width / 2, (this.height / 2) - 30, 0xFFFFFF);
        this.drawCenteredString(fontRendererObj, Util.localize("order.info4"), this.width / 2, (this.height / 2) - 20, 0xFFFFFF);

        if (mouseY >= info2Start && mouseY <= info2Start + fontRendererObj.FONT_HEIGHT)
        {
            ITextComponent component = getComponent(mouseX, mouseY);

            if (component != null)
            {
                HoverEvent event = component.getStyle().getHoverEvent();
                if (event != null)
                    if (event.getAction() == HoverEvent.Action.SHOW_TEXT)
                        this.drawHoveringText(Splitter.on("\n").splitToList(event.getValue().getFormattedText()), mouseX, mouseY);
            }
        }
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:67,代码来源:GuiPersonalDetails.java

示例14: setHoverEvent

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
public Style setHoverEvent(HoverEvent event)
{
    throw new UnsupportedOperationException();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:5,代码来源:Style.java

示例15: getHoverEvent

import net.minecraft.util.text.event.HoverEvent; //导入依赖的package包/类
/**
 * The effective chat hover event.
 */
@Nullable
public HoverEvent getHoverEvent()
{
    return null;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:Style.java


注:本文中的net.minecraft.util.text.event.HoverEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。