當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemTooltipEvent.getItemStack方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.ItemTooltipEvent.getItemStack方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemTooltipEvent.getItemStack方法的具體用法?Java ItemTooltipEvent.getItemStack怎麽用?Java ItemTooltipEvent.getItemStack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.ItemTooltipEvent的用法示例。


在下文中一共展示了ItemTooltipEvent.getItemStack方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onItemTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent ev)
{
	ItemStack itemStack = ev.getItemStack();

	if (itemStack.getItem() instanceof IClassifiedItem)
	{
		IClassifiedItem classifiedItem = (IClassifiedItem)itemStack.getItem();
		String transItemClass = I18n.translateToLocal("compositegear.itemclass");

		ev.getToolTip().add(1, transItemClass + ": " + classifiedItem.getItemClass().getLocalized());
		
		if (itemStack.getItem() instanceof ItemCGArmor) {
			String transItemDesc = I18n.translateToLocal("compositegear.itemdesc");
			
			
			if (((ItemCGArmor)itemStack.getItem()).hasDescription()) {
				String descriptionString = I18n.translateToLocal(itemStack.getItem().getUnlocalizedName() + ".description");
				ev.getToolTip().add(2, transItemDesc + ": " + descriptionString);
			}
		}
	}
}
 
開發者ID:TwilightWingsStudio,項目名稱:CompositeGear,代碼行數:25,代碼來源:ClientEventHandler.java

示例3: renderQuartzTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGH)
@SideOnly(Side.CLIENT)
public void renderQuartzTooltip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();
    if(stack == null)
        return;
    NBTTagCompound compound = stack.getTagCompound();

    if(!stack.isEmpty() && compound != null && compound.hasKey("QuartzCrystal"))
    {
        int growth = compound.getInteger("QuartzCrystalGrowth");
        int souls = compound.getInteger("QuartzSouls");
        event.getToolTip().add(TextFormatting.LIGHT_PURPLE+getSaturationString(growth,false));
        if(souls > 0)
            event.getToolTip().add(TextFormatting.DARK_RED+getSoulString(souls,27,false));
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:19,代碼來源:RenewablesHandler.java

示例4: onToolTipEvent

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = LOWEST)
@SuppressWarnings("unused")
public void onToolTipEvent(ItemTooltipEvent event) {
    if(event.getItemStack() ==null) {
        return;
    }
    if(ConfigurationHandler.getInstance().tooltipOnLinkItems && BoatLinker.getInstance().isValidLinkKey(event.getItemStack())) {
        this.addBoatLinkTooltip(event.getToolTip());
    }
    if(ConfigurationHandler.getInstance().tooltipOnChests && event.getItemStack().getItem() == Item.getItemFromBlock(Blocks.CHEST)) {
        this.addChestBoatTooltip(event.getToolTip());
    }
    if(ConfigurationHandler.getInstance().tooltipOnBoats && event.getItemStack().getItem() instanceof ItemBoat) {
        this.addBoatTooltip(event.getToolTip());
    }
}
 
開發者ID:InfinityRaider,項目名稱:Boatifull,代碼行數:17,代碼來源:TooltipHandler.java

示例5: onTooltipEvent

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    if (stack.getItem() == Items.extractor) {
        event.getToolTip().subList(1, event.getToolTip().size()).clear();
        int malgra = 0;
        int maxMalgra = 0;
        if (stack.hasTagCompound()) {
            malgra = stack.getTagCompound().getInteger("malgra");
            ExtractorContainer container = (ExtractorContainer) (ForgeRegistries.ITEMS.getValue(new ResourceLocation(stack.getTagCompound().getString("container"))));
            maxMalgra = container.getStorage();
        } else {
            stack.setTagCompound(new NBTTagCompound());
            stack.getTagCompound().setInteger("malgra", malgra);
            stack.getTagCompound().setString("container", Items.tinyContainer.getUnlocalizedName().substring(5));
        }
        event.getToolTip().add(Utils.translateToLocal("item.manaExtractor.malgraStored") + ": " + malgra + "/" + maxMalgra);
        if (stack.hasTagCompound()) {
            ExtractorTip tip = (ExtractorTip) (ForgeRegistries.ITEMS.getValue(new ResourceLocation(stack.getTagCompound().getString("tip"))));
            if (tip != null)
                event.getToolTip().add((tip.getMaterial().getDamageVsEntity() + 4) + " " + Utils.translateToLocal("attribute.name.generic.attackDamage"));
        }
    }
}
 
