Minenash / CustomHUD

A highly customizable variable-based text HUD for Minecraft
MIT License
80 stars 23 forks source link

java.lang.StringIndexOutOfBoundsException: begin 2, end 1, length 3 #64

Closed TheDIGS closed 1 year ago

TheDIGS commented 1 year ago

had my editor on autosave, and the game instantly crashed after i wrote this

==BackgroundColor:0x00000000==

==Section:TopLeft==
{velocity_x}

==Section:TopRight, 0, 150==
{{target_block, "Looking at: {tbx} {tby} {tbz} {target_block}", "goodbye"}}
{{target_block}}

==Section:BottomLeft, 0, 0, true==
{bx} {by} {bz} ({yaw}, {pitch})

specifically the {{target_block}} on line 8

crash report:

---- Minecraft Crash Report ----
// Hey, that tickles! Hehehe!

Time: 2022-09-19 17:38:17
Description: Unexpected error

java.lang.StringIndexOutOfBoundsException: begin 2, end 1, length 3
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4604)
    at java.base/java.lang.String.substring(String.java:2707)
    at com.minenash.customhud.VariableParser.parseElement(VariableParser.java:93)
    at com.minenash.customhud.VariableParser.parseElements(VariableParser.java:48)
    at com.minenash.customhud.Profile.parseProfile(Profile.java:127)
    at com.minenash.customhud.CustomHud.updateProfiles(CustomHud.java:207)
    at com.minenash.customhud.CustomHud.onTick(CustomHud.java:89)
    at net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents.lambda$static$2(ClientTickEvents.java:65)
    at net.minecraft.class_310.handler$zka000$onEndTick(class_310.java:6473)
    at net.minecraft.class_310.method_1574(class_310.java:1907)
    at net.minecraft.class_310.method_1523(class_310.java:1135)
    at net.minecraft.class_310.method_1514(class_310.java:768)
    at net.minecraft.client.main.Main.method_44604(Main.java:244)
    at net.minecraft.client.main.Main.main(Main.java:51)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.quiltmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:423)
    at org.quiltmc.loader.impl.launch.knot.Knot.launch(Knot.java:76)
    at org.quiltmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:24)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.polymc.impl.OneSixLauncher.invokeMain(OneSixLauncher.java:104)
    at org.polymc.impl.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:175)
    at org.polymc.impl.OneSixLauncher.launch(OneSixLauncher.java:185)
    at org.polymc.EntryPoint.listen(EntryPoint.java:144)
    at org.polymc.EntryPoint.main(EntryPoint.java:74)

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
    at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4604)
    at java.base/java.lang.String.substring(String.java:2707)
    at com.minenash.customhud.VariableParser.parseElement(VariableParser.java:93)
    at com.minenash.customhud.VariableParser.parseElements(VariableParser.java:48)
    at com.minenash.customhud.Profile.parseProfile(Profile.java:127)
    at com.minenash.customhud.CustomHud.updateProfiles(CustomHud.java:207)
    at com.minenash.customhud.CustomHud.onTick(CustomHud.java:89)
    at net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents.lambda$static$2(ClientTickEvents.java:65)
    at net.minecraft.class_310.handler$zka000$onEndTick(class_310.java:6473)

-- Affected level --
Details:
    All players: 1 total; [class_746['xthedigs'/4, l='ClientLevel', x=146.84, y=56.00, z=-25.24]]
    Chunk stats: 1024, 357
    Level dimension: minecraft:overworld
    Level spawn location: World: (200,56,-8), Section: (at 8,8,8 in 12,3,-1; chunk contains blocks 192,-64,-16 to 207,319,-1), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,-64,-512 to 511,319,-1)
    Level time: 557634 game time, 1 day time
    Server brand: quilt
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.class_638.method_8538(class_638.java:453)
    at net.minecraft.class_310.method_1587(class_310.java:2341)
    at net.minecraft.class_310.method_1514(class_310.java:792)
    at net.minecraft.client.main.Main.method_44604(Main.java:244)
    at net.minecraft.client.main.Main.main(Main.java:51)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.quiltmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:423)
    at org.quiltmc.loader.impl.launch.knot.Knot.launch(Knot.java:76)
    at org.quiltmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:24)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.polymc.impl.OneSixLauncher.invokeMain(OneSixLauncher.java:104)
    at org.polymc.impl.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:175)
    at org.polymc.impl.OneSixLauncher.launch(OneSixLauncher.java:185)
    at org.polymc.EntryPoint.listen(EntryPoint.java:144)
    at org.polymc.EntryPoint.main(EntryPoint.java:74)

