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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • There's a scheme I got into where they promised to trade Bitcoin for me and take a cut as a commission. Seemed like a good idea at the time. But then, things went south real fast. They ended up transferring   $190,000 worth of my Bitcoin. I was devastated and felt completely helpless. That's when I stumbled upon the Wizard Web Recovery Tool. It was like a beacon of hope amid chaos. With this tool, I could finally start digging into what went wrong and hopefully get my Bitcoin back. Using Wizard Web was surprisingly easy. I just had to plug in some details about my Bitcoin account and let it do its thing. It started scanning the internet, looking for any clues about what happened to my Bitcoin. It felt like having a detective on my side, searching for answers. And guess what? Wizard Web found some leads. It uncovered evidence of the scheme's shady dealings and helped me track down the people responsible for losing my Bitcoin. Armed with this information, I took the case to court. After a long and hard-fought legal battle, the court ruled in my favor. The perpetrators were held accountable for their actions and faced criminal charges for their involvement in the scheme. It was a victory not just for me, but for anyone who's been taken advantage of by these kinds of scams. Thanks to Wizard Web Recovery, I was able to get justice and reclaim what was rightfully mine. It showed me that even in the face of adversity, there's always a way to fight back. And with the right tools and determination, anything is possible.   The following is the contact information for Wizard Web Recovery.   Email: wizard web recovery((@))programmer . net
    • Hello, good morning. I know some programming and I'm interested in mod creation. That's why I've decided to follow a tutorial guide on YouTube by TurtyWurty. https://www.youtube.com/watch?v=DhoX9cmAZqA&t=160s&ab_channel=TurtyWurty I've followed the tutorial perfectly. The problem is that when checking the food, the texture doesn't load for me. However, everything seems fine no matter how much I check. I'm sure it's something trivial, the problem is that I can't find it. Could you help me solve it, please? I leave a zip of my file so you can edit it freely. forge-1.20-Civicraft.rar
    • If you have nvidia graphics, it's important that you make sure Minecraft (and anything Minecraft-related) is set to prefer high performance graphics first. If you only update your AMD drivers it might fix the issue but cause severe performance loss vs Vanilla as it'll be running on the integrated graphics instead of dedicated nvidia graphics
    • Update your drivers: https://www.amd.com/en/support/downloads/drivers.html/processors/ryzen/ryzen-5000-series/amd-ryzen-5-5600g.html
  • Topics

×
×
  • Create New...

Important Information

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