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


Java HoverEvent类代码示例

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


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

示例1: getChatComponent

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
/**
 * Get a ChatComponent for this Item's display name that shows this Item on hover
 */
public IChatComponent getChatComponent()
{
    ChatComponentText chatcomponenttext = new ChatComponentText(this.getDisplayName());

    if (this.hasDisplayName())
    {
        chatcomponenttext.getChatStyle().setItalic(Boolean.valueOf(true));
    }

    IChatComponent ichatcomponent = (new ChatComponentText("[")).appendSibling(chatcomponenttext).appendText("]");

    if (this.item != null)
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();
        this.writeToNBT(nbttagcompound);
        ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ChatComponentText(nbttagcompound.toString())));
        ichatcomponent.getChatStyle().setColor(this.getRarity().rarityColor);
    }

    return ichatcomponent;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:ItemStack.java

示例2: getStatName

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
@Override
public IChatComponent getStatName() {
    IChatComponent text = this.name.createCopy();
    ChatStyle style = text.getChatStyle();
    style.setColor(color);

    // So the achievement doesn't have to be registered on the client.
    IChatComponent desc = new ChatComponentText("");
    desc.appendSibling(text.createCopy()).appendText("\n");
    IChatComponent type = new ChatComponentText("Achievement");
    type.getChatStyle().setItalic(true);
    desc.appendSibling(type).appendText("\n");
    desc.appendSibling(new ChatComponentText(this.getDescription()));
    HoverEvent hover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, desc);
    style.setChatHoverEvent(hover);

    return text;
}
 
开发者ID:killjoy1221,项目名称:Achievement-Get,代码行数:19,代码来源:StatAchievement.java

示例3: onClientTick

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
	if(event.phase == Phase.END) {
		for(EQMod mod : EQMod.mods.values()) {
			if(mod.config.displayVersionResult && !mod.versionMessage && mod.versionResult == EQVersion.OUTDATED) {
				if(FMLClientHandler.instance().getClient().currentScreen == null) {
					if(mod.versionResult != EQVersion.UNINITIALIZED || mod.versionResult != EQVersion.FINAL_ERROR) {
						mod.versionMessage = true;
						if(mod.versionResult == EQVersion.OUTDATED) {
							ChatComponentText chatComponent = new ChatComponentText(EQVersion.getResultMessageForClient(mod));
							chatComponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(LanguageManager.getLocalization("elconqore.version.chat_hover"))));
							chatComponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, mod.remoteUpdateLocation));
							Minecraft.getMinecraft().thePlayer.addChatMessage(chatComponent);
						}
					}
				}
			}
		}
	}
}
 
开发者ID:ElConquistador,项目名称:ElConQore,代码行数:21,代码来源:EQTickHandlerClient.java

示例4: onPlayerConnect

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
public void onPlayerConnect(ICommandSender sender)
{
	if (checking) {
		this.senders.add(sender);
	} else {
		int updates = UpdateCheckThreadController.instance.getUpdates();
		if (updates > 0) {
			String msg = "There "+(updates == 1 ? "is " : "are ")+EnumChatFormatting.RED+updates+EnumChatFormatting.AQUA+" mod"+(updates == 1 ? "" : "s")+" with"+(updates == 1 ? " a" : "")+" new version"+(updates == 1 ? "" : "s")+".";
			sender.addChatMessage(new ChatComponentText(msg).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA)));
			
			IChatComponent chatComponentBody = new ChatComponentText("For more information, please type ").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.AQUA));
			IChatComponent chatComponentLink = new ChatComponentText("/updates").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.RED).setChatClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/updates")).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText("Run command").setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GOLD)))));;
			sender.addChatMessage(chatComponentBody.appendSibling(chatComponentLink));
		}
	}
}
 
开发者ID:thislooksfun,项目名称:ForgeUpdater,代码行数:17,代码来源:UpdateCheckThreadController.java