開發者ID:Ohrm,項目名稱:Malgra,代碼行數:25,代碼來源:Extractor.java

示例6: addTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@SubscribeEvent
public void addTooltip(ItemTooltipEvent e) {
	if (!e.getItemStack().isEmpty()) {
		Minecraft mc = Minecraft.getMinecraft();
		if (mc.currentScreen instanceof GuiContainer) {
			GuiContainer c = (GuiContainer) mc.currentScreen;
			if (c.inventorySlots != null) {
				for (int i = 0;i < c.inventorySlots.inventorySlots.size();i++) {
					Slot s = c.inventorySlots.inventorySlots.get(i);
					if (s instanceof ITooltipSlot && e.getItemStack() == s.getStack() && ((ITooltipSlot) s).showTooltip()) {
						ITooltipSlot t = (ITooltipSlot) s;
						t.getTooltip(e.getToolTip());
					}
				}
			}
		}
		if (tooltipOverrideFast.containsKey(e.getItemStack().getItem())) {
			Entry<String, String> entry = tooltipOverrideFast.get(e.getItemStack().getItem());
			e.getToolTip().addAll((Collection<? extends String>) Arrays.asList((I18n.format(entry.getValue())).split("/n")).stream().map(s -> entry.getKey() + s).collect(Collectors.<String>toList()));
		}
	}
}
 
開發者ID:tom5454,項目名稱:Toms-Mod,代碼行數:24,代碼來源:EventHandlerClient.java

