Posted February 13, 20232 yr I would love some help with adding a tooltip to my item, I am, ofc, a beginner in modding, and this may seem like a simple thing, but I would like some help with this: so here's my problem, I was adding a tooltip to my code, and I've been having issues, but it seems to have been resolved, but now, I can't seem to make it show up, I think the text is invisible somehow, here is the code and the image to my item (also yes ik, I didn't add the name of my item to the .lang, and the .literal is temporary): package com.github.ClaraArmada.serilis.common.item; import com.github.ClaraArmada.serilis.Serilis; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; import net.minecraft.world.item.AxeItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; import net.minecraft.world.level.Level; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.registries.DeferredRegister; import net.minecraftforge.registries.ForgeRegistries; import net.minecraftforge.registries.RegistryObject; import org.jetbrains.annotations.Nullable; import java.util.List; public class ModTools extends Item { private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, Serilis.MODID); public static final RegistryObject<Item> FLINT_FLAKE = ITEMS.register("flint_flake", () -> new AxeItem(ItemTiers.FLINT, 1, 2f, new Item.Properties())); public ModTools(Properties p_41383_) { super(p_41383_); } @Override public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> components, TooltipFlag flag) { components.add(Component.literal("This is a tool made out of flint").withStyle(ChatFormatting.GOLD)); super.appendHoverText(stack, level, components, flag); } public static void register(IEventBus eventBus) { ITEMS.register(eventBus); } } the code and here's the screenshot
February 13, 20232 yr Can I see the ItemInit? Edit: oh I just noticed what you're doing there. That would be your ToolInit if I'm not mistaken, right? So, to achieve what you want to do you could create the ToolInit which should not extend anything and implement the deferred register in it. Then create your own class of the item and instead of doing new Item or AxeItem you do new YourClass. The class we're talking about should extend the type of item you want to imitate, in this case it seems it's an AxeItem. So YourClass extends AxeItem. Then in that class you override appendHoverText and write stuff inside it. Edited February 13, 20232 yr by DrNickenstein
February 13, 20232 yr Author alright, the problem has been fixed, thank you! 😄 14 minutes ago, DrNickenstein said: Can I see the ItemInit? Edit: oh I just noticed what you're doing there. That would be your ToolInit if I'm not mistaken, right? So, to achieve what you want to do you could create the ToolInit which should not extend anything and implement the deferred register in it. Then create your own class of the item and instead of doing new Item or AxeItem you do new YourClass. The class we're talking about should extend the type of item you want to imitate, in this case it seems it's an AxeItem. So YourClass extends AxeItem. Then in that class you override appendHoverText and write stuff inside it.
February 13, 20232 yr Just now, ClaraArmada said: alright, the problem has been fixed, thank you! 😄 Glad it was useful
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.