Replay Mod Forums

Custom Main Menu, help?
    • User
    • 10 forum posts
    AngelloHalo
    #1

    Apr 21 19, 07:04 AM | Last edited: Apr 21 19, 07:05 AM

    So I made a post earlier, which I deleted since I'm making this one. I'm trying to make a custom main menu for SkyFactory 4, so I can access the replay mod options; I'm using these as a template but there's something I'm doing wrong and I'm not quite sure what. Here is what I have so far:

    {
    "images":
    {
    "title":
    {
    "image" : "test:textures/gui/title/background/alpha.png",
    "posX" : -137,
    "posY" : 30,
    "width" : 512,
    "height" : 512,
    "alignment" : "top_center"
    }
    },

    "buttons":
    {
    "singleplayer":
    {
    "text" : "menu.singleplayer",
    "texture" : "test:textures/gui/title/background/button.png",
    "posX" : -200,
    "posY" : -110,
    "width" : 140,
    "height" : 38,
    "alignment" : "center",
    "imageWidth": "624",
    "imageHeight": "167",
    "action" :
    {
    "type" : "openGui",
    "gui" : "singleplayer"
    }
    },

    "multiplayer":
    {
    "text" : "menu.multiplayer",
    "texture" : "test:textures/gui/title/background/button.png",
    "posX" : -200,
    "posY" : -73,
    "width" : 140,
    "height" : 38,
    "alignment" : "center",
    "imageWidth": "624",
    "imageHeight": "167",
    "action" :
    {
    "type" : "openGui",
    "gui" : "multiplayer"
    }
    },

    "mods":
    {
    "text" : "fml.menu.mods",
    "texture" : "test:textures/gui/title/background/button.png",
    "posX" : -200,
    "posY" : -36,
    "width" : 140,
    "height" : 38,
    "alignment" : "center",
    "imageWidth": "624",
    "imageHeight": "167",
    "action" :
    {
    "type" : "openGui",
    "gui" : "mods"
    }
    },

    "options":
    {
    "text" : "menu.options",
    "texture" : "test:textures/gui/title/background/button.png",
    "posX" : -200,
    "posY" : 1,
    "width" : 140,
    "height" : 38,
    "alignment" : "center",
    "imageWidth": "624",
    "imageHeight": "167",
    "action" :
    {
    "type" : "openGui",
    "gui" : "options"
    }
    },

    "quit":
    {
    "text" : "menu.quit",
    "texture" : "test:textures/gui/title/background/button.png",
    "posX" : -200,
    "posY" : 75,
    "width" : 140,
    "height" : 38,
    "alignment" : "center",
    "imageWidth": "624",
    "imageHeight": "167",
    "action" :
    {
    "type" : "quit"
    }
    },

    "language":
    {
    "text" : "Language",
    "texture" : "test:textures/gui/title/background/button.png",
    "posX" : -200,
    "posY" : 38,
    "width" : 140,
    "height" : 38,
    "alignment" : "center",
    "imageWidth": "624",
    "imageHeight": "167",
    "action" :
    {
    "type" : "openGui",
    "gui" : "languages"
    }
    }

    "replayviewer":
    {
    "text" : "replaymod.gui.replayviewer",
    "posX" : -400,
    "posY" : 38,
    "width" : 140,
    "height" : 38,
    "alignment" : "center",
    "texture" : "mainmenu:shortbutton.png",
    "wrappedButton": 17890234
    },

    "replaycenter":
    {
    "text" : "replaymod.gui.replaycenter",
    "posX" : -400,
    "posY" : 1,
    "width" : 98,
    "height" : 20,
    "alignment" : "center",
    "texture" : "mainmenu:shortbutton.png",
    "wrappedButton": 17890236
    },

    "refresh":
    {
    "text" : "",
    "posX" : -20,
    "posY" : 0,
    "width" : 20,
    "height" : 20,
    "alignment" : "top_right",
    "texture" : "mainmenu:refresh.png",
    "action" :
    {
    "type" : "refresh"
    }
    }
    },


    },

    "labels":
    {
    "mojang":
    {
    "text" : "Copyright Mojang AB. Do not distribute!",
    "posX" : -197,
    "posY" : -10,
    "color" : -1,
    "alignment" : "bottom_right"
    },

    "fml":
    {
    "text" : "",
    "posX" : 2,
    "posY" : -40,
    "color" : -1,
    "alignment" : "bottom_left"
    }
    },

    "other":
    {
    "background":
    {
    "image" : "test:textures/gui/title/background/bg_full.png",
    "mode" : "stretch"
    }
    }
    }
    }


    But it's giving me this error:

    ---- Minecraft Crash Report ----

    WARNING: coremods are present:
    BedPatch (bedpatch-2.2-1.12.2.jar)
    Do not report to Forge! (If you haven't disabled the FoamFix coremod, try disabling it in the config! Note that this bit of text will still appear.) (foamfix-0.10.5-1.12.2.jar)
    CorePlugin (SmoothFont-mc1.12.2-2.0-alpha-11.jar)
    AppleCore (AppleCore-mc1.12.2-3.2.0.jar)
    CoreMod (Aroma1997Core-1.12.2-2.0.0.2.b164.jar)
    LoadingPlugin (replaymod-1.12.2-2.1.4.jar)
    TransformerLoader (OpenComputers-MC1.12.2-1.7.4.153.jar)
    AstralCore (astralsorcery-1.12.2-1.10.17.jar)
    SqueezerCore (SqueezerPatch-1.12.2-1.0.0.jar)
    ForgelinPlugin (Forgelin-1.8.2.jar)
    CTMCorePlugin (CTM-MC1.12.2-0.3.3.22.jar)
    EnderCorePlugin (EnderCore-1.12.2-0.5.56-core.jar)
    ApotheosisCore (Apotheosis-1.12.2-1.9.2.jar)
    BNBGamingCore (BNBGamingCore-1.12.2-0.11.0.jar)
    LoadingPlugin (ResourceLoader-MC1.12.1-1.5.3.jar)
    MalisisCorePlugin (malisiscore-1.12.2-6.5.1.jar)
    SurgeLoadingPlugin (Surge-1.12.2-2.0.77.jar)
    Contact their authors BEFORE contacting forge

    // Ooh. Shiny.

    Time: 4/20/19 9:44 PM
    Description: There was a severe problem during mod loading that has caused the game to fail

    net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Custom Main Menu (custommainmenu)
    Caused by: java.lang.RuntimeException: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 124 column 4 path $.buttons.language
    at lumien.custommainmenu.CustomMainMenu.preInit(CustomMainMenu.java:72)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:637)
    at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
    at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
    at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
    at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
    at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
    at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
    at com.google.common.eventbus.EventBus.post(EventBus.java:217)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    Caused by: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 124 column 4 path $.buttons.language
    at com.google.gson.internal.Streams.parse(Streams.java:60)
    at com.google.gson.JsonParser.parse(JsonParser.java:84)
    at lumien.custommainmenu.configuration.ConfigurationLoader.load(ConfigurationLoader.java:92)
    at lumien.custommainmenu.CustomMainMenu.preInit(CustomMainMenu.java:67)
    ... 40 more
    Caused by: com.google.gson.stream.MalformedJsonException: Unterminated object at line 124 column 4 path $.buttons.language
    at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559)
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:491)
    at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:414)
    at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:738)
    at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:739)
    at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:714)
    at com.google.gson.internal.Streams.parse(Streams.java:48)


    If someone can point out what I'm doing wrong or suggest what to change that'd be amazing. I'm novice (at best) to coding and haven't even touched JavaScript so any help would be appreciated!


    • Developer
    • 1618 forum posts
    johni0702
    #2

    Apr 21 19, 10:21 AM

    {} these denote a set of key-value pairs (e.g. {"a": 5, "b": "text"}) where each pair needs to be separated from other pairs by a single comma.
    So when adding new pairs after the "language": … one, you need to add a comma after the language pair. You also want to remove the one after the "refresh": … pair since it's the last one in that set.

    Side note: JSON is only a small subset of JavaScript and is widely used outside of the JavaScript world (like for custommainmenu).
    To be exact, JSON was only originally intended to be a strict subset of JavaScript, hence its name. However it actually ended up not being one (there are some exceptions but it's still fairly close).