示例7: onItemTooltipEvent

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onItemTooltipEvent(ItemTooltipEvent event) {
  if (Keyboard.isCreated()
      && (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) {
    // https://www.reddit.com/r/minecraftsuggestions/comments/3brh7v/when_hovering_over_a_food_it_shows_how_many_food/
    ItemStack itemStack = event.getItemStack();
    if (itemStack == null || itemStack.getItem() == null) {
      return;
    }
    if (foodDetails && itemStack.getItem() instanceof ItemFood) {
      ItemFood food = (ItemFood) itemStack.getItem();
      int hunger = food.getHealAmount(itemStack);
      float satur = food.getSaturationModifier(itemStack);
      if (hunger > 0 || satur > 0) {
        event.getToolTip().add(hunger + " (" + satur + ")");
      }
    }
    if (fuelDetails) {
      int burnTime = TileEntityFurnace.getItemBurnTime(itemStack);
      if (burnTime > 0) {
        event.getToolTip().add(UtilChat.lang("tooltip.burntime") + burnTime);
      }
    }
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:27,代碼來源:TextInfoModule.java

示例8: 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

示例9: addSeedStatsTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
/**
 * Adds tooltips for SEED stats.
 *
 * @param event
 */
@SubscribeEvent
public void addSeedStatsTooltip(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    // Add Seed Information.
    if (stack != null) {
        AgriSeed seed = AgriApi.getSeedRegistry().valueOf(stack).orElse(null);
        if (seed != null) {
            if (seed.getStat().isAnalyzed()) {
                seed.getStat().addStats(event.getToolTip()::add);
            } else {
                event.getToolTip().add(" " + AgriCore.getTranslator().translate("agricraft_tooltip.unidentified"));
            }
        }
    }
}
 
開發者ID:AgriCraft,項目名稱:AgriCraft,代碼行數:21,代碼來源:ItemToolTipHandler.java

示例10: onItemHover

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
/**
 * Method used to add relavent information to user tooltips.
 * 
 * @param event = event passed.
 */
// @SideOnly(Side.CLIENT)
@SubscribeEvent
public void onItemHover(ItemTooltipEvent event) {
	ItemStack stack = event.getItemStack();
	if (stack != null) {
		insertTileEntityInfo(event, stack);
		
		Block b = Block.getBlockFromItem(stack.getItem());
		
		if (b instanceof BlockAtomicBomb) {
			event.getToolTip().add(TextFormatting.GOLD + "WARNING: " + TextFormatting.WHITE + "Highly Destructive!");
			event.getToolTip().add(TextFormatting.GREEN + "Unbreakable");
		}
	}
}
 
開發者ID:hockeyhurd,項目名稱:Project-Zed,代碼行數:21,代碼來源:ItemHoverEventHandler.java

示例11: 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

示例12: onLanolinTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onLanolinTooltip(ItemTooltipEvent event){
    ItemStack stack = event.getItemStack();
    if (!stack.isEmpty() && ItemLanolin.canCraftWith(stack) && stack.hasTagCompound()
            && stack.getTagCompound().hasKey("lanolin")) {
        String levelKey = "tooltip.lanolin.level." + stack.getTagCompound().getByte("lanolin");
        event.getToolTip().add(TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC +
                I18n.format("tooltip.lanolin.lanolin") + " " +
                I18n.format(levelKey));
    }
}
 
開發者ID:SirLyle,項目名稱:Lanolin,代碼行數:13,代碼來源:EventHandlerClient.java

示例13: showTooltip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void showTooltip(ItemTooltipEvent event) {
	
	if (event.getItemStack().getItem() != Item.getItemFromBlock(Blocks.MOB_SPAWNER)) return;
	
	ItemStack tooltipper = event.getItemStack();
	if (!tooltipper.hasTagCompound() || (tooltipper.hasTagCompound() && !tooltipper.getTagCompound().hasKey("Spawner"))) return;
	
	NBTTagCompound tag = tooltipper.getTagCompound().getCompoundTag("Spawner");
	event.getToolTip().add("Mob spawner data:");
	event.getToolTip().add(TextFormatting.GOLD + tag.getCompoundTag("SpawnData").getString("id"));
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:13,代碼來源:UCEventHandlerServer.java

示例14: onToolTip

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
@SideOnly(Side.CLIENT)
public void onToolTip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();

    if(stack.getItem() == Items.ENCHANTED_BOOK && InteractionBWM.HIDDEN_ENCHANTS)
    {
        event.getToolTip().clear();
        event.getToolTip().add(TextFormatting.WHITE+I18n.format("item.ancient_manuscript.name"));
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:13,代碼來源:AssortedHandler.java

示例15: onFoodHover

import net.minecraftforge.event.entity.player.ItemTooltipEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onFoodHover(ItemTooltipEvent e)
{
    if (e.getItemStack() != null && e.getItemStack().getItem() instanceof ItemFood) {
        ItemFood food = (ItemFood) e.getItemStack().getItem();
        double healAmount = food.getHealAmount(e.getItemStack());
        double saturationModifier = food.getSaturationModifier(e.getItemStack());
        df.setRoundingMode(RoundingMode.FLOOR);

        if (GuiScreen.isShiftKeyDown())
            e.getToolTip().add("H: " + healAmount + " | S: " + df.format(saturationModifier));
        else
            e.getToolTip().add(I18n.translateToLocalFormatted("tooltip.littlethings.foodrating", String.valueOf(new Double(healAmount * saturationModifier).intValue())));
    }
}
 
開發者ID:GamingsModding,項目名稱:LittleThings-old,代碼行數:16,代碼來源:FoodEvents.java


注:本文中的net.minecraftforge.event.entity.player.ItemTooltipEvent.getItemStack方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。