• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ClickEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onPlayerLogin

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event){
    if(DifficultyManager.enabled && ProgressiveDifficulty.oldConfigExists){
        TextComponentString linkComponent = new TextComponentString("[Progressive Difficulty Wiki]");
        ITextComponent[] chats = new ITextComponent[]{
                new TextComponentString("[ProgressiveDifficulty] It looks like you have a version 1.0 " +
                        "config file. Please check out the Progressive Difficulty Wiki for instructions on how" +
                        " to migrate to a version 2.0 config file."),
                linkComponent
        };
        ClickEvent goLinkEvent = new ClickEvent(ClickEvent.Action.OPEN_URL,"https://github.com/talandar/ProgressiveDifficulty/wiki/2.0-Transition");
        linkComponent.getStyle().setClickEvent(goLinkEvent);
        linkComponent.getStyle().setColor(TextFormatting.BLUE);
        linkComponent.getStyle().setUnderlined(true);
        ChatUtil.sendChat(event.player,chats);
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:18,代码来源:EventHandler.java


示例2: mouseClicked

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Override
public boolean mouseClicked(int mouseX, int mouseY, int y, int virtualWidth) {
	ITextComponent hoveredComponent = getHoveredComponent(virtualWidth, y, mouseX, mouseY);
	if (hoveredComponent != null) {
		ClickEvent clickEvent = hoveredComponent.getStyle().getClickEvent();
		if (clickEvent != null && clickEvent.getAction() == ClickEvent.Action.CHANGE_PAGE) {
			String value = clickEvent.getValue();
			String name = null;
			if (value.contains("=")) {
				int equalsIndex = value.indexOf('=');
				name = value.substring(0, equalsIndex);
				value = value.substring(equalsIndex + 1);
			}
			CommandHelpManager.getInstance().displayHelpScreen(name, value);
			return true;
		} else {
			return GeneralUtils.handleClickEvent(clickEvent);
		}
	} else
		return false;
}
 
开发者ID:Earthcomputer,项目名称:Easy-Editors,代码行数:22,代码来源:CommandHelpManager.java


示例3: notifyUser

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
private void notifyUser(VersionData data, UpdateResponse response) {
    ITextBuilder builder = new TextBuilder()
            .translation("update.available")
            .text(data.getName())
            .format(TextFormatting.GOLD)
            .end()
            .text(" ");
    if (data.getUrl() != null)
        builder.translation("update.clickhere").end()
                .format(TextFormatting.LIGHT_PURPLE)
                .click(new ClickEvent(ClickEvent.Action.OPEN_URL, data.getUrl()))
                .text(". ");
    ITextComponent msg = builder
            .text(response.minecraft.version)
            .text(" - ")
            .text(response.minecraft.changes)
            .build();
    LogManager.getLogger("Updates").info(msg.getUnformattedText());
    this.chatProxy.addToChat("Updates", msg);
}
 
开发者ID:killjoy1221,项目名称:MnM-Utils,代码行数:21,代码来源:UpdateChecker.java


示例4: makeChat

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
private static ITextComponent makeChat(boolean tag) {

        ITextComponent chat = new TextComponentString(tag ? "[test] " : "");
        chat.getStyle().setBold(true);
        {
            ITextComponent colored = new TextComponentString("This should be green. ");
            colored.getStyle().setColor(TextFormatting.GREEN);
            chat.appendSibling(colored);
        }
        chat.appendText(" ");
        {
            ITextComponent link = new TextComponentString("This is a link.");
            link.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://google.com/"));
            chat.appendSibling(link);
        }
        return chat;
    }
 
开发者ID:killjoy1221,项目名称:TabbyChat-2,代码行数:18,代码来源:ChatTextUtilsTest.java


示例5: append

import net.minecraft.util.text.event.ClickEvent; //导入依赖的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


示例6: mouseClicked

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
    super.mouseClicked(mouseX, mouseY, mouseButton);

    int info2Start = (this.height / 2) - 50;

    if (orderPressed && !isSure && mouseY >= info2Start && mouseY <= info2Start + fontRendererObj.FONT_HEIGHT)
    {
        ITextComponent comp = getComponent(mouseX, mouseY);

        ClickEvent clickevent = comp.getStyle().getClickEvent();
        if (clickevent != null && clickevent.getAction() == ClickEvent.Action.OPEN_URL)
        {
            try
            {
                URI uri = new URI(clickevent.getValue());
                Class<?> oclass = Class.forName("java.awt.Desktop");
                Object object = oclass.getMethod("getDesktop").invoke(null);
                oclass.getMethod("browse", URI.class).invoke(object, uri);
            }
            catch (Throwable t)
            {
                CreeperHost.logger.error("Can\'t open url for " + clickevent, t);
            }
            return;
        }
    }

    for (TextFieldDetails field : this.fields)
    {
        field.myMouseClicked(mouseX, mouseY, mouseButton);
    }
}
 
开发者ID:CreeperHost,项目名称:CreeperHostGui,代码行数:35,代码来源:GuiPersonalDetails.java


示例7: addURLClick

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


示例8: getDisplayName

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Get the formatted ChatComponent that will be used for the sender's username in chat
 */
public ITextComponent getDisplayName()
{
    ITextComponent itextcomponent = new TextComponentString(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getName()));
    itextcomponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getName() + " "));
    itextcomponent.getStyle().setHoverEvent(this.getHoverEvent());
    itextcomponent.getStyle().setInsertion(this.getName());
    return itextcomponent;
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:12,代码来源:EntityPlayer.java


