net.minecraftforge.event.entity.player.ItemTooltipEvent Java Examples
The following examples show how to use
net.minecraftforge.event.entity.player.ItemTooltipEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommunityMod.java From CommunityMod with GNU Lesser General Public License v2.1 | 6 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void onItemTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); if (!stack.isEmpty() && CommunityGlobals.MOD_ID.equals(stack.getItem().getRegistryName().getNamespace())) { SubModContainer subMod = SubModLoader.getSubModOrigin(stack.getItem()); if (subMod != null) { event.getToolTip().add(TextFormatting.DARK_GRAY + "(" + subMod.getName() + " - " + subMod.getAttribution() + ")"); } } }
Example #2
Source File: ClientEventListener.java From BetterChests with GNU Lesser General Public License v3.0 | 6 votes |
@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()); } } } }
Example #3
Source File: GuiBarrel.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@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")); } } }
Example #4
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 6 votes |
/** * Adds tooltips for SEED stats. * * @param event */ @SubscribeEvent public void addSeedStatsTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); // Add Seed Information. if (!stack.isEmpty()) { 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")); } } } }
Example #5
Source File: EventTooltip.java From Levels with GNU General Public License v2.0 | 6 votes |
@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); } } } }
Example #6
Source File: EventHandlerWorld.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@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); } } }
Example #7
Source File: EventHandlerGolem.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
@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; } } } } } }
Example #8
Source File: CustomToolTipsHandler.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 6 votes |
@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("&", "§")); } } }
Example #9
Source File: ScrapingDisabledWarning.java From Survivalist with BSD 3-Clause "New" or "Revised" License | 6 votes |
@SubscribeEvent public static void addInformation(ItemTooltipEvent ev) { if (!ConfigManager.SERVER.enableScraping.get() && EnchantmentHelper.getEnchantmentLevel(SurvivalistMod.SCRAPING.get(), ev.getItemStack()) > 0) { List<ITextComponent> list = ev.getToolTip(); /*int lastScraping = -1; for (int i = 0; i < list.size(); i++) { if (list.get(i).getFormattedText().startsWith(I18n.format("enchantment.survivalist.scraping"))) { lastScraping = i; } } if (lastScraping >= 0) { list.add(lastScraping + 1, "" + TextFormatting.DARK_GRAY + TextFormatting.ITALIC + I18n.format("tooltip.survivalist.scraping.disabled")); }*/ list.add(new TranslationTextComponent("tooltip.survivalist.scraping.disabled").func_240701_a_(TextFormatting.DARK_GRAY, TextFormatting.ITALIC)); } }
Example #10
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 5 votes |
@SubscribeEvent public void addRegistryInfo(ItemTooltipEvent event) { if (AgriCraftConfig.enableRegistryTooltips) { final Item item = event.getItemStack().getItem(); addCategory(event, "Registry"); addParameter(event, "id", item.getRegistryName()); } }
Example #11
Source File: TerminalManagerClient.java From OpenPeripheral-Addons with MIT License | 5 votes |
@SubscribeEvent public void onItemTooltip(ItemTooltipEvent evt) { if (evt.itemStack != null && NbtGuidProviders.hasTerminalCapabilities(evt.itemStack)) { final Optional<Long> guid = NbtGuidProviders.getTerminalGuid(evt.itemStack); if (guid.isPresent()) { evt.toolTip.add(StatCollector.translateToLocalFormatted("openperipheral.terminal.key", TerminalUtils.formatTerminalId(guid.get()))); } else { evt.toolTip.add(StatCollector.translateToLocal("openperipheral.terminal.unbound")); } } }
Example #12
Source File: ClientEventHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void onItemTooltip(ItemTooltipEvent event){ if(event.itemStack.getItem() instanceof IProgrammable) { IProgrammable programmable = (IProgrammable)event.itemStack.getItem(); if(programmable.canProgram(event.itemStack) && programmable.showProgramTooltip()) { boolean hasInvalidPrograms = false; List<String> addedEntries = new ArrayList<String>(); Map<String, Integer> widgetMap = getPuzzleSummary(TileEntityProgrammer.getProgWidgets(event.itemStack)); 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 = EnumChatFormatting.RED + ""; hasInvalidPrograms = true; } } addedEntries.add(prefix + "-" + entry.getValue() + "x " + I18n.format("programmingPuzzle." + entry.getKey() + ".name")); } if(hasInvalidPrograms) { event.toolTip.add(EnumChatFormatting.RED + I18n.format("gui.tooltip.programmable.invalidPieces")); } Collections.sort(addedEntries); event.toolTip.addAll(addedEntries); } } }
Example #13
Source File: FMEventHandler.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
@SubscribeEvent public void onTooltip(ItemTooltipEvent event) { if (event.itemStack.getItem() instanceof ItemWandCasting) { if (((ItemWandCasting) event.itemStack.getItem()).getRod(event.itemStack).getTag().startsWith("blood") && !event.itemStack.stackTagCompound.getString("ownerName").equals("")) { event.toolTip.add(StatCollector.translateToLocal("tooltip.currentowner") + " " + event.itemStack.stackTagCompound.getString("ownerName")); } else if (((ItemWandCasting) event.itemStack.getItem()).getRod(event.itemStack).getTag().startsWith("neutronium")) { event.toolTip.add(StatCollector.translateToLocal("tooltip.creativeonly")); } else if (((ItemWandCasting) event.itemStack.getItem()).getRod(event.itemStack).getTag().startsWith("profane")) { event.toolTip.add("Contract: " + event.itemStack.getTagCompound().getInteger("contract")); } } }
Example #14
Source File: ElectricBoogaloo.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@SubscribeEvent public static void itemToolTipEvent(ItemTooltipEvent event) { if (twosList == null || twosList.length < 1 || event.getToolTip().isEmpty()) return; boolean isPotion = event.getItemStack().getItem() instanceof ItemPotion || event.getItemStack().getItem() instanceof ItemArrow; for (int i = 0; i < event.getToolTip().size(); i++) { String toolTip = event.getToolTip().get(i); String lowerTip = toolTip.toLowerCase(); boolean relocateReset = false; if (lowerTip.endsWith("§r")) { lowerTip = lowerTip.substring(0, lowerTip.length() - 2); toolTip = toolTip.substring(0, toolTip.length() - 2); relocateReset = true; } for (String to : twosList) { String boogaloo = null; if (isPotion && TIMER_PATTERN.matcher(lowerTip).find()) { String potionName = lowerTip.substring(0, lowerTip.indexOf('(') - 1); if (potionName.endsWith(to)) { int index = toolTip.indexOf('(') - 1; String beforeTimer = toolTip.substring(0, index); String timer = toolTip.substring(index); boogaloo = I18n.format("tooltip.community_mod.electric", beforeTimer) + timer; } } if (lowerTip.endsWith(to)) { boogaloo = I18n.format("tooltip.community_mod.electric", toolTip); if (relocateReset) boogaloo += "§r"; } if (!Strings.isNullOrEmpty(boogaloo)) event.getToolTip().set(i, boogaloo); } } }
Example #15
Source File: GuiMSU.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
@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")); } } }
Example #16
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 5 votes |
/** * Adds tooltips to items that are clippers (implementing IClipper). * * @param event */ @SubscribeEvent public void addClipperTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); if (StackHelper.isValid(stack, IAgriClipperItem.class)) { event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.clipper1")); event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.clipper2")); event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.clipper3")); } }
Example #17
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 5 votes |
/** * Adds tooltips to items that are trowels (implementing ITrowel). * * @param event */ @SubscribeEvent public void addTrowelTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); if (!stack.isEmpty() && stack.getItem() instanceof IAgriTrowelItem) { AgriSeed seed = AgriApi.getSeedRegistry().valueOf(event.getItemStack()).orElse(null); if (seed != null) { event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.seed") + ": " + seed.getPlant().getSeedName()); } else { event.getToolTip().add(AgriCore.getTranslator().translate("agricraft_tooltip.trowel")); } } }
Example #18
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 5 votes |
@SubscribeEvent public void addOreDictInfo(ItemTooltipEvent event) { if (AgriCraftConfig.enableOreDictTooltips && !event.getItemStack().isEmpty()) { addCategory(event, "OreDict"); final int[] ids = OreDictionary.getOreIDs(event.getItemStack()); for (int id : ids) { addFormatted(event, " - {1} ({0})", id, OreDictionary.getOreName(id)); } if (ids.length == 0) { addFormatted(event, " - No OreDict Entries"); } } }
Example #19
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 5 votes |
@SubscribeEvent public void addNbtInfo(ItemTooltipEvent event) { if (AgriCraftConfig.enableNBTTooltips) { addCategory(event, "NBT"); if (StackHelper.hasTag(event.getItemStack())) { final NBTTagCompound tag = StackHelper.getTag(event.getItemStack()); for (String key : tag.getKeySet()) { addParameter(event, key, tag.getTag(key)); } } else { addFormatted(event, " - No NBT Tags"); } } }
Example #20
Source File: ClientProxy.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent public static void addMaterialFormulaHandler(ItemTooltipEvent event) { ItemStack itemStack = event.getItemStack(); if (!(itemStack.getItem() instanceof ItemBlock)) { UnificationEntry unificationEntry = OreDictUnifier.getUnificationEntry(itemStack); if (unificationEntry != null && unificationEntry.material != null) { String formula = unificationEntry.material.chemicalFormula; if (formula != null && !formula.isEmpty() && !formula.equals("?")) { event.getToolTip().add(1, ChatFormatting.GRAY.toString() + unificationEntry.material.chemicalFormula); } } } }
Example #21
Source File: GTEventItemTooltip.java From GT-Classic with GNU Lesser General Public License v3.0 | 5 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public void onTooltipEvent(ItemTooltipEvent event) { if (GTConfig.general.removeIC2Plasmafier && GTHelperStack.isEqual(event.getItemStack(), GTMaterialGen.getIc2(Ic2Items.plasmaCell))) { String name = event.getItemStack().getDisplayName(); event.getToolTip().clear(); event.getToolTip().add(name); event.getToolTip().add(TOOLTIP); } }
Example #22
Source File: ToolTip.java From customstuff4 with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent void onToolTip(ItemTooltipEvent event) { if (isCorrectModeActive() && isCorrectItem(event.getItemStack())) { List<String> toolTip = event.getToolTip(); modifyToolTip(toolTip); } }
Example #23
Source File: NEIClientEventHandler.java From NotEnoughItems with MIT License | 5 votes |
@SubscribeEvent public void itemTooltipEvent(ItemTooltipEvent event) { if (instanceTooltipHandlers != null && Minecraft.getMinecraft().currentScreen != null) { GuiScreen screen = Minecraft.getMinecraft().currentScreen; instanceTooltipHandlers.forEach(handler -> handler.handleItemDisplayName(screen, event.getItemStack(), event.getToolTip())); } }
Example #24
Source File: EventHandler.java From TinkersToolLeveling with MIT License | 4 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent public void onTooltip(ItemTooltipEvent event) { Tooltips.addTooltips(event.getItemStack(), event.getToolTip()); }
Example #25
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 4 votes |
private static void addParameter(ItemTooltipEvent event, String key, Object value) { event.getToolTip().add(ChatFormatting.DARK_AQUA + " - " + key + ": " + Objects.toString(value)); }
Example #26
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 4 votes |
private static void addCategory(ItemTooltipEvent event, String category) { event.getToolTip().add(ChatFormatting.DARK_AQUA + category + ":"); }
Example #27
Source File: ItemToolTipHandler.java From AgriCraft with MIT License | 4 votes |
private static void addFormatted(ItemTooltipEvent event, String format, Object... objects) { event.getToolTip().add(ChatFormatting.DARK_AQUA + MessageFormat.format(format, objects)); }
Example #28
Source File: TooltipEventHandler.java From bartworks with MIT License | 4 votes |
@SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.HIGHEST) public void getTooltip(ItemTooltipEvent event) { if (event == null || event.itemStack == null || event.itemStack.getItem() == null) return; if (TooltipCache.getTooltip(event.itemStack).isEmpty()) { ItemStack tmp = event.itemStack.copy(); Pair<Integer,Short> abstractedStack = new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage()); List<String> tooAdd = new ArrayList<>(); if (OreDictHandler.getNonBWCache().contains(abstractedStack)) { for (Pair<Integer,Short> pair : OreDictHandler.getNonBWCache()) { if (pair.equals(abstractedStack)) { GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); if (UI == null) UI = GameRegistry.findUniqueIdentifierFor(Block.getBlockFromItem(tmp.getItem())); if (UI != null) { for (ModContainer modContainer : Loader.instance().getModList()) { if (UI.modId.equals(MainMod.MOD_ID) || UI.modId.equals(BartWorksCrossmod.MOD_ID) || UI.modId.equals("BWCore")) break; if (UI.modId.equals(modContainer.getModId())) { tooAdd.add("Shared ItemStack between " + ChatColorHelper.DARKGREEN + "BartWorks" + ChatColorHelper.GRAY + " and " + ChatColorHelper.RED + modContainer.getName()); } } } else tooAdd.add("Shared ItemStack between " + ChatColorHelper.DARKGREEN + "BartWorks" + ChatColorHelper.GRAY + " and another Mod, that doesn't use the ModContainer propperly!"); } } } Block BLOCK = Block.getBlockFromItem(event.itemStack.getItem()); if (BLOCK != null && BLOCK != Blocks.air) { if (BLOCK instanceof BW_Blocks) { TooltipCache.put(event.itemStack, tooAdd); return; } BioVatLogicAdder.BlockMetaPair PAIR = new BioVatLogicAdder.BlockMetaPair(BLOCK, (byte) event.itemStack.getItemDamage()); HashMap<BioVatLogicAdder.BlockMetaPair, Byte> GLASSMAP = BioVatLogicAdder.BioVatGlass.getGlassMap(); if (GLASSMAP.containsKey(PAIR)) { int tier = GLASSMAP.get(PAIR); tooAdd.add( StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(tier) + GT_Values.VN[tier] + ChatColorHelper.RESET); } else if (BLOCK.getMaterial().equals(Material.glass)) { tooAdd.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(3) + GT_Values.VN[3] + ChatColorHelper.RESET); } } TooltipCache.put(event.itemStack, tooAdd); event.toolTip.addAll(tooAdd); } else { event.toolTip.addAll(TooltipCache.getTooltip(event.itemStack)); } }
Example #29
Source File: GuiScreenHook.java From SkyblockAddons with MIT License | 4 votes |
public static void renderBackpack(ItemStack stack, int x, int y, ReturnValue<?> returnValue) { SkyblockAddons main = SkyblockAddons.getInstance(); if (stack.getItem().equals(Items.skull) && main.getConfigValues().isEnabled(Feature.SHOW_BACKPACK_PREVIEW)) { if (main.getConfigValues().isEnabled(Feature.SHOW_BACKPACK_HOLDING_SHIFT) && !GuiScreen.isShiftKeyDown()) { return; } Container playerContainer = Minecraft.getMinecraft().thePlayer.openContainer; if (playerContainer instanceof ContainerChest) { // Avoid showing backpack preview in auction stuff. IInventory chestInventory = ((ContainerChest) playerContainer).getLowerChestInventory(); if (chestInventory.hasCustomName()) { String chestName = chestInventory.getDisplayName().getUnformattedText(); if (chestName.contains("Auction") || "Your Bids".equals(chestName)) { // Show preview for backpacks in player inventory if enabled. if (!main.getConfigValues().isEnabled(Feature.BACKPACK_PREVIEW_AH)) { return; } /* If the backpack is in the auction house window, ignore it. Empty backpacks can't be listed in the auction. */ for (int i = 0; i < chestInventory.getSizeInventory(); i++) { if (ItemStack.areItemStackTagsEqual(chestInventory.getStackInSlot(i), stack)) { return; } } } } } Backpack backpack = BackpackManager.getFromItem(stack); if (backpack != null) { backpack.setX(x); backpack.setY(y); if (isFreezeKeyDown() && System.currentTimeMillis() - lastBackpackFreezeKey > 500) { lastBackpackFreezeKey = System.currentTimeMillis(); GuiContainerHook.setFreezeBackpack(!GuiContainerHook.isFreezeBackpack()); main.getUtils().setBackpackToPreview(backpack); } if (!GuiContainerHook.isFreezeBackpack()) { main.getUtils().setBackpackToPreview(backpack); } main.getPlayerListener().onItemTooltip(new ItemTooltipEvent(stack, null, null, false)); returnValue.cancel(); } } if (GuiContainerHook.isFreezeBackpack()) { returnValue.cancel(); } }
Example #30
Source File: MiscHandler.java From Cyberware with MIT License | 4 votes |
@SubscribeEvent(priority = EventPriority.LOWEST) @SideOnly(Side.CLIENT) public void handleCyberwareTooltip(ItemTooltipEvent event) { ItemStack stack = event.getItemStack(); if (CyberwareAPI.isCyberware(stack)) { ICyberware ware = CyberwareAPI.getCyberware(stack); Quality quality = ware.getQuality(stack); GameSettings settings = Minecraft.getMinecraft().gameSettings; if (settings.isKeyDown(settings.keyBindSneak)) { List<String> info = ware.getInfo(stack); if (info != null) { event.getToolTip().addAll(info); } ItemStack[][] reqs = ware.required(stack); if (reqs.length > 0) { String joined = ""; for (int i = 0; i < reqs.length; i++) { String toAdd = ""; for (int j = 0; j < reqs[i].length; j++) { if (j != 0) { toAdd += " " + I18n.format("cyberware.tooltip.joinerOr") + " "; } toAdd += I18n.format(reqs[i][j].getUnlocalizedName() + ".name"); } if (i != 0) { joined += I18n.format("cyberware.tooltip.joiner") + " "; } joined += toAdd; } event.getToolTip().add(ChatFormatting.AQUA + I18n.format("cyberware.tooltip.requires") + " " + joined); } event.getToolTip().add(ChatFormatting.RED + I18n.format("cyberware.slot." + ware.getSlot(stack).getName())); if (quality != null) { event.getToolTip().add(I18n.format(quality.getUnlocalizedName())); } } else { event.getToolTip().add(ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.shiftPrompt", Minecraft.getMinecraft().gameSettings.keyBindSneak.getDisplayName())); } } else if (stack.getItem() instanceof IDeconstructable) { if (event.getToolTip().size() > 1) { event.getToolTip().add(1, ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.canDeconstruct")); } else { event.getToolTip().add(ChatFormatting.DARK_GRAY + I18n.format("cyberware.tooltip.canDeconstruct")); } } }