Sunday, 24 May 2015

Common mistakes with filenames

Many of the block and item model problems are caused by incorrect filenames, or files being placed in the wrong place.

Some notes about getting filenames and folder structure right:

Your project directory structure should look like the one in this example project here.
i.e. src/main/resources/assets/minecraftbyexample/

When you build your project to debug or run it, the resources in these folders will be copied into the build folder
build/classes/main/assets/minecraftbyexample
which is where forge expects to find them.


View from IntelliJ 14

There are a few reasons things can go wrong, usually one of the following:
  1. You have spelled a folder name incorrectly, check very closely!  Check spaces between words!
  2. You have added .json or .png where it's not required, for example
    {
        "variants": {
            "normal": { "model": "minecraftbyexample:mbe01_block_simple_model.json" }
        }
    }
  3. I'm told that underscores(_) are not permitted in texture names. For example, in a model json, the texture path "MODID:items/TEXTURE", TEXTURE must not contain any underscores. It works ok for me, but hey. 
  4. When specifying a resource location, or in one of your json files, you have added the wrong domain, or forgotten it entirely.  This may be obvious from the error message, for example
    java.io.FileNotFoundException: misspelleddomain:models/block/mbe01_block_simple_model.json
    {
        "variants": {
            "normal": { "model": "misspelleddomain:mbe01_block_simple_model" }
        }
    }
    or missing entirely, in which case it defaults to the minecraft domain.
    java.io.FileNotFoundException: minecraft:models/block/mbe01_block_simple_model.json
    {
        "variants": {
            "normal": { "model": "mbe01_block_simple_model" }
        }
    }
    
    
  5. Upper/Lower case must match!  myModFolder is not the same as mymodfolder!
    Your mod ID, all your package names and folder names should be all lower case.  Your filenames can be mixed case if you are careful to be consistent, but it's probably easier to leave them all lower case too.  Especially since if you use GitHub for your project, it ignores your filename case and will cause you all sorts of grief when you try to fix it without realising what's happening.  (Hint: rename myWROngFile.json to dummyname.json, commit, then rename to mywrongfile.json and commit again).
  6. If you are using IntelliJ 14 instead of Eclipse, you should add this line to the bottom of your build.gradle file, otherwise it won't copy your resources to the right place.
    sourceSets { main { output.resourcesDir = output.classesDir } }
    See here for more information.

1 comment:

  1. Underscores are absolutely acceptable. Just look at vanilla: there are underscores everywhere!

    iron_sword, log_oak_top, crafting_table_front, bucket_lava

    ReplyDelete