示例9: getClickEvent

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

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


示例10: getDisplayName

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Get the formatted ChatComponent that will be used for the sender's username in chat
 */
public ITextComponent getDisplayName()
{
    ITextComponent itextcomponent = new TextComponentString("");
    if (!prefixes.isEmpty()) for (ITextComponent prefix : prefixes) itextcomponent.appendSibling(prefix);
    itextcomponent.appendSibling(new TextComponentString(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getDisplayNameString())));
    if (!suffixes.isEmpty()) for (ITextComponent suffix : suffixes) itextcomponent.appendSibling(suffix);
    itextcomponent.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getName() + " "));
    itextcomponent.getStyle().setHoverEvent(this.getHoverEvent());
    itextcomponent.getStyle().setInsertion(this.getName());
    return itextcomponent;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:EntityPlayer.java


示例11: sendRecordMessage

import net.minecraft.util.text.event.ClickEvent; //导入依赖的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: climsg

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
protected void climsg(EntityPlayer p) {
	final TextComponentTranslation tt = new TextComponentTranslation("mcflux.update.newversion", version);
	tt.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, R.MF_URL));
	p.sendMessage(tt);
}
 
开发者ID:Szewek,项目名称:Minecraft-Flux,代码行数:8,代码来源:Msg.java


示例13: handleComponentClick

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Executes the click event specified by the given chat component
 */
protected boolean handleComponentClick(ITextComponent component) {
    ClickEvent clickevent = component.getStyle().getClickEvent();

    if (clickevent == null) {
        return false;
    } else if (clickevent.getAction() == ClickEvent.Action.CHANGE_PAGE) {
        String s = clickevent.getValue();

        try {
            int i = Integer.parseInt(s) - 1;

            if (i >= 0 && i < this.bookTotalPages && i != this.currPage) {
                this.currPage = i;
                this.updateButtons();
                return true;
            }
        } catch (Throwable var5) {
            ;
        }

        return false;
    } else {
        boolean flag = super.handleComponentClick(component);
        if (flag && clickevent.getAction() == ClickEvent.Action.RUN_COMMAND) {
            this.mc.displayGuiScreen((GuiScreen)null);
        }
        return flag;
    }
}
 
开发者ID:r1chardj0n3s,项目名称:pycode-minecraft,代码行数:33,代码来源:GuiPythonBook.java


