Jump to content

[1.14.2] Natural wood log check + I18n


Recommended Posts



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));




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: '%'

Link to comment
Share on other sites

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.



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.

  • Thanks 1

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.

Link to comment
Share on other sites

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);




Link to comment
Share on other sites

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.

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

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