zlepper / itlt

It's the little things mod, a mod about the little things.
MIT License
12 stars 5 forks source link

Startup crash #24

Closed InteJason closed 3 years ago

InteJason commented 3 years ago

https://pastebin.com/xLvnEYem

Version: 1.16.5 itlt-1.16.x-2.0.0

PaintNinja commented 3 years ago

Thanks for your report.

Please temporarily remove Optifine, Performant, LazyDFU, Adaptive Performance Tweaks, SmoothBoot, Dynamic View Distance and Fast Furnace and run the game again as they might be causing trouble. Depending on who you ask, either some, many or all performance mods come at the cost of compatibility issues, gameplay changes or some other kind of catch.

If it still crashes, please provide the new crash report. If it works, one of those is doing sketchy things it shouldn't and you should raise an issue with them with a link to here.

What launcher and OS are you using by the way?

FractalizeR commented 3 years ago

I've the same problem. Tried to remove mods you mentioned one by one to locate problematic one and didn't succeed. itlt crashes anyway so may be it conflics with two. But may be it's just because of the locale. The error message says, it cannot parse string "3,6" on my PC and "6,7" in the log above. Looks like locale problems with russian language for instance.

Anyway, for now I'm going to try to disable itlt.

PaintNinja commented 3 years ago

Interesting, thanks for your insight @FractalizeR.

The problematic line in question is here: https://github.com/zlepper/itlt/blob/ab69e71b2926f7de65a474b8715044b3fbdd6bf0/src/main/java/dk/zlepper/itlt/client/ClientModEvents.java#L44

It seems like Java's Float.parseFloat(String) doesn't support localisation while String.format(String, Float) does, causing the crash. The fix seems trivial - just add an extra method to the chain that replaces any "," with "." before trying to parse it as a float. I just don't have access to my desktop at the moment so can't push out the fix yet. :(

Does launching the game with a newer version of Java fix the issue in the meantime? Just curious if it's a bug in old Java 8u51 that ships with 1.16.5. You can find guides on how to change the version of Java used to launch the game on the itlt wiki.

FractalizeR commented 3 years ago

No, I was using latest Java8 version available at the previous weekend (downloaded it from official website and setup my GDLauncher to use it).

PaintNinja commented 3 years ago

What about Java 15 (or Java 16 with the Java args in step 7 here)? Aside from that there's unfortunately nothing else I can do or suggest atm until I have access to my desktop again. :/

FractalizeR commented 3 years ago

Actually, I never tried, sorry ;) Java 16 crashed the GDLauncher (or the modpack may be) almost immediately after I started playing. And I stopped playing that modpack, that contained your mod. So no hurry and no worries ;) Glad I could help.

Maxi3773 commented 3 years ago

I have the same problem. It seems to effect every language that uses a comma in floating point numbers.

Aside from that there's unfortunately nothing else I can do or suggest atm until I have access to my desktop again. :/

When will you be able to fix this bug?

PaintNinja commented 3 years ago

When will you be able to fix this bug?

I'll fix it as soon as I can. Might be a day, might be a week - I genuinely don't know at the moment.

Usually I'm pretty quick with bugfixes and ports but unexpected things happened that I need to sort out first.

Maxi3773 commented 3 years ago

The problematic line in question is here:

https://github.com/zlepper/itlt/blob/ab69e71b2926f7de65a474b8715044b3fbdd6bf0/src/main/java/dk/zlepper/itlt/client/ClientModEvents.java#L44

It seems like Java's Float.parseFloat(String) doesn't support localisation while String.format(String, Float) does, causing the crash. The fix seems trivial - just add an extra method to the chain that replaces any "," with "." before trying to parse it as a float. I just don't have access to my desktop at the moment so can't push out the fix yet. :(

It seems like this is really the problematic line. I tested your replacing idea and it works, but while doing this I guess I have found an even better solution.

import java.util.Locale;

public class Main {

    public static void main(String[] args) {

        long memory = 2684354560L;

        // Replace
        String text1 = String.format("%.1f", memory / 1073741824F).replace(',', '.');
        // String.format() returns a localized floating point number
        // String.replace() replaces any ',' with '.' when the locale uses ',' instead of '.'

        // This only works for locales which use ',' instead of '.' but not if it uses a different character for the
        // floating point or different system of writing floats, therefore it is not very safe!
        System.out.println(text1);
        float memoryInGiB1 = Float.parseFloat(text1); // Works!
        System.out.println(memoryInGiB1);

        // No Locale
        String text2 = String.format((Locale) null, "%.1f", memory / 1073741824F);
        // String.format() returns a floating point number without localization
        // This should always work!
        System.out.println(text2);
        float memoryInGiB2 = Float.parseFloat(text2); // Works!
        System.out.println(memoryInGiB2);
    }
}
PaintNinja commented 3 years ago

Sorry about the delays... v2.0.1 is finally out and has implemented @07maxi's fix, among other things. Thanks to those involved for reporting this and helping diagnose and fix the issue.