示例14: execute

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Override
public String execute(CommandSender sender, String[] params) throws CommandException {
	DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
	
	ITextComponent textModid = new TextComponentString("MODID:             ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent modid = new TextComponentString(Reference.MODID).setStyle(new Style().setColor(TextFormatting.GREEN));
	
	ITextComponent textVersion = new TextComponentString("VERSION:          ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent version = new TextComponentString(Reference.VERSION).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textName = new TextComponentString("NAME:              ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent name = new TextComponentString(Reference.NAME).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textModDir = new TextComponentString("MOD_DIR:          ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent modDir = new TextComponentString(Reference.getModDir().getPath()).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textBuildDate = new TextComponentString("BUILD_DATE:     ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent builDate = new TextComponentString(df.format(Reference.BUILD)).setStyle(new Style().setColor(TextFormatting.GREEN));

	ITextComponent textWebsite = new TextComponentString("WEBSITE         ").setStyle(new Style().setColor(TextFormatting.DARK_AQUA));
	ITextComponent website = new TextComponentString(Reference.WEBSITE).setStyle(new Style().setColor(TextFormatting.GREEN).setUnderlined(true).setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, Reference.WEBSITE)));
	
	sender.sendChatComponent(textModid.appendSibling(modid));
	sender.sendChatComponent(textVersion.appendSibling(version));
	sender.sendChatComponent(textName.appendSibling(name));
	sender.sendChatComponent(textModDir.appendSibling(modDir));
	sender.sendChatComponent(textBuildDate.appendSibling(builDate));
	sender.sendChatComponent(textWebsite.appendSibling(website));
	
	return null;
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:32,代码来源:CommandMorecommands.java


示例15: findMoreCommandsUpdates

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Starts a thread looking for MoreCommands updates
 */
private void findMoreCommandsUpdates() {
	this.mod.getLogger().info("Searching for MoreCommands updates");
	
	new Thread(new MoreCommandsUpdater(Loader.MC_VERSION, new MoreCommandsUpdater.UpdateCallback() {
		@Override
		public void udpate(String version, String website, String download) {
			TextComponentString text = new TextComponentString(Reference.VERSION.equals(version) ? 
					"MoreCommands update for this version found " : "new MoreCommands version found: "); 
			text.getStyle().setColor(TextFormatting.BLUE);
			TextComponentString downloadVersion = new TextComponentString(version); downloadVersion.getStyle().setColor(TextFormatting.YELLOW);
			TextComponentString homepage = new TextComponentString("Minecraft Forum"); homepage.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, website)).setColor(TextFormatting.GREEN).setItalic(true).setUnderlined(true);
			TextComponentString downloadPage = new TextComponentString("Download"); downloadPage.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, download)).setColor(TextFormatting.GREEN).setItalic(true).setUnderlined(true);
			TextComponentString comma = new TextComponentString(", "); comma.getStyle().setColor(TextFormatting.DARK_GRAY);
			TextComponentString sep = new TextComponentString(" - "); sep.getStyle().setColor(TextFormatting.DARK_GRAY);
			
			String rawText = text.getUnformattedText() + (Reference.VERSION.equals(version) ? "" : downloadVersion.getUnformattedText()) + " - " + website + ", " + download;
			if (!Reference.VERSION.equals(version)) text.appendSibling(downloadVersion);
			text.appendSibling(sep).appendSibling(homepage).appendSibling(comma).appendSibling(downloadPage);
			
			CommonProxy.this.mod.getLogger().info(rawText);
			CommonProxy.this.updateText = text;
			
			if (MoreCommands.isClientSide() && net.minecraft.client.Minecraft.getMinecraft().player != null) {
				CommonProxy.this.playerNotified = true;
				net.minecraft.client.Minecraft.getMinecraft().player.sendMessage(text);
			}
		}
	}), "MoreCommands Update Thread").start();
}
 
开发者ID:MrNobody98,项目名称:morecommands,代码行数:33,代码来源:CommonProxy.java


