From 71883d93e97ab72c1f41b6bfbcbdf7fcf6ed2617 Mon Sep 17 00:00:00 2001 From: Jenny Date: Wed, 12 Feb 2025 16:35:51 +0100 Subject: [PATCH] implement tooltip --- .../advancedarrows/items/ArrowAbstract.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/jenny/advancedarrows/items/ArrowAbstract.java b/src/main/java/com/jenny/advancedarrows/items/ArrowAbstract.java index 76899f6..cbd8239 100644 --- a/src/main/java/com/jenny/advancedarrows/items/ArrowAbstract.java +++ b/src/main/java/com/jenny/advancedarrows/items/ArrowAbstract.java @@ -1,26 +1,34 @@ package com.jenny.advancedarrows.items; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.projectile.AbstractArrow; import net.minecraft.world.item.ArrowItem; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; +import java.util.List; + +import static com.jenny.advancedarrows.advancedArrows.MODID; + public abstract class ArrowAbstract extends ArrowItem { public ArrowAbstract(Properties properties){ super(properties); } - /*@Override - public void appendHoverText(@NotNull ItemStack pStack, @Nullable Level pLevel, @NotNull List pTooltipComponents, @NotNull TooltipFlag pIsAdvanced) { + @Override + public void appendHoverText(@NotNull ItemStack pStack, @NotNull TooltipContext pContext, @NotNull List pTooltipComponents, @NotNull TooltipFlag pTooltipFlag) { String key = String.format("tooltip.%s.%s", MODID, this); MutableComponent toolTip = Component.translatable(key); if (!toolTip.getString().equals(key)) { pTooltipComponents.add(toolTip.withStyle(ChatFormatting.DARK_BLUE)); - super.appendHoverText(pStack, pLevel, pTooltipComponents, pIsAdvanced); + super.appendHoverText(pStack, pContext, pTooltipComponents, pTooltipFlag); } - }*/ + } @Override @NotNull