Posted August 17, 20187 yr could someone help me with int conversion for my tooltips?? above constructor ive set public int BurnTime; public String burntime = String.valueOf(BurnTime); in constructor i set int BurnTime in the super i set this. BurnTime = burntime; in the add information code i set tooltip.add(this.burntime); i get no errors and yes the item has the right burn time set to it (the items burn at the rate in which they are set) but the tooltip says 0, i cant get it to write the proper int ive tried using Integer.toString(BurnTime) String.valueOf(BurnTime) Integer(BurnTime).toString() https://github.com/reapersremorse/UTO-Mod/blob/master/src/main/java/com/reapersremorse/uto/prefabs/items/BasicItemPrefab.java
August 17, 20187 yr 6 minutes ago, reapersremorse said: could someone help me with int conversion for my tooltips?? Please learn Java. 7 minutes ago, reapersremorse said: public String burntime = String.valueOf(BurnTime); This is ran once and it happens before you set your BurnTime variable in your constructor. You need to set this also in your constructor. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 17, 20187 yr Your burntime string is set before you have assigned any bvalue to your integer burntime. Remove this variable, it's unnecessary. And do not name your variables from upper case (google for java naming conventions) tooltip.add(String.valueOf(burnTime));//burnTime is your integer variable
August 17, 20187 yr Author 2 minutes ago, diesieben07 said: When this executes, BurnTime is not initialized yet, so it is 0. burntime therefor gets initialized to "0" and is never changed. i tried setting as an int instead of a string, it only wants a string so i converted it to a string. 3 minutes ago, diesieben07 said: Why do you even have this separate String field? Just use the int field when you create the tooltip does this mean i have to set 2 fields for my tooltips? i could not use an int in any way inside the tooltips, when i tried setting the field from public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) { intopublic void addInformation(ItemStack stack, World worldIn, List<int> tooltip, ITooltipFlag flagIn) { orpublic void addInformation(ItemStack stack, World worldIn, List<Integer> tooltip, ITooltipFlag flagIn) { it would not add the tooltips.
August 17, 20187 yr Author oh i get it, thank you for the help. i was just inputting the method incorrectly. this works well, thanks for the speedy help.
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.