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 try:

    @Override
    @OnlyIn(Dist.CLIENT)
    public void appendHoverText(ItemStack itemStack, @Nullable World world, List<ITextComponent> textComponents,
                                ITooltipFlag tipFlag) {
        if (itemStack.getTag() != null) {
            textComponents.add(new TranslationTextComponent("tooltip.chinacraft.silk_worm.schedule",10));
        }
    }

No effect, he didn't append variables behind mine

first do never use @OnlyIn, since it's only for vanilla
second, do you want to have the '10' as replacement for your TranslationTextComponent?
-> if yes, that's not how the TranslationTextComponent worked, you need to put the Translation into the language file
-> if not, explain what you mean by 'he didn't append variables behind mine'

  • Author
7 hours ago, Luis_ST said:

first do never use @OnlyIn, since it's only for vanilla
second, do you want to have the '10' as replacement for your TranslationTextComponent?
-> if yes, that's not how the TranslationTextComponent worked, you need to put the Translation into the language file
-> if not, explain what you mean by 'he didn't append variables behind mine'

This is my language file

ย 

I also have a custom variable, I want to splice it to the back of the language file to make it look like this: Growth progress: 20

ย 

"tooltip.chinacraft.silk_worm.schedule": "ยงaGrowth progress: ",

ย 

    @Override
    public void appendHoverText(ItemStack itemStack, @Nullable World world, List<ITextComponent> textComponents,
                                ITooltipFlag tipFlag) {
        if (itemStack.getTag() != null) {
            textComponents.add(new TranslationTextComponent("tooltip.chinacraft.silk_worm.schedule"));
        }
    }

ย 

I am curious how it is implemented in the code.
Or do I need to implement it in the language file?

ย 

I use translation software, if you donโ€™t understand, Iโ€™m sorry

Edited by Spring

8 hours ago, Spring said:

I also have a custom variable, I want to splice it to the back of the language file to make it look like this: Growth progress: 20

19 hours ago, Spring said:
new TranslationTextComponent("tooltip.chinacraft.silk_worm.schedule",10)

this is correct but the translation should look like this:

"tooltip.chinacraft.silk_worm.schedule": "Growth progress: %s"

ย 

8 hours ago, Spring said:

ยงa

do not use color codes, use IFormattableTextComponent#mergeStyle

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.