示例5: createComponent

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
private IChatComponent createComponent(String[] parts, Iterator args) {
    ChatStyle chatStyle = getStyle(parts[0]);
    String[] textWithHover = parts[1].split(" << ");
    String actualText = textWithHover[0];

    while (actualText.contains("%s")) {
        actualText = actualText.replaceFirst("%s", Matcher.quoteReplacement(args.next().toString()));
    }
    IChatComponent message = new ChatComponentText(actualText).setChatStyle(chatStyle);

    if (textWithHover.length == 2) {
        IChatComponent hoverText = new ChatComponentFormatted("{" + textWithHover[1] + "}", args);
        chatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText));
    }

    return message;
}
 
开发者ID:MyEssentials,项目名称:MyEssentials-Core,代码行数:18,代码来源:ChatComponentFormatted.java

示例6: getFormattedChatText

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
public IChatComponent getFormattedChatText() {
	String text = StatCollector.translateToLocal("neiLotr.versionChecker.notification.chat");
	String[] parts = text.split("7");
	String text1 = parts[0];
	String text2 = parts[1];
	String text3 = parts[2];
	String text4 = parts[3];

	ChatComponentText chat1 = (ChatComponentText) new ChatComponentText("[NEI LOTR]: ")
			.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN));
	ChatComponentText chat2 = (ChatComponentText) new ChatComponentText(text1 + " ")
			.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
	ChatComponentText chat3 = (ChatComponentText) new ChatComponentText(text2)
			.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.BLUE).setUnderlined(true)
					.setChatClickEvent(
							new ClickEvent(Action.OPEN_URL, "https://goo.gl/EkxFlC"))
					.setChatHoverEvent(
							new HoverEvent(net.minecraft.event.HoverEvent.Action.SHOW_TEXT,
									new ChatComponentText(StatCollector
											.translateToLocal("neiLotr.versionChecker.notification.changelog")
											.replace("/", "\n")))));
	ChatComponentText chat4 = (ChatComponentText) new ChatComponentText(" " + text3 + " ")
			.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
	ChatComponentText chat5 = (ChatComponentText) new ChatComponentText(state.toString() + " " + version)
			.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW).setUnderlined(true)
					.setChatClickEvent(
							new ClickEvent(Action.OPEN_URL, url))
					.setChatHoverEvent(
							new HoverEvent(net.minecraft.event.HoverEvent.Action.SHOW_TEXT,
									new ChatComponentText(StatCollector
											.translateToLocal("neiLotr.versionChecker.notification.newVersion")
											.replace("/", "\n")))));
	ChatComponentText chat6 = (ChatComponentText) new ChatComponentText(" " + text4 + " ")
			.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));
	ChatComponentText chat7 = (ChatComponentText) new ChatComponentText(mcVersion)
			.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE));

	return chat1.appendSibling(chat2).appendSibling(chat3).appendSibling(chat4).appendSibling(chat5)
			.appendSibling(chat6).appendSibling(chat7);
}
 
开发者ID:CraftedMods,项目名称:nei-lotr,代码行数:41,代码来源:ModVersion.java

示例7: getHoverEvent

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

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

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

示例8: getStatName

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
public IChatComponent getStatName()
{
    IChatComponent ichatcomponent = this.statName.createCopy();
    ichatcomponent.getChatStyle().setColor(EnumChatFormatting.GRAY);
    ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ACHIEVEMENT, new ChatComponentText(this.statId)));
    return ichatcomponent;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:8,代码来源:StatBase.java