-- Last reload --
Details:
    Reload number: 1
    Reload reason: initial
    Finished: Yes
    Packs: Default, VanillaTweaks_r287952.zip, Fabric Mods

-- System Details --
Details:
    Minecraft Version: 1.19.2
    Minecraft Version ID: 1.19.2
    Operating System: Linux (amd64) version 5.15.0-46-generic
    Java Version: 17.0.4.1, Azul Systems, Inc.
    Java VM Version: OpenJDK 64-Bit Server VM (mixed mode, sharing), Azul Systems, Inc.
    Memory: 1027817896 bytes (980 MiB) / 2560622592 bytes (2442 MiB) up to 4294967296 bytes (4096 MiB)
    CPUs: 8
    Processor Vendor: AuthenticAMD
    Processor Name: AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
    Identifier: AuthenticAMD Family 23 Model 24 Stepping 1
    Microarchitecture: Zen / Zen+
    Frequency (GHz): 2.10
    Number of physical packages: 1
    Number of physical CPUs: 4
    Number of logical CPUs: 8
    Graphics card #0 name: Picasso
    Graphics card #0 vendor: Advanced Micro Devices, Inc. [AMD/ATI] (0x1002)
    Graphics card #0 VRAM (MB): 258.00
    Graphics card #0 deviceId: 0x15d8
    Graphics card #0 versionInfo: unknown
    Virtual memory max (MB): 4987.12
    Virtual memory used (MB): 6405.87
    Swap memory total (MB): 2048.00
    Swap memory used (MB): 1068.73
    JVM Flags: 2 total; -Xms512m -Xmx4096m
    Fabric Mods: ERR
    Launched Version: 1.19.2
    Backend library: LWJGL version 3.3.1 build 7
    Backend API: AMD Radeon(TM) Vega 8 Graphics (RAVEN, DRM 3.42.0, 5.15.0-46-generic, LLVM 12.0.0) GL version 4.6 (Core Profile) Mesa 21.2.6, AMD
    Window size: 1850x1020
    GL Caps: Using framebuffer using OpenGL 3.2
    GL debug messages: 
    Using VBOs: Yes
    Is Modded: Definitely; Client brand changed to 'quilt'; Server brand changed to 'quilt'
    Type: Integrated Server (map_client.txt)
    Graphics mode: fancy
    Resource Packs: vanilla, file/VanillaTweaks_r287952.zip, Fabric Mods
    Current Language: English (US)
    CPU: 8x AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
    Server Running: true
    Player Count: 1 / 8; [class_3222['xthedigs'/4, l='ServerLevel[Test]', x=146.84, y=56.00, z=-25.24]]
    Data Packs: vanilla, Fabric Mods
Minenash commented 1 year ago

Interesting, will look into this weekend, sorry for the delay

Minenash commented 1 year ago

Hmm, it didn't crash for me. Does it reliably crash, and if relevant, what block are you looking at when it crashes?

Minenash commented 1 year ago

Actually, I figured out a problem. Doesn't explain why yours crash and mine doesn't, but {{target_block}} doesn't do anything, It's a conditional without a true or false section(s). I assume you probably meant {target_block}?

Minenash commented 1 year ago

I can't reprouce the crash on my side so I'm going to close this issue, removing the extra set of {} should make the profile work however