Search in sources :

Example 1 with ItemTooltipEvent

use of net.minecraftforge.event.entity.player.ItemTooltipEvent in project MinecraftForge by MinecraftForge.

the class ForgeEventFactory method onItemTooltip.

public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, EntityPlayer entityPlayer, List<String> toolTip, boolean showAdvancedItemTooltips) {
    ItemTooltipEvent event = new ItemTooltipEvent(itemStack, entityPlayer, toolTip, showAdvancedItemTooltips);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
Also used : ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent)

Example 2 with ItemTooltipEvent

use of net.minecraftforge.event.entity.player.ItemTooltipEvent in project Tropicraft by Tropicraft.

the class GuiTropicalBook method checkMouseHover.

/**
 * Draw the name of an item when it's hovered over in game
 * @param itemstack ItemStack being hovered over
 * @param x x coord
 * @param y y coord
 * @param size size...of something idk what :D
 */
private void checkMouseHover(ItemStack itemstack, int x, int y, int mx, int my, int size) {
    boolean checkHover = (mx >= x && my >= y && mx < x + size && my < y + size);
    float z = this.zLevel;
    this.zLevel = 500;
    if (!itemstack.isEmpty() && checkHover) {
        ITooltipFlag flag = mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
        ItemTooltipEvent evt = new ItemTooltipEvent(itemstack, mc.player, itemstack.getTooltip(mc.player, flag), flag);
        if (!MinecraftForge.EVENT_BUS.post(evt)) {
            ttLines = evt.getToolTip();
        } else {
            ttLines = null;
        }
    }
    this.zLevel = z;
}
Also used : ITooltipFlag(net.minecraft.client.util.ITooltipFlag) ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent)

Example 3 with ItemTooltipEvent

use of net.minecraftforge.event.entity.player.ItemTooltipEvent in project MinecraftForge by MinecraftForge.

the class ForgeEventFactory method onItemTooltip.

public static ItemTooltipEvent onItemTooltip(ItemStack itemStack, @Nullable Player entityPlayer, List<Component> list, TooltipFlag flags) {
    ItemTooltipEvent event = new ItemTooltipEvent(itemStack, entityPlayer, list, flags);
    MinecraftForge.EVENT_BUS.post(event);
    return event;
}
Also used : ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent)

Example 4 with ItemTooltipEvent

use of net.minecraftforge.event.entity.player.ItemTooltipEvent in project AgriCraft by AgriCraft.

the class ItemToolTipHandler method addTrowelTooltip.

/**
 * Adds tooltips to items that are trowels (implementing ITrowel).
 */
@SubscribeEvent
@SuppressWarnings("unused")
public void addTrowelTooltip(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    if (!stack.isEmpty() && stack.getItem() instanceof IAgriTrowelItem) {
        event.getToolTip().add(AgriToolTips.TROWEL);
        IAgriTrowelItem trowel = (IAgriTrowelItem) stack.getItem();
        trowel.getGenome(stack).map(genome -> {
            event.getToolTip().add(AgriToolTips.getPlantTooltip(genome.getPlant()));
            trowel.getGrowthStage(stack).ifPresent(stage -> event.getToolTip().add(AgriToolTips.getGrowthTooltip(stage)));
            return genome.getStats();
        }).ifPresent(stats -> stats.addTooltips(text -> event.getToolTip().add(text)));
    }
}
Also used : OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) Item(net.minecraft.item.Item) CompoundNBT(net.minecraft.nbt.CompoundNBT) IAgriClipperItem(com.infinityraider.agricraft.api.v1.content.items.IAgriClipperItem) MessageFormat(java.text.MessageFormat) ModuleKeyboard(com.infinityraider.infinitylib.modules.keyboard.ModuleKeyboard) ITextComponent(net.minecraft.util.text.ITextComponent) Dist(net.minecraftforge.api.distmarker.Dist) ItemStack(net.minecraft.item.ItemStack) AgriToolTips(com.infinityraider.agricraft.reference.AgriToolTips) Minecraft(net.minecraft.client.Minecraft) BlockTags(net.minecraft.tags.BlockTags) IAgriJournalItem(com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem) IAgriTrowelItem(com.infinityraider.agricraft.api.v1.content.items.IAgriTrowelItem) StringTextComponent(net.minecraft.util.text.StringTextComponent) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) CapabilityGeneInspector(com.infinityraider.agricraft.capability.CapabilityGeneInspector) AgriCraft(com.infinityraider.agricraft.AgriCraft) AgriApi(com.infinityraider.agricraft.api.v1.AgriApi) ItemTags(net.minecraft.tags.ItemTags) Collection(java.util.Collection) TextFormatting(net.minecraft.util.text.TextFormatting) BlockItem(net.minecraft.item.BlockItem) IAgriRakeItem(com.infinityraider.agricraft.api.v1.content.items.IAgriRakeItem) ItemTooltipEvent(net.minecraftforge.event.entity.player.ItemTooltipEvent) ResourceLocation(net.minecraft.util.ResourceLocation) ItemSeedBag(com.infinityraider.agricraft.content.tools.ItemSeedBag) ItemStack(net.minecraft.item.ItemStack) IAgriTrowelItem(com.infinityraider.agricraft.api.v1.content.items.IAgriTrowelItem) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

ItemTooltipEvent (net.minecraftforge.event.entity.player.ItemTooltipEvent)4 AgriCraft (com.infinityraider.agricraft.AgriCraft)1 AgriApi (com.infinityraider.agricraft.api.v1.AgriApi)1 IAgriClipperItem (com.infinityraider.agricraft.api.v1.content.items.IAgriClipperItem)1 IAgriJournalItem (com.infinityraider.agricraft.api.v1.content.items.IAgriJournalItem)1 IAgriRakeItem (com.infinityraider.agricraft.api.v1.content.items.IAgriRakeItem)1 IAgriTrowelItem (com.infinityraider.agricraft.api.v1.content.items.IAgriTrowelItem)1 CapabilityGeneInspector (com.infinityraider.agricraft.capability.CapabilityGeneInspector)1 ItemSeedBag (com.infinityraider.agricraft.content.tools.ItemSeedBag)1 AgriToolTips (com.infinityraider.agricraft.reference.AgriToolTips)1 ModuleKeyboard (com.infinityraider.infinitylib.modules.keyboard.ModuleKeyboard)1 MessageFormat (java.text.MessageFormat)1 Collection (java.util.Collection)1 Minecraft (net.minecraft.client.Minecraft)1 ITooltipFlag (net.minecraft.client.util.ITooltipFlag)1 BlockItem (net.minecraft.item.BlockItem)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1 BlockTags (net.minecraft.tags.BlockTags)1