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


Java ItemTooltipEvent.getToolTip方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.player.ItemTooltipEvent.getToolTip方法的典型用法代码示例。如果您正苦于以下问题:Java ItemTooltipEvent.getToolTip方法的具体用法?Java ItemTooltipEvent.getToolTip怎么用?Java ItemTooltipEvent.getToolTip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.player.ItemTooltipEvent的用法示例。


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

示例1: onItemTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onItemTooltip(ItemTooltipEvent event)
{
	ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
	ItemStack stack = event.getItemStack();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (event.getEntityPlayer() != null)
	{
		PlayerInformation info = (PlayerInformation) event.getEntityPlayer().getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
		
		if (info != null && (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemLEMagical || stack.getItem() instanceof ItemLEBauble))
		{
			Rarity rarity = Rarity.getRarity(nbt);
			
			if (rarity != Rarity.DEFAULT)
			{
				if (stack.getItem() instanceof ItemSword) drawMelee(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemArmor) drawArmor(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemLEMagical) drawMagical(tooltip, stack, nbt, event.getEntityPlayer(), info);
				else if (stack.getItem() instanceof ItemLEBauble) drawBauble(tooltip, stack, nbt, event.getEntityPlayer(), info);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:26,代码来源:EventItemTooltip.java

示例2: onTooltipShow

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
/** Show item damages in their tooltips */
@SubscribeEvent
public void onTooltipShow(ItemTooltipEvent e) {
	if(ACConfig.durabilityTooltips && !e.getItemStack().isEmpty() && e.getItemStack().getItem().isDamageable()) {
		String modid = e.getItemStack().getItem().getRegistryName().getResourceDomain();
		if(!ACConfig.tooltipModBL.contains(modid)) {
			int maxDamage = e.getItemStack().getMaxDamage();
			int currentDamage = e.getItemStack().getItemDamage();
			List<String> t = e.getToolTip();
			if(e.getFlags().isAdvanced() && currentDamage > 0) { // remove the vanilla indicator
				Iterator<String> it = t.iterator();
				while(it.hasNext()) {
					String str = it.next();
					if(str.contains("Durability")) it.remove();
				}
			}
			t.add(1, TextFormatting.DARK_GRAY + "Durability: " + (maxDamage - currentDamage) + " / " + maxDamage);
		}
	}
}
 
开发者ID:sblectric,项目名称:AdvancedCombat,代码行数:21,代码来源:InformationHandler.java

示例3: onTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onTooltip(ItemTooltipEvent event)
{
	ArrayList<String> tooltip = (ArrayList<String>) event.getToolTip();
	ItemStack stack = event.getItemStack();
	NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
	
	if (stack != null && nbt != null)
	{
		if (stack.getItem() instanceof ItemSword || stack.getItem() instanceof ItemArmor || stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemShield || stack.getItem() instanceof ItemTool)
		{
			Rarity rarity = Rarity.getRarity(nbt);
			
			if (rarity != Rarity.DEFAULT)
			{
				addTooltips(tooltip, stack, nbt);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Levels,代码行数:21,代码来源:EventTooltip.java

示例4: onItemTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
/**
 * Change attribute format when displayed on item tooltip
 *
 * @param event
 */
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
    for (String txt : event.getToolTip()) {
        if (txt.startsWith(TextFormatting.BLUE.toString())) {
            if (txt.contains(attributeNames[0]) || txt.contains(attributeNames[2]))
                event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + TextFormatting.getTextWithoutFormattingCodes(txt));
            else if (txt.contains(attributeNames[3]))
                event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.DARK_GREEN + reformat(txt, 3));
            else if (txt.contains(attributeNames[1]))
                event.getToolTip().set(event.getToolTip().indexOf(txt), TextFormatting.GOLD + reformat(txt, 1));
        }
    }
    if(event.getItemStack().getItem() instanceof IBackStabbable){
        event.getToolTip().add(TextFormatting.GOLD + I18n.format("attribute.name.weapon.backstab"));
    }
}
 
开发者ID:Mine-and-blade-admin,项目名称:Battlegear2,代码行数:22,代码来源:BattlegearClientEvents.java

示例5: drawTooltips

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void drawTooltips(ItemTooltipEvent event) {
	ItemStack stack = event.getItemStack();
	if (stack.getItem() instanceof IUpgrade) {
		IUpgrade upgrade = (IUpgrade) stack.getItem();
		List<String> tooltips = event.getToolTip();

		Collection<UpgradableBlockType> compatibleBlocks = upgrade.getCompatibleTypes(stack);
		for (UpgradableBlockType type : compatibleBlocks) {
			tooltips.add(LocalizationHelper.localize("betterchests:tooltip.compatible." + type.name().toLowerCase()));
		}

		int maxUpgrades = upgrade.getMaxAmountUpgrades(stack);
		if (maxUpgrades > 0 && maxUpgrades < Integer.MAX_VALUE) {
			tooltips.add(LocalizationHelper.localizeFormatted("betterchests:tooltip.maxUpgrades", maxUpgrades));
		}

		Collection<ItemStack> requiredUpgrades = upgrade.getRequiredUpgrades(stack);
		if (!requiredUpgrades.isEmpty()) {
			tooltips.add(LocalizationHelper.localize("betterchests:tooltip.requiredUpgrades"));
			for (ItemStack req : requiredUpgrades) {
				tooltips.add("  " + req.getDisplayName());
			}
		}
	}
}
 
开发者ID:Aroma1997,项目名称:BetterChests,代码行数:27,代码来源:ClientEventListener.java

示例6: onToolTip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
void onToolTip(ItemTooltipEvent event)
{
    if (isCorrectModeActive() && isCorrectItem(event.getItemStack()))
    {
        List<String> toolTip = event.getToolTip();

        modifyToolTip(toolTip);
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:11,代码来源:ToolTip.java

示例7: onRenderTooltips

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onRenderTooltips(ItemTooltipEvent event) {
	EntityPlayer player = event.getEntityPlayer();
	ItemStack stack = event.getItemStack();
	List<String> tooltip = event.getToolTip();
	if (stack == null) return;
	handleITooltipHolders(player, stack, tooltip);
	handleBaubleHolding(stack, tooltip);
}
 
开发者ID:yolp900,项目名称:ItsJustaCharm1.10.2Dead,代码行数:11,代码来源:TooltipHandler.java

示例8: onItemHover

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onItemHover(ItemTooltipEvent event) {
	final ItemStack itemStack = event.getItemStack();
	if (itemStack == null) return;

	ITooltip<?> tooltip;

	final Block block = BlockUtils.getBlockFromItem(itemStack.getItem());
	if (block instanceof IBlockTooltip) tooltip = (IBlockTooltip) block;
	else if (itemStack.getItem() instanceof ITooltip<?>) tooltip = (ITooltip<?>) itemStack.getItem();
	else return;

	// ITooltip<?> tooltip = (IBlockTooltip) block;
	// final ITooltip<?> tooltip = (IBlockTooltip) itemStack.getItem();
	final List<String> list = event.getToolTip();
	final boolean hasShiftInfo = tooltip.hasShiftInformation();
	final boolean hasControlInfo = tooltip.hasControlInformation();

	tooltip.addInformation(list, itemStack);

	if (hasShiftInfo) {
		list.add("");

		if (isShiftKeyDown()) tooltip.addShiftInformation(list, itemStack);
		else list.add(shiftInfoTag);
	}

	if (hasControlInfo) {
		if (!hasShiftInfo) list.add("");
		if (isControlKeyDown()) tooltip.addControlInformation(list, itemStack);
		else list.add(controlInfoTag);
	}
}
 
开发者ID:hockeyhurd,项目名称:HCoreLib,代码行数:34,代码来源:ItemTooltipEventHandler.java


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