Modding Help Json issue when creating matitem recipe

Discussion in 'Starbound Modding' started by Fruiteyes, Sep 12, 2016.

  1. Fruiteyes

    Fruiteyes Phantasmal Quasar

    So I've created a matitem, and I want it to be craftable from the Industrial Workbench. So I created a recipe file for it, based off of the neonblock recipe file. All I changed was one part of the recipe, and the name of the material to be spawned. Yet, when I load Starbound, I get this error message in the log file:

    [Error] Could not instantiate item '[invisiblematerial, 20, {}]'. (JsonException) Improper conversion to JsonArray from string

    I'm not sure what I did wrong. Everything checks out in the json linter I've been using, so I don't think the code is messed up. Here's the neonblock recipe file and my recipe file for comparison.

    {
    "input" : [
    { "item" : "glass", "count" : 1 },
    { "item" : "smallbattery", "count" : 1 }
    ],
    "output" : { "item" : "neonblock", "count" : 20 },
    "duration" : 0.25,
    "groups" : [ "craftingfurniture2", "materials", "all" ]
    }



    {
    "input" : [
    { "item" : "glass", "count" : 1 },
    { "item" : "phasematter", "count" : 1 }
    ],
    "output" : { "item" : "invisiblematerial", "count" : 20 },
    "duration" : 0.5,
    "groups" : [ "craftingfurniture2", "materials", "all" ]
    }




    Any idea what's wrong? The matitem itself works just fine, I can spawn it and place it without any problem, it's just the recipe that's giving me issues, so I'm not really sure what I'm missing here...
     
  2. Chofranc

    Chofranc Pangalactic Porcupine




    You have those lines in one recipe file? If is yes, then there is your problem, it should be a comma before the last block, try that and comment if its work or not.

    , <----- here
    {
    "input" : [
    { "item" : "glass", "count" : 1 },
    { "item" : "phasematter", "count" : 1 }
    ],
    "output" : { "item" : "invisiblematerial", "count" : 20 },
    "duration" : 0.5,
    "groups" : [ "craftingfurniture2", "materials", "all" ]
    }
     
  3. LordBaconator

    LordBaconator Scruffy Nerf-Herder

    Everything looks correct to me.

    You should post your invisiblematerial.matitem file. The material you created is probably misnamed somewhere or you are using an incorrect reference.
     
  4. LordBaconator

    LordBaconator Scruffy Nerf-Herder

    He posted two separate recipe blocks for visual comparison. The top one is just a copy of the vanilla recipe he used as a basis for his.
     
  5. Fruiteyes

    Fruiteyes Phantasmal Quasar

    {
    "itemName" : "invisiblematerial",
    "price" : 0,
    "category" : "block",
    "rarity" : "Legendary",
    "inventoryIcon" : "invisible.png",
    "description" : ". . .",
    "shortdescription" : "Invisible Block",
    "materialId" : 6260,
    "learnBlueprintsOnPickup" : "invisiblematerial"
    }


    And here's the .material file as well:

    {
    "materialId" : 6260,
    "materialName" : "invisible",
    "particleColor" : [255, 255, 255, 255],
    "itemDrop" : "invisiblematerial",
    "description" : ". . .",
    "shortdescription" : "Invisible Material",
    "footstepSound" : "/tiles/default_footstep.ogg",
    "health" : 25,
    "category" : "materials",

    "renderTemplate" : "/tiles/classicmaterialtemplate.config",
    "renderParameters" : {
    "texture" : "invisible.png",
    "variants" : 1,
    "lightTransparent" : false,
    "occludesBelow" : false,
    "multiColored" : false,
    "zLevel" : 1920
    }
    }
     
  6. LordBaconator

    LordBaconator Scruffy Nerf-Herder

    Try changing "invisiblematerial" to "invisible" in your recipe. I have a feeling it wants to use the name of the .material instead of the name of the .matitem in the crafting recipe.
     
  7. Fruiteyes

    Fruiteyes Phantasmal Quasar

    Hmm. Okay, I just tried that, but now I get this error:
    [15:55:14.461] [Error] Could not instantiate item '[invisible, 20, {}]'. (ItemException) No such item 'invisible'
     
  8. LordBaconator

    LordBaconator Scruffy Nerf-Herder

    Looks like you had it right the first time. I still don't understand why it's throwing the error about converting JsonArray to String though. Everything you did looks identical to the vanilla file...
     
  9. Fruiteyes

    Fruiteyes Phantasmal Quasar

    I know, right? That's why I'm so confused... I literally copied the vanilla file and just changed the second line in the recipe and the name of the material, I don't get what the problem is.
     
  10. LordBaconator

    LordBaconator Scruffy Nerf-Herder

    Stuff like this usually happens when you miss name something or use the wrong reference name for what you're trying to use. An example I had was adding Cobblestone to merchant inventories. Adding "cobblestone" threw an error because the item name that all of the cobblestone materials drop is named "cobblestonematerial."

    Maybe you miss typed a filename or put a file in the wrong place.
     
  11. Fruiteyes

    Fruiteyes Phantasmal Quasar

    I've double and triple checked all of the filenames and their references in my code, all of those seem to check out fine.

    Let's see... I think the only thing I haven't shared yet are my paths.

    /items/materials/invisible.matitem
    /recipes/furniture2/materials/invisiblematerial.recipe
    /tiles/materials/invisible.material

    Is there anything wrong here? Because if not, I don't know what else could possibly be the problem. As mentioned earlier, the material itself works fine, I can spawn it using admin commands and place it without problem, but the recipe won't load for whatever reason.
     
  12. LordBaconator

    LordBaconator Scruffy Nerf-Herder

    Try changing filename of the .matitem to invisiblematerial.matitem, then try the same but instead rename invisible.material to invisiblematerial.matitem.

    Sometimes it can be irritatingly unclear whether the Json is going to interpret names as the file name or the name of the item you defined inside the file. Sometimes the reference the game wants is inconsistent in different parts of the code.
     
  13. Fruiteyes

    Fruiteyes Phantasmal Quasar

    I tried both, but neither one made a difference.
     
  14. LordBaconator

    LordBaconator Scruffy Nerf-Herder

    Not sure what else to tell you. Usually these things are an obvious case of "You fucked up; here is how, where, and why."
    This is a much more nuanced problem and I haven't had cause to try and add a recipe for a new block material before so I'm not really sure where to go from here. It has to be some sort of item naming reference error because all of the syntax was correct in all of the files and all of the path names were correct.
     
  15. Fruiteyes

    Fruiteyes Phantasmal Quasar

    Eh if nothing else, I guess I could just leave the recipe out of the picture for now. After all, the new block material works just fine, and I can easily spawn it in with admin commands. Plus, the main idea behind the mod is for server admins to be able to create invisible barriers in certain areas, so having a recipe would be counterintuitive since then just anyone could make it, I suppose.

    Thanks everyone for your help, even though we were unable to solve the problem. I appreciate all of you jumping in here to offer assistance ^^
     
  16. ColonolNutty

    ColonolNutty Ketchup Robot

    The issue I ran into that caused this problem wasn't with the recipe itself but with the object I was creating. For instance you are missing the array around your learnBlueprintsOnPickup value

    "materialId" : 6260,
    "learnBlueprintsOnPickup" : "invisiblematerial"

    should be

    "materialId" : 6260,
    "learnBlueprintsOnPickup" : ["invisiblematerial"]

    For anyone that isn't the OP, other places to look would be inside the .patch files in the case of OPs example you would find the invisible.matitem.patch. check your quotations, an easy one to miss is this one "[invisible]" (should be ["invisible"]) that's the problem I was having

    FIgured I would answer this since it's the only forum I found that was even close to related and it didn't have a proper answer.
     
    Last edited: Feb 10, 2017
    Cyel likes this.
  17. bk3k

    bk3k Oxygen Tank

    I don't know if it will allow 2 recipes in one file or not, but if it will, it will expect it like this.

    Code:
    [
      {
        "input" : [
          { "item" : "glass", "count" : 1 },
          { "item" : "smallbattery", "count" : 1 }
        ],
        "output" : { "item" : "neonblock", "count" : 20 },
        "duration" : 0.25,
        "groups" : [ "craftingfurniture2", "materials", "all" ]
      },
      {
        "input" : [
          { "item" : "glass", "count" : 1 },
          { "item" : "phasematter", "count" : 1 }
        ],
        "output" : { "item" : "invisiblematerial", "count" : 20 },
        "duration" : 0.5,
        "groups" : [ "craftingfurniture2", "materials", "all" ]
      }
    ]
    Note that I put the 2 objects({ } is considered a JSON object) within an array([ ] is considered a JSON array so that there is only one base level container. I'm fairly certain it isn't truly valid any other way.

    I'm still not sure it will work. You might get an error about "improper conversion from object to array". The vanilla recipes don't do what you did and my instinct says it won't work. You might just need to make 2 different .recipe files.
    someRecipe.1.recipe
    someRecipe.2.recipe
    "someRecipe" is obviously a placeholder for another name.

    That said I HIGHLY recommend you don't name your materials something so generic because the chances of another mod using that exact name(with a different "materialId") are high and that the attempt to use both will crash the game on startup.

    What I recommend instead is appending either the mod name(perhaps a short verson) or your handle like so
    "materialName" : "Fruiteyes_invisibleMaterial",
    That's unlikely to be used by anyone else.
     
  18. ColonolNutty

    ColonolNutty Ketchup Robot

    Hmm, I hadn't thought of that being a problem. Have you tried it ingame? does it recognize both of the recipes? Does it crash? or does it recognize only the first? I only ask because that would simplify some of my recipes ;)
     

Share This Page