Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

ZonQq0O.png

and here's the screenshot

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 by DrNickenstein

  • 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. 

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.