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

Hi

 

I have this block which can only be placed on logs, which is fine. But it is a TileEntity which has a function that makes a value in it go up over time, I have a simple boolean value whenever it can do that or not. But due to the nature of the block, I would for that boolean value only change to true when the log it is attached is actually a tree log. I don't want the player to just build a wall of logs and then spamming my block on it, at least make it a little harder.

So if there is a way to check whenever a block (a wood log in this case) has been placed by a tree growing and not placed by some other way such as the player or part of a village house.

 

 

I would like to add colour to the tooltip of my item to accommodate people with dyslexia to recognize an element better inside my ore block by-product better. I have an enum of colour codes corresponding to my ores, so checking that is simple, but having it change colour is the problem.

 

My current code for the tooltip:

if (flagIn.isAdvanced()) {
    for (ElementComposition element : this.composition)
        tooltip.add(new TranslationTextComponent("tooltip.intercraftcore.composition",element.getSymbol(true),element.getPercentage()*100));
}

 

2019-08-28_14_26_03.thumb.png.e4b4f42c6ce11ce718ea39841a354113.png

 

When I tried a simple test to just change the colour I crashed when hovering over the item:

tooltip.add(new TranslationTextComponent(I18n.format("tooltip.intercraftcore.composition", TextFormatting.AQUA, TextFormatting.RESET),element.getSymbol(true),element.getPercentage()*100));

net.minecraft.util.text.TranslationTextComponentFormatException: Error parsing: TranslatableComponent{key=': %', args=[Cu, 95.0], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}}: Unsupported format: '%'

10 minutes ago, Simon_kungen said:

So if there is a way to check whenever a block (a wood log in this case) has been placed by a tree growing and not placed by some other way such as the player or part of a village house.

No.

 

10 minutes ago, Simon_kungen said:

TextFormatting.AQUA, TextFormatting.RESET)

 

There are methods on the TextComponent class that allow you to add formatting. Don't bake it into lang file.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author
17 minutes ago, diesieben07 said:

Use ITextComponent#getStyle to set the formatting and colors for text.

Alright, got it to change to the vanilla hardcoded colours, but how would I change it to my own custom colour codes? Such as 0xc1810a?

 

TranslationTextComponent text = new TranslationTextComponent("tooltip.intercraftcore.composition",element.getSymbol(true),element.getPercentage()*100);

text.getStyle().setColor(...);

tooltip.add(text);

 

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.