示例16: processCommand

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
@Override
public boolean processCommand(ICommandSender sender, String[] parameters) throws CommandException {
    List list = this.getSortedPossibleCommands(sender);
    byte b0 = 7;
    int i = (list.size() - 1) / b0;
    boolean flag = false;
    int k;

    try {
        k = parameters.length == 0 ? 0 : net.minecraft.command.CommandBase.parseInt(parameters[0], 1, i + 1) - 1;
    } catch (NumberInvalidException numberinvalidexception) {
        Map map = this.getCommands();
        AbstractCommand icommand = (AbstractCommand) map.get(parameters[0]);

        if (icommand != null) {
            CommandManager.throwError(sender, icommand);
            return true;
        }

        if (MathHelper.parseIntWithDefault(parameters[0], -1) != -1) {
            throw numberinvalidexception;
        }

        throw new CommandNotFoundException();
    }

    int j = Math.min((k + 1) * b0, list.size());
    TextComponentTranslation chatcomponenttranslation1 = new TextComponentTranslation("crafting.commands.help.header", new Object[] { Integer.valueOf(k + 1), Integer.valueOf(i + 1) });
    chatcomponenttranslation1.getStyle().setColor(TextFormatting.DARK_GREEN);
    sender.addChatMessage(chatcomponenttranslation1);

    for (int l = k * b0; l < j; ++l) {
        AbstractCommand icommand1 = (AbstractCommand) list.get(l);
        TextComponentTranslation chatcomponenttranslation = new TextComponentTranslation(CommandManager.getUsage(icommand1), new Object[0]);
        chatcomponenttranslation.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + icommand1.getCommandName() + " "));
        sender.addChatMessage(chatcomponenttranslation);
    }

    return true;
}
 
开发者ID:joshiejack,项目名称:Progression,代码行数:41,代码来源:CommandHelp.java


示例17: createURLComponent

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Creates a url chat component.
 *
 * @param separateMessages boolean flag to separate by commas and space.
 * @param url String url to use.
 * @param maskURL String url mask.
 * @param messages Messages.
 * @return IChatComponent.
 */
public static ITextComponent createURLComponent(boolean separateMessages, String url, String maskURL, String... messages) {
    if (!StringUtils.nullCheckString(url) || !StringUtils.contains(url, '.'))
        throw new NullPointerException("URL doesn't exist!");

    ITextComponent comp = createComponent(separateMessages, messages);
    comp.appendText(" " + (StringUtils.nullCheckString(maskURL) ? maskURL : url));

    comp.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url));

    return comp;
}
 
开发者ID:hockeyhurd,项目名称:HCoreLib,代码行数:21,代码来源:ChatUtils.java


示例18: createCmdComponent

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Creates a command chat component.
 *
 * @param separateMessages boolean flag to separate by commas and space.
 * @param command HCommand to use.
 * @param messages Messages.
 * @return IChatComponent.
 */
public static ITextComponent createCmdComponent(boolean separateMessages, HCommand command, String... messages) {
    if (command == null)
        return createComponent(false, "<Invalid command>");

    ITextComponent comp = createComponent(separateMessages, messages);

    comp.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
            command.getUsage(null)));

    return comp;
}
 
开发者ID:hockeyhurd,项目名称:HCoreLib,代码行数:20,代码来源:ChatUtils.java


示例19: createFileComponent

import net.minecraft.util.text.event.ClickEvent; //导入依赖的package包/类
/**
 * Creates a file chat component.
 *
 * @param separateMessages boolean flag to separate by commas and space.
 * @param file File to open.
 * @param messages Messages.
 * @return IChatComponent.
 */
public static ITextComponent createFileComponent(boolean separateMessages, File file, String... messages) {
    if (file == null || !file.exists())
        return createComponent(false, "<missing file>");

    ITextComponent comp = createComponent(separateMessages, messages);

    comp.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, file.getAbsolutePath()));

    return comp;
}
 
开发者ID:hockeyhurd,项目名称:HCoreLib,代码行数:19,代码来源:ChatUtils.java


示例20: playerDeath

import net.minecraft.util.text.event.ClickEvent; //导入依赖的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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AssistContent类代码示例发布时间:2022-05-21
下一篇:
Java PsiMethodCallExpression类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap