-
-
Save Harleyoc1/ef9d0b2b5ec37837d4bbbfb7bc428f26 to your computer and use it in GitHub Desktop.
Simple tooltip event for displaying Forge item tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.blah; | |
import net.minecraft.util.ResourceLocation; | |
import net.minecraft.util.text.ITextComponent; | |
import net.minecraft.util.text.StringTextComponent; | |
import net.minecraftforge.api.distmarker.Dist; | |
import net.minecraftforge.api.distmarker.OnlyIn; | |
import net.minecraftforge.event.entity.player.ItemTooltipEvent; | |
import net.minecraftforge.eventbus.api.SubscribeEvent; | |
import java.util.List; | |
/** | |
* Tool tip event for viewing forge tags set to items. | |
* | |
* @author Harley O'Connor | |
*/ | |
public final class TooltipEvent { | |
@SubscribeEvent | |
@OnlyIn(Dist.CLIENT) | |
public void onTooltip(final ItemTooltipEvent event) { | |
List<ITextComponent> toolTip = event.getToolTip(); | |
for (ResourceLocation tag : event.getItemStack().getItem().getTags()) | |
toolTip.add(new StringTextComponent("§8" + tag.toString())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment