PictureSign

PictureSign

13.4k Downloads

Crash after pasting an (seemingly valid) URL

SammyForReal opened this issue ยท 1 comments

commented

Description

Whenever I paste the URL https://github.com/MModding/extravaganza/blob/main/src/main/resources/assets/extravaganza/icon.png?raw=true into a sign, it crashes.

Hotfix

I managed to avoid the crash by adding yet anoyher try-catch block at eu.midnightdust.picturesign.util.PictureURLUtils at Line 35:

try {
    jsonData = GSON.fromJson(reader, STRING_TYPE);
} catch (JsonIOException error) {
    PictureSignClient.LOGGER.error("Unable to load url from JSON because of reading issues: " + error.getMessage());
} catch (JsonSyntaxException error) {
    PictureSignClient.LOGGER.error("Unable to load url from JSON because of an syntax error: " + error.getMessage());
}

Crash

---- Minecraft Crash Report ----
// Hi. I'm Minecraft, and I'm a crashaholic.

Time: 2024-07-08 19:02:43
Description: Rendering Block Entity

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.Gson.fromJson(Gson.java:1238)
    at com.google.gson.Gson.fromJson(Gson.java:1137)
    at com.google.gson.Gson.fromJson(Gson.java:1107)
    at eu.midnightdust.picturesign.util.PictureURLUtils.infoFromJson(PictureURLUtils.java:35)
    at eu.midnightdust.picturesign.render.PictureRenderer.render(PictureRenderer.java:73)
    at eu.midnightdust.picturesign.render.PictureSignRenderer.render(PictureSignRenderer.java:23)
    at net.minecraft.class_837.handler$dmj000$picturesign$ps$onRender(class_837.java:537)
    at net.minecraft.class_837.method_23083(class_837.java)
    at net.minecraft.class_837.method_3569(class_837.java:41)
    at net.minecraft.class_824.method_23079(class_824.java:90)
    at net.minecraft.class_824.method_23081(class_824.java:79)
    at net.minecraft.class_824.method_3554(class_824.java:104)
    at net.minecraft.class_824.method_3555(class_824.java:79)
    at me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer.renderBlockEntity(SodiumWorldRenderer.java:368)
    at me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer.redirect$cjg000$iris$addToList2(SodiumWorldRenderer.java:592)
    at me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer.renderGlobalBlockEntities(SodiumWorldRenderer.java:330)
    at me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer.renderBlockEntities(SodiumWorldRenderer.java:271)
    at net.minecraft.class_761.handler$eia000$sodium$onRenderBlockEntities(class_761.java:14327)
    at net.minecraft.class_761.method_22710(class_761.java:1119)
    at net.minecraft.class_757.method_3188(class_757.java:1087)
    at net.minecraft.class_757.method_3192(class_757.java:850)
    at net.minecraft.class_310.method_1523(class_310.java:1285)
    at net.minecraft.class_310.method_1514(class_310.java:882)
    at net.minecraft.client.main.Main.main(Main.java:256)
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:470)
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
    at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
    at org.prismlauncher.launcher.impl.StandardLauncher.launch(StandardLauncher.java:100)
    at org.prismlauncher.EntryPoint.listen(EntryPoint.java:129)
    at org.prismlauncher.EntryPoint.main(EntryPoint.java:70)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
    at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:393)
    at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:182)
    at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:144)
    at com.google.gson.Gson.fromJson(Gson.java:1227)
    ... 29 more

Environment

I am using Fabric in mc1.21, with PictureSign 2.0.1 installed.

commented

The root issue seems to be that GitHub is listed as a JSON source by default, so the mod assumes it is a json when it's actually an image. Upload to a different host until I have time to fix this.