示例9: func_180605_a

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
public void func_180605_a(String p_180605_1_, ChatRawMessage[] p_180605_2_)
{
    for (ChatRawMessage chatrawmessage : p_180605_2_)
    {
        this.func_176027_a(chatrawmessage.userName, chatrawmessage);

        if (this.func_176028_a(chatrawmessage.modes, chatrawmessage.subscriptions, this.mc.gameSettings.streamChatUserFilter))
        {
            IChatComponent ichatcomponent = new ChatComponentText(chatrawmessage.userName);
            IChatComponent ichatcomponent1 = new ChatComponentTranslation("chat.stream." + (chatrawmessage.action ? "emote" : "text"), new Object[] {this.twitchComponent, ichatcomponent, EnumChatFormatting.getTextWithoutFormattingCodes(chatrawmessage.message)});

            if (chatrawmessage.action)
            {
                ichatcomponent1.getChatStyle().setItalic(Boolean.valueOf(true));
            }

            IChatComponent ichatcomponent2 = new ChatComponentText("");
            ichatcomponent2.appendSibling(new ChatComponentTranslation("stream.userinfo.chatTooltip", new Object[0]));

            for (IChatComponent ichatcomponent3 : GuiTwitchUserMode.func_152328_a(chatrawmessage.modes, chatrawmessage.subscriptions, (IStream)null))
            {
                ichatcomponent2.appendText("\n");
                ichatcomponent2.appendSibling(ichatcomponent3);
            }

            ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ichatcomponent2));
            ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.TWITCH_USER_INFO, chatrawmessage.userName));
            this.mc.ingameGUI.getChatGUI().printChatMessage(ichatcomponent1);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:32,代码来源:TwitchStream.java

示例10: onPlayerJoinWorld

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerJoinWorld(EntityJoinWorldEvent event) {
	if (UsefulFunctions.isPlayer(event.entity) && event.world.isRemote) {
		Version version = RorysMod.instance.versionCheker;
		if (!version.haveWarnedVersionOutOfDate && !version.isLatestVersion()) {
			ChatComponentText localChatComponentText = new ChatComponentText("");
			ChatStyle localChatStyle;
			IChatComponent modVersion = new ChatComponentText(EnumChatFormatting.AQUA + StatCollector.translateToLocal("message.rorysmod.version.current") + ": " + RorysGlobal.VERSION);

			IChatComponent modName = new ChatComponentText(EnumChatFormatting.GOLD + "[" + RorysGlobal.NAME + "]" + EnumChatFormatting.WHITE);
			localChatStyle = modName.getChatStyle();
			localChatStyle.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, modVersion));
			localChatStyle.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://rorysmod.rtfd.io"));
			localChatComponentText.appendSibling(modName);

			IChatComponent newVersion = new ChatComponentText(" " + StatCollector.translateToLocal("message.rorysmod.version.new"));
			newVersion.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.WHITE + version.getLatest().getName())));
			localChatComponentText.appendSibling(newVersion);
			UsefulFunctions.getPlayerFromEntity(event.entity).addChatMessage(localChatComponentText);
			localChatComponentText = new ChatComponentText("");

			IChatComponent download = new ChatComponentText(EnumChatFormatting.GREEN + StatCollector.translateToLocal("message.rorysmod.download"));
			download.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, version.getLatest().getHtmlUrl())).setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(EnumChatFormatting.YELLOW + StatCollector.translateToLocal("message.rorysmod.version.download"))));

			IChatComponent update = new ChatComponentText("[");
			update.appendSibling(download);
			update.appendText(EnumChatFormatting.WHITE + "] " + EnumChatFormatting.GRAY + version.getLatest().getName());
			update.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, version.getLatest().getHtmlUrl()));
			localChatComponentText.appendSibling(update);
			UsefulFunctions.getPlayerFromEntity(event.entity).addChatMessage(localChatComponentText);
			version.haveWarnedVersionOutOfDate = true;
		}
	}
}
 
开发者ID:roryclaasen,项目名称:RorysMod,代码行数:35,代码来源:PlayerTickEvents.java

示例11: formatExceptionForChat

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
/**
 * Formats a chat message to inform the player that an exception was caught while processing a
 * chat command
 *
 * @param e
 *        The {@link Exception} that was caught
 * @return A formatted message to be sent to the player
 */
