當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。