Posted October 1, 20169 yr 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 Developer of Primeval Forest.
October 1, 20169 yr 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. 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/
October 1, 20169 yr 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. 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.
October 1, 20169 yr Author 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 ]). Developer of Primeval Forest.
October 1, 20169 yr 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")); 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.
October 1, 20169 yr 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. 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/
October 1, 20169 yr Author 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. Developer of Primeval Forest.
October 1, 20169 yr 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 . 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/
October 1, 20169 yr Author 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%. Developer of Primeval Forest.
October 2, 20169 yr I think you meant I18n.format("example.string", TextFormatting.BOLD, TextFormatting.RESET) 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.
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.