Jump to content

int conversion errors??


reapersremorse

Recommended Posts

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 2018-08-17_05_21_37.thumb.png.bdec37adca9c9d232cafd315ab37db3f.png 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

into
public void addInformation(ItemStack stack, World worldIn, List<int> tooltip, ITooltipFlag flagIn) {
or

public void addInformation(ItemStack stack, World worldIn, List<Integer> tooltip, ITooltipFlag flagIn) {
it would not add the tooltips.

 

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.

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...

×   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.

Announcements



×
×
  • Create New...

Important Information

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