public static final IChatComponent formatExceptionForChat(Exception e) {
	// I _could_ have chained all of this into one line.
	// But then I'd never be willing to debug it.
	// And it /needed/ debugging.
	ChatComponentTranslation msg = new ChatComponentTranslation("coreder.chat.exception");
	ChatStyle style = new ChatStyle();
	HoverEvent onHover = new HoverEvent(Action.SHOW_TEXT, new ChatComponentText(e.toString()));
	style.setItalic(true).setColor(EnumChatFormatting.RED).setUnderlined(true);
	style.setChatHoverEvent(onHover);
	msg.setChatStyle(style);
	return msg;
}
 
开发者ID:PrincessRTFM,项目名称:Coreder,代码行数:21,代码来源:ChatCommandBase.java

示例12: sendNotificationToPlayer

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
private void sendNotificationToPlayer(EntityPlayer player) {
   	if (versionInfo.isCriticalUpdate()) {
   		player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.critical", versionInfo.getLatestVersion()).setChatStyle(alert));
   	}
   	else {
   		player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.newVersion", versionInfo.getLatestVersion()).setChatStyle(newVersion));
   	}
   	ChatStyle thisDescription = description.createShallowCopy();
   	thisDescription.setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, VersionInfo.DownloadURL));
   	thisDescription.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentText(versionInfo.getVersionDescription())));
   	player.addChatMessage(new ChatComponentTranslation("magicbees.versioning.clickDownload").setChatStyle(thisDescription));
}
 
开发者ID:MagicBees,项目名称:MagicBees,代码行数:13,代码来源:TickHandlerVersion.java

示例13: func_151000_E

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
public IChatComponent func_151000_E()
{
    IChatComponent var1 = (new ChatComponentText("[")).appendText(this.getDisplayName()).appendText("]");

    if (this.field_151002_e != null)
    {
        NBTTagCompound var2 = new NBTTagCompound();
        this.writeToNBT(var2);
        var1.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ChatComponentText(var2.toString())));
        var1.getChatStyle().setColor(this.getRarity().rarityColor);
    }

    return var1;
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:15,代码来源:ItemStack.java

示例14: func_150951_e

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
public IChatComponent func_150951_e()
{
    IChatComponent var1 = this.statName.createCopy();
    var1.getChatStyle().setColor(EnumChatFormatting.GRAY);
    var1.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ACHIEVEMENT, new ChatComponentText(this.statId)));
    return var1;
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:8,代码来源:StatBase.java

示例15: run

import net.minecraft.event.HoverEvent; //导入依赖的package包/类
@Override
public boolean run(Screenshot screenshot) {
    Minecraft minecraft = Minecraft.getMinecraft();

    if (screenshot != null && screenshot.imageID != 0) {

        String path = ConfigHandler.formatImagePath(minecraft);
        File outputFile = new File(minecraft.mcDataDir, path);

        if (outputFile != null) {
            if (!outputFile.getParentFile().exists()) {
                outputFile.getParentFile().mkdirs();
            }

            try {
                ImageIO.write(screenshot.image, ConfigHandler.SAVE_FORMAT, outputFile);
            } catch (IOException e) {
                MessageHandler.sendChatMessage("image.upload.fail", e.getMessage());
                e.printStackTrace();
                return false;
            }

            IChatComponent message = new ChatComponentTranslation("image.upload.success");
            IChatComponent url = new ChatComponentText("Disk");

            url.setChatStyle(new ChatStyle()
                    .setColor(EnumChatFormatting.GOLD)
                    .setBold(true)
                    .setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ChatComponentTranslation("image.disk.click")))
                    .setChatClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, path)));

            message.appendSibling(url);

            MessageHandler.sendChatMessage(message);
            HistoryHandler.addUploadedImage(new UploadedImage(outputFile.getName().substring(0, outputFile.getName().length() - 4), path, screenshot, new HDImageSource(outputFile)));
            return true;
        }
    }
    return false;
}
 
开发者ID:CodingBadgers,项目名称:bUpload,代码行数:41,代码来源:HDUploadHandler.java


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