Search in sources :

Example 1 with IAgriTrowelItem

use of com.infinityraider.agricraft.api.v1.content.items.IAgriTrowelItem 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

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 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 ItemTags (net.minecraft.tags.ItemTags)1 ResourceLocation (net.minecraft.util.ResourceLocation)1