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;
}
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;
}
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;
}
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)));
}
}
Aggregations