Java 类net.minecraftforge.event.entity.player.ItemTooltipEvent 实例源码

项目:Loot-Slash-Conquer    文件:EventItemTooltip.java   
@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);
            }
        }
    }
}
项目:pnc-repressurized    文件:ClientEventHandler.java   
private void handleFluidContainerTooltip(ItemTooltipEvent event) {
    FluidStack fluidStack = FluidUtil.getFluidContained(event.getItemStack());
    if (fluidStack != null && fluidStack.amount > 0) {
        String key = "gui.tooltip.item." + fluidStack.getFluid().getName() + "_bucket";
        if (I18n.hasKey(key)) {
            if (event.getToolTip().get(event.getToolTip().size() - 1).contains("Minecraft Forge")) {
                // bit of a kludge!  otherwise the blue "Minecraft Forge" string gets shown twice
                event.getToolTip().remove(event.getToolTip().size() - 1);
            }
            String prefix = "";
            if (!FluidRegistry.getDefaultFluidName(fluidStack.getFluid()).startsWith(Names.MOD_ID)) {
                // fluid is owned by another mod; let's make it clear that this tooltip applies to PneumaticCraft
                prefix = TextFormatting.DARK_AQUA + "" + TextFormatting.ITALIC + "[" + Names.MOD_NAME + "] ";
            }
            if (PneumaticCraftRepressurized.proxy.isSneakingInGui()) {
                String translatedInfo = TextFormatting.AQUA + I18n.format(key);
                event.getToolTip().addAll(PneumaticCraftUtils.convertStringIntoList(prefix + translatedInfo, 40));
            } else {
                event.getToolTip().add(TextFormatting.AQUA + I18n.format("gui.tooltip.sneakForInfo"));
            }
        }
    }
}
项目:Jewelcrafting    文件:TooltipHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void handleTooltipEvent(ItemTooltipEvent event)
{
    NBTTagCompound baseTag = event.getItemStack().getTagCompound();
    if (baseTag != null &&  baseTag.hasKey("sockets"))
    {
        NBTTagCompound tag = (NBTTagCompound) event.getItemStack().getTagCompound().getTag("sockets");

        for (int i = 0 ; i < tag.getInteger("number") ; i++)
        {
            if (tag.getString("socket-"+i)=="none")
            {
                event.getToolTip().add("Socket "+(i+1)+": Empty");
            }
            if (tag.getString("socket-"+i)=="diamond")
            {
                event.getToolTip().add("Socket "+(i+1)+": diamond");
            }
        }
    }
}
项目:CompositeGear    文件:ClientEventHandler.java   
@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);
            }
        }
    }
}
项目:Mods    文件:TF2EventsClient.java   
@SubscribeEvent
public void addTooltip(ItemTooltipEvent event) {

    if (event.getItemStack().hasTagCompound() && event.getItemStack().getTagCompound().getBoolean("Australium") && !(event.getItemStack().getItem() instanceof ItemFromData)
            && !event.getItemStack().hasDisplayName()) {
        event.getToolTip().set(0, "Australium " + event.getToolTip().get(0));
    }
    if (event.getItemStack().hasTagCompound() && event.getItemStack().getTagCompound().getBoolean("Strange")) {
        if (!(event.getItemStack().getItem() instanceof ItemFromData) && !event.getItemStack().hasDisplayName()) {
            event.getToolTip().set(0, TF2EventsCommon.STRANGE_TITLES[event.getItemStack().getTagCompound().getInteger("StrangeLevel")] + " " + event.getToolTip().get(0));
        }

        event.getToolTip().add("");
        if (event.getItemStack().getItem() instanceof ItemMedigun) {
            event.getToolTip().add("Ubercharges: " + event.getItemStack().getTagCompound().getInteger("Ubercharges"));
        } else if (event.getItemStack().getItem() instanceof ItemCloak) {
            event.getToolTip().add("Seconds cloaked: " + event.getItemStack().getTagCompound().getInteger("CloakTicks") / 20);
        } else {
            event.getToolTip().add("Mob kills: " + event.getItemStack().getTagCompound().getInteger("Kills"));
            event.getToolTip().add("Player kills: " + event.getItemStack().getTagCompound().getShort("PlayerKills"));
        }
    }

}
项目:AdvancedCombat    文件:InformationHandler.java   
/** 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);
        }
    }
}
项目:BetterWithAddons    文件:RenewablesHandler.java   
@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));
    }
}
项目:BetterWithAddons    文件:RotHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
@SideOnly(Side.CLIENT)
public void onToolTip(ItemTooltipEvent event)
{
    ItemStack stack = event.getItemStack();

    if(isRottingItem(stack))
    {
        long timeOfCreation = getCreationDate(stack);
        if(timeOfCreation == -1)
            return;

        for(RotInfo info : rottingItems.get(stack.getItem())) {
            if(info.matches(stack)) {
                String prefix =  I18n.format(info.getUnlocalizedName(stack, timeOfCreation));
                if(prefix.length() > 0)
                    prefix = prefix + " ";

                event.getToolTip().set(0,prefix + event.getToolTip().get(0));
                break;
            }
        }
    }
}
项目:Malgra    文件:Extractor.java   
@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"));
        }
    }
}
项目:Toms-Mod    文件:EventHandlerClient.java   
@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()));
        }
    }
}
项目:geomastery    文件:ClientEvents.java   
/** Adds block weight to non BlockBuildingAbstract tooltips if config. */
@SubscribeEvent
public void addTooltips(ItemTooltipEvent event) {

    if (GeoConfig.textVisual.buildTooltips) {

        Item item = event.getItemStack().getItem();
        Block block = Block.getBlockFromItem(item);

        if (item instanceof ItemBlock) {

            event.getToolTip().add(I18n.format(EBlockWeight
                    .getWeight(block.getDefaultState()).supports()));
        }
    }
}
项目:Boatifull    文件:TooltipHandler.java   
@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());
    }
}
项目:NotEnoughItems    文件:NEIClientEventHandler.java   
@SubscribeEvent
public void itemTooltipEvent(ItemTooltipEvent event) {

    if (instanceTooltipHandlers != null && Minecraft.getMinecraft().currentScreen != null) {
        GuiScreen screen = Minecraft.getMinecraft().currentScreen;

        Point mousePos = GuiDraw.getMousePosition();

        instanceTooltipHandlers.forEach(handler -> handler.handleTooltip(screen, mousePos.x, mousePos.y, event.getToolTip()));

        if (screen instanceof GuiContainer) {
            GuiContainer container = ((GuiContainer) screen);
            instanceTooltipHandlers.forEach(handler -> handler.handleItemDisplayName(screen, GuiHelper.getStackMouseOver(container, true), event.getToolTip()));
        }
    }
}
项目:NewHorizonsCoreMod    文件:CustomToolTipsHandler.java   
@SubscribeEvent
public void onToolTip( ItemTooltipEvent pEvent )
{
  if( pEvent.entity == null ) {
    return;
  }
  CustomToolTips.ItemToolTip itt = _mCustomToolTips.FindItemToolTip( pEvent.itemStack );
  if( itt != null )
  {
      String[] tToolTips = itt.getToolTip().split("\\\\n");

    for( String tPartTip : tToolTips ) {
      pEvent.toolTip.add(tPartTip.replace("&", "§"));
    }
  }
}
项目:Adventure-Backport    文件:TooltipHandler.java   
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
    NBTTagCompound tag = event.itemStack.getTagCompound();
    if(tag != null) {
        if(tag.hasKey("CanDestroy", Constants.NBT.TAG_LIST)) {
            event.toolTip.add("");
            event.toolTip.add("Can break:");
            addBlockList(tag.getTagList("CanDestroy", Constants.NBT.TAG_STRING), event.toolTip);
        }
        if(tag.hasKey("CanPlaceOn", Constants.NBT.TAG_LIST)) {
            event.toolTip.add("");
            event.toolTip.add("Can be placed on:");
            addBlockList(tag.getTagList("CanPlaceOn", Constants.NBT.TAG_STRING), event.toolTip);
        }
    }
}
项目:EnderCore    文件:EnchantTooltipHandler.java   
@SuppressWarnings("unchecked")
@SubscribeEvent
public void handleTooltip(ItemTooltipEvent event) {
  if (event.itemStack.hasTagCompound()) {
    Map<Integer, Integer> enchantments = EnchantmentHelper.getEnchantments(event.itemStack);

    for (Integer integer : enchantments.keySet()) {
      Enchantment enchant = Enchantment.enchantmentsList[integer];

      if (enchant instanceof IAdvancedEnchant) {
        for (int i = 0; i < event.toolTip.size(); i++) {
          if (event.toolTip.get(i).contains(StatCollector.translateToLocal(enchant.getName()))) {
            for (String s : ((IAdvancedEnchant) enchant).getTooltipDetails(event.itemStack)) {
              event.toolTip.add(i + 1, EnumChatFormatting.DARK_GRAY.toString() + EnumChatFormatting.ITALIC + "  - " + s);
              i++;
            }
          }
        }
      }
    }
  }
}
项目:EnderCore    文件:OreDictTooltipHandler.java   
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
  boolean shiftDown = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT);
  boolean debugMode = Minecraft.getMinecraft().gameSettings.advancedItemTooltips;
  boolean doRegistry = showRegistryNameTooltips == 3 ? debugMode : showRegistryNameTooltips == 2 ? shiftDown : showRegistryNameTooltips == 1;
  boolean doOredict = showOredictTooltips == 3 ? debugMode : showOredictTooltips == 2 ? shiftDown : showOredictTooltips == 1;

  if (doRegistry) {
    event.toolTip.add(Item.itemRegistry.getNameForObject(event.itemStack.getItem()));
  }

  if (doOredict) {
    int[] ids = OreDictionary.getOreIDs(event.itemStack);

    if (ids.length > 0) {
      event.toolTip.add(EnderCore.lang.localize("tooltip.oreDictNames"));
      for (int i : ids) {
        event.toolTip.add("  - " + OreDictionary.getOreName(i));
      }
    }
  }
}
项目:Cyclic    文件:TextInfoModule.java   
@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);
      }
    }
  }
}
项目:Skills    文件:EventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onItemTooltip(ItemTooltipEvent event)
{
    SkillTrackerData tracker = SkillTrackerData.get(event.entityPlayer);
    RecipeWrapper recipe = RecipeHelper.getWrappedRecipefromItemStack(event.itemStack);

    if(tracker != null && recipe != null)
    {
        if(tracker.GetSkillByID(recipe.getSkill()).getSkillLevel() >= recipe.getDifficulty())
        {
            event.toolTip.add(new ChatComponentTranslation(EnumChatFormatting.YELLOW+"You can build this!").getUnformattedText());
        }else {
            event.toolTip.add(new ChatComponentTranslation(EnumChatFormatting.RED+"Need: "+ tracker.GetSkillByID(recipe.getSkill()).getLocName() +" skill of "+ recipe.getDifficulty()).getUnformattedText());

        }
    }
}
项目:Fidelis    文件:Fidelis.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void info(ItemTooltipEvent event){
    if(event.itemStack.hasTagCompound()){
        if(event.itemStack.getTagCompound().hasKey("Fidelis"))
        {
            String fidelisID = getFidelisID(event.itemStack);
            if(getID(event.entityPlayer).equals(fidelisID))
                event.toolTip.add(EnumChatFormatting.DARK_GRAY + "Loyal to you");
            else if(!fidelisID.equals(""))
                event.toolTip.add(EnumChatFormatting.DARK_GRAY + "Loyal to someone else (" + event.itemStack.getTagCompound().getString("FidelisDisplay") + ")");
            else
                event.toolTip.add(EnumChatFormatting.DARK_GRAY + "Waiting to bind to a loyal soul");

            if(event.itemStack.getItem().hasCustomEntity(event.itemStack) && HIJACK_ITEMS){
                event.toolTip.add(EnumChatFormatting.RED + "WARNING: Item may not return if 'killed' (Dropped in Lava, onto cactus)");
                event.toolTip.add(EnumChatFormatting.RED + "The item will still return if you die with it, however");
            }
        }
    }
}
项目:Gadomancy    文件:EventHandlerGolem.java   
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(ItemTooltipEvent event) {
    if(event.itemStack != null) {
        if(event.itemStack.getItem() instanceof ItemGolemPlacer
                || event.itemStack.getItem() instanceof ItemAdditionalGolemPlacer) {
            if(RegisteredGolemStuff.upgradeRunicShield.hasUpgrade(event.itemStack)) {
                event.toolTip.add("\u00a76" + StatCollector.translateToLocal("item.runic.charge") + " +" + RegisteredGolemStuff.upgradeRunicShield.getChargeLimit(event.itemStack));
            }

            AdditionalGolemCore core = GadomancyApi.getAdditionalGolemCore(event.itemStack);
            if(core != null) {
                String searchStr = StatCollector.translateToLocal("item.ItemGolemCore.name");
                for(int i = 0; i < event.toolTip.size(); i++) {
                    String line = event.toolTip.get(i);
                    if(line.contains(searchStr)) {
                        int index = line.indexOf('\u00a7', searchStr.length()) + 2;
                        event.toolTip.remove(i);
                        event.toolTip.add(i, line.substring(0, index) + StatCollector.translateToLocal(core.getUnlocalizedName()));
                        break;
                    }
                }
            }
        }
    }
}
项目:Gadomancy    文件:EventHandlerWorld.java   
@SubscribeEvent(priority = EventPriority.NORMAL)
public void on(ItemTooltipEvent e) {
    if (e.toolTip.size() > 0 && e.itemStack.hasTagCompound()) {
        if (e.itemStack.stackTagCompound.getBoolean("isStickyJar")) {
            e.toolTip.add(1, "\u00a7a" + StatCollector.translateToLocal("gadomancy.lore.stickyjar"));
        }
    }

    if(e.toolTip.size() > 0 && NBTHelper.hasPersistentData(e.itemStack)) {
        NBTTagCompound compound = NBTHelper.getPersistentData(e.itemStack);
        if(compound.hasKey("disguise")) {
            NBTBase base = compound.getTag("disguise");
            String lore;
            if(base instanceof NBTTagCompound) {
                ItemStack stack = ItemStack.loadItemStackFromNBT((NBTTagCompound) base);
                lore = String.format(StatCollector.translateToLocal("gadomancy.lore.disguise.item"), EnumChatFormatting.getTextWithoutFormattingCodes(stack.getDisplayName()));
            } else {
                lore = StatCollector.translateToLocal("gadomancy.lore.disguise.none");
            }
            e.toolTip.add("\u00a7a" + lore);
        }
    }
}
项目:Levels    文件:EventTooltip.java   
@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);
            }
        }
    }
}
项目:Bagginses    文件:TooltipEventHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void tooltip(ItemTooltipEvent e) {
    if (Minecraft.getMinecraft().currentScreen instanceof BagGui) {
        try {
            Bag bag = (Bag) getStack(e.getEntityPlayer()).getItem();
            String color = bag.getColor();

            if (bag.getType() == BagTypes.TIER1
                    || bag.getType() == BagTypes.TIER2) {
                if (!isItemAllowed(e.getItemStack(), color)) {
                    e.getToolTip().add(ChatFormatting.RED + "This item is not allowed in this bag");
                }
            }
        } catch (Exception ex) {
            return;
        }
    }
}
项目:Privatizer    文件:PrivatizerEventHandler.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event)
{
    if(event.itemStack.hasTagCompound())
    {
        NBTTagList list = event.itemStack.getTagCompound().getTagList("privatizer", Constants.NBT.TAG_STRING);
        if(!list.getStringTagAt(1).isEmpty() && !GameSettings.isKeyDown(FMLClientHandler.instance().getClient().gameSettings.keyBindSneak))
        {
            event.toolTip.add(StatCollector.translateToLocal("item.toolTip.hasPassword"));
            event.toolTip.add(StatCollector.translateToLocal("item.toolTip.sneak"));
        }
        else
        {
            if(list.getStringTagAt(0).equals(event.entityPlayer.getGameProfile().getId().toString()))
            {
                event.toolTip.add(StatCollector.translateToLocalFormatted("item.toolTip.password", list.getStringTagAt(1)));
            }
            else
            {
                event.toolTip.add(StatCollector.translateToLocal("item.toolTip.noOwner"));
            }
        }
    }
}
项目:AgriCraft    文件:ItemToolTipHandler.java   
/**
 * 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"));
            }
        }
    }
}
项目:enderutilities    文件:GuiMSU.java   
@SubscribeEvent
public static void onTooltipEvent(ItemTooltipEvent event)
{
    if (Minecraft.getMinecraft().currentScreen instanceof GuiMSU && event.getEntityPlayer() != null &&
        event.getEntityPlayer().openContainer instanceof ContainerMSU)
    {
        ContainerMSU container = (ContainerMSU) event.getEntityPlayer().openContainer;
        GuiMSU gui = (GuiMSU) Minecraft.getMinecraft().currentScreen;
        Slot slot = gui.getSlotUnderMouse();

        if (slot != null && slot.getHasStack() && container.getCustomInventorySlotRange().contains(slot.slotNumber))
        {
            String size = EUStringUtils.formatNumberWithKSeparators(slot.getStack().getCount());
            event.getToolTip().add(size + " " + I18n.format("enderutilities.tooltip.item.items"));
        }
    }
}
项目:enderutilities    文件:GuiBarrel.java   
@SubscribeEvent
public static void onTooltipEvent(ItemTooltipEvent event)
{
    if (Minecraft.getMinecraft().currentScreen instanceof GuiBarrel && event.getEntityPlayer() != null &&
        event.getEntityPlayer().openContainer instanceof ContainerBarrel)
    {
        ContainerBarrel container = (ContainerBarrel) event.getEntityPlayer().openContainer;
        GuiBarrel gui = (GuiBarrel) Minecraft.getMinecraft().currentScreen;
        Slot slot = gui.getSlotUnderMouse();

        if (slot != null && slot.getHasStack() && container.getCustomInventorySlotRange().contains(slot.slotNumber))
        {
            String size = EUStringUtils.formatNumberWithKSeparators(slot.getStack().getCount());
            event.getToolTip().add(size + " " + I18n.format("enderutilities.tooltip.item.items"));
        }
    }
}
项目:Farrago    文件:ClientProxy.java   
@Override
public void tooltip(ItemTooltipEvent e) {
    for (Entry<Selector, String> en : FarragoMod.disabled.entrySet()) {
        if (en.getKey().itemStackMatches(e.itemStack)) {
            String reason = en.getValue();
            e.toolTip.add("\u00A74This item has been disabled in the config file.");
            if (StringUtils.isNotBlank(reason)) {
                e.toolTip.add("The reason given is:");
                for (String s : (List<String>)Minecraft.getMinecraft().fontRenderer.listFormattedStringToWidth(reason, 250)) {
                    e.toolTip.add("\u00A77"+s);
                }
            } else {
                e.toolTip.add("A reason was not given.");
            }
            if (FarragoMod.brand != null) {
                e.toolTip.add("\u00A74Contact the creator of your modpack if you think this is a mistake.");
            }
            return;
        }
    }
    Encyclopedia.process(e.itemStack, e.entityPlayer, e.toolTip, e.showAdvancedItemTooltips);
}
项目:Farrago    文件:FarragoMod.java   
@SubscribeEvent
public void onTooltip(ItemTooltipEvent e) {
    if (e.showAdvancedItemTooltips) {
        float massF = Masses.getMass(e.itemStack);
        String massS = (massF <= 0 ? "\u00A7cERROR\u00A79" : ""+massF);
        float magic = Masses.getMagic(e.itemStack);
        if (magic > 0) {
            e.toolTip.add("\u00A79"+magic+" Kahur Magic");
        }
        e.toolTip.add("\u00A79"+massS+" Kahur Mass");
    }
    if (e.itemStack.getItem() == Item.getItemFromBlock(COMBUSTOR) || e.itemStack.getItem() == Item.getItemFromBlock(SCRAPPER)) {
        e.toolTip.add("\u00A74DEPRECATED. Place in a crafting window to update.");
        e.toolTip.add("\u00A7cIF THIS ITEM IS NOT UPDATED IT WILL BE LOST IN FARRAGO 1.1");
    }
    proxy.tooltip(e);
}
项目:RecipeTweakingCore    文件:TooltipHandler.java   
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event)
{
    String[] lines = TweakingRegistry.getTooltip(event.itemStack.getItem(), event.itemStack.getItemDamage());
    if (lines != null)
    {
        if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
        {
            event.toolTip.add(EnumChatFormatting.RED + "Tweaked Item:");
            for (int i = 0; i < lines.length; i++)
                event.toolTip.add((i == 0 ? EnumChatFormatting.AQUA : EnumChatFormatting.YELLOW)+ lines[i]);
        }
        else
            event.toolTip.add(EnumChatFormatting.YELLOW + "Tweaked Item! - " + EnumChatFormatting.RED + "Shift " + EnumChatFormatting.YELLOW + "for Info");
    }
}
项目:Project-Zed    文件:ItemHoverEventHandler.java   
/**
 * 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");
        }
    }
}
项目:ModTutoriel17    文件:PlayerEventHandler.java   
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onTooltip(ItemTooltipEvent event)
{
    if(event.itemStack.getItem() == Items.dye && event.itemStack.getItemDamage() == 15)
    {
        event.toolTip.add("clic droit sur les plantes pour les faire pousser");
    }
    else if(event.itemStack.getItem() == Item.getItemFromBlock(Blocks.obsidian))
    {
        if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
        {
            event.toolTip.add("Bloc très résistant aux exposions");
            event.toolTip.add("Résistance : 2000");
        }
        else
        {
            event.toolTip.add("Maintenir shift gauche pour plus d'information");
        }
    }
}
项目:Battlegear2    文件:BattlegearClientEvents.java   
/**
 * 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"));
    }
}
项目:BetterChests    文件:ClientEventListener.java   
@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());
            }
        }
    }
}
项目:OpenBlocks    文件:LoreFlimFlam.java   
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent evt) {
    if (Config.loreDisplay > 0) {
        final NBTTagCompound itemTag = evt.getItemStack().getTagCompound();
        if (itemTag != null) {
            if (itemTag.hasKey("display", Constants.NBT.TAG_COMPOUND)) {
                final NBTTagCompound displayTag = itemTag.getCompoundTag("display");
                if (displayTag.hasKey(TAG_NAME, Constants.NBT.TAG_LIST) &&
                        !displayTag.hasKey("Lore", Constants.NBT.TAG_LIST)) {
                    final NBTTagList sillyLore = displayTag.getTagList(TAG_NAME, Constants.NBT.TAG_STRING);

                    if ((Config.loreDisplay > 1) ||
                            Keyboard.isKeyDown(Keyboard.KEY_LMENU) ||
                            Keyboard.isKeyDown(Keyboard.KEY_RMENU)) {
                        for (int i = 0; i < sillyLore.tagCount(); i++)
                            evt.getToolTip().add(LORE_FORMAT + sillyLore.getStringTagAt(i));
                    } else {
                        evt.getToolTip().add(TranslationUtils.translateToLocal("openblocks.misc.hidden_lore"));
                    }
                }
            }
        }
    }
}
项目:Lanolin    文件:EventHandlerClient.java   
@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));
    }
}
项目:pnc-repressurized    文件:ClientEventHandler.java   
@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
    if (event.getItemStack().getItem() instanceof IProgrammable) {
        handleProgrammableTooltip(event);
    } else if (event.getItemStack().getItem() instanceof ItemBucket || event.getItemStack().getItem() instanceof UniversalBucket) {
        handleFluidContainerTooltip(event);
    }
}
项目:pnc-repressurized    文件:ClientEventHandler.java   
private void handleProgrammableTooltip(ItemTooltipEvent event) {
    IProgrammable programmable = (IProgrammable) event.getItemStack().getItem();
    if (programmable.canProgram(event.getItemStack()) && programmable.showProgramTooltip()) {
        boolean hasInvalidPrograms = false;
        List<String> addedEntries = new ArrayList<>();
        List<IProgWidget> widgets = TileEntityProgrammer.getProgWidgets(event.getItemStack());
        Map<String, Integer> widgetMap = getPuzzleSummary(widgets);
        for (Map.Entry<String, Integer> entry : widgetMap.entrySet()) {
            IProgWidget widget = ItemProgrammingPuzzle.getWidgetForName(entry.getKey());
            String prefix = "";
            GuiScreen curScreen = Minecraft.getMinecraft().currentScreen;
            if (curScreen instanceof IGuiDrone) {
                if (!((IGuiDrone) curScreen).getDrone().isProgramApplicable(widget)) {
                    prefix = TextFormatting.RED + "";
                    hasInvalidPrograms = true;
                }
            }
            addedEntries.add(prefix + "- " + entry.getValue() + "x " + I18n.format("programmingPuzzle." + entry.getKey() + ".name"));
        }
        if (hasInvalidPrograms) {
            event.getToolTip().add(TextFormatting.RED + I18n.format("gui.tooltip.programmable.invalidPieces"));
        }
        Collections.sort(addedEntries);
        event.getToolTip().addAll(addedEntries);
        if (PneumaticCraftRepressurized.proxy.isSneakingInGui() && !widgets.isEmpty()) {
            Map<Integer,Integer> widgetColorMap = TileEntityProgrammer.getPuzzleSummary(widgets);
            event.getToolTip().add(TextFormatting.WHITE + I18n.format("gui.tooltip.programmable.requiredPieces"));
            for (int color : widgetColorMap.keySet()) {
                ItemStack stack = ItemProgrammingPuzzle.getStackForColor(color);
                stack.setCount(widgetColorMap.get(color));
                event.getToolTip().add("- " + widgetColorMap.get(color) + " x " + stack.getDisplayName());
            }
        }
    }
}
项目:Industrial-Foregoing    文件:IFTooltipEvent.java   
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onTooltip(ItemTooltipEvent event) {
    if (Block.getBlockFromItem(event.getItemStack().getItem()) == Blocks.AIR) return;
    Block block = Block.getBlockFromItem(event.getItemStack().getItem());
    if (block instanceof IHasAdvancedTooltip && !((IHasAdvancedTooltip) block).getTooltip(event.getItemStack()).isEmpty()) {
        if (!GuiScreen.isShiftKeyDown()) {
            event.getToolTip().add(new TextComponentTranslation("text.industrialforegoing.tooltip.hold_shift").getFormattedText());
        } else {
            event.getToolTip().addAll(((IHasAdvancedTooltip) block).getTooltip(event.getItemStack()));
        }
    }
}