Bektor Posted October 1, 2016 Posted October 1, 2016 Hi, I'm wondering how to add a translated and coloured tooltip to a block/item/itemblock. That's what I've currently got: tooltip.add(TextFormatting.DARK_GRAY + Constants.MOD_NAME); I'm also wondering if the addInformation method to add a tooltip is client-side only or also server-side and for what the boolean advanced is. Thx in advance. Bektor Quote Developer of Primeval Forest.
yooksi Posted October 1, 2016 Posted October 1, 2016 To add a colour to your tooltip text you have to append a ChatFormatting element to the info argument in the addInformation method followed by your tooltip message. There is a lot of colours to choose from and you can find them as ChatFormatting elements under com.mojang.realmsclient.gui. You can also display the message in italic or bold. Here is an example: @SideOnly(Side.CLIENT) @Override public void addInformation(ItemStack stack, EntityPlayer player, java.util.List<String> info, boolean par4) { info.add(com.mojang.realmsclient.gui.ChatFormatting.BLUE + "This is a simple item."); info.add(com.mojang.realmsclient.gui.ChatFormatting.ITALIC + "It's colour is blue."); // newline } This method should always be client-side, I don't see how it would work server-side. The client is the one that displays the tooltip, the server can't do that. It could ask the client to display it, but the client would still have to be the one that actually displays it, so you would again need some custom code there. Quote I still haven't published a mod because I can never get that in-dev version just right to warrant a public release. And yes, after two years of mod development I am still learning to speak Java. Follow me on GitHub: https://github.com/yooksi Contact me on Twitter: https://twitter.com/yooksi Read my Minecraft blog: https://yooksidoesminecraft.blogspot.de/
Draco18s Posted October 1, 2016 Posted October 1, 2016 I'm also wondering if the addInformation method to add a tooltip is client-side only or also server-side and for what the boolean advanced is. Add information is client side only. It makes no sense on the server. The advanced boolean, I believe, is true if the player is holding Shift. Quote 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.
Bektor Posted October 1, 2016 Author Posted October 1, 2016 I'm also wondering if the addInformation method to add a tooltip is client-side only or also server-side and for what the boolean advanced is. Add information is client side only. It makes no sense on the server. The advanced boolean, I believe, is true if the player is holding Shift. Ah, ok. Now when thinking about it.. makes sense. ^^ Oh and the advanced boolean isn't for holding shift stuff. Tested it a few seconds ago: if(advanced) tooltip.add(TextFormatting.BLACK + "the last of it - the last of them"); So when it is client-side only, which is the best way of translating a String in 1.10.2 (since it's been a long time since I last did such stuff [1.7 or 1.6 I think ]). Quote Developer of Primeval Forest.
Draco18s Posted October 1, 2016 Posted October 1, 2016 Using the text translation around the bit that isn't the color/formatting. tooltip.add(TextFormatting.BLACK + I18n.translateToLocal("the last of it - the last of them")); Quote 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.
larsgerrits Posted October 1, 2016 Posted October 1, 2016 Last time I checked I18n.translateToLocal was deprecated, so which one to use next? I18N.format ? (BTW, that is in another Minecraft I18N class... there are 2...) The advanced tooltips are enabled when you pres F3 + H ingame. Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Bektor Posted October 1, 2016 Author Posted October 1, 2016 Using the text translation around the bit that isn't the color/formatting. tooltip.add(TextFormatting.BLACK + I18n.translateToLocal("the last of it - the last of them")); Last time I checked I18n.translateToLocal was deprecated, so which one to use next? I18N.format ? (BTW, that is in another Minecraft I18N class... there are 2...) The advanced tooltips are enabled when you pres F3 + H ingame. Ah, ok thx. And I18n.translateToLocal is still deprecated. And the method format wants a second parameter. I think there is even one more class... (not names I18n), but not quite sure about it. Quote Developer of Primeval Forest.
larsgerrits Posted October 1, 2016 Posted October 1, 2016 I think the I18N class we should be using now is net.minecraft.client.resources.I18N . Atleast that is what every vanilla and Forge class is using. In the I18N#format method you can leave the second parameter empty if you don't have any formatting in the first String . Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Bektor Posted October 1, 2016 Author Posted October 1, 2016 I think the I18N class we should be using now is net.minecraft.client.resources.I18N . Atleast that is what every vanilla and Forge class is using. In the I18N#format method you can leave the second parameter empty if you don't have any formatting in the first String . Ok, thx. That works. Just letting this open if someone knows it to 100%. Quote Developer of Primeval Forest.
Draco18s Posted October 2, 2016 Posted October 2, 2016 I think you meant I18n.format("example.string", TextFormatting.BOLD, TextFormatting.RESET) Quote 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.
Recommended Posts
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.