Jump to content

FileNotFoundException when reading model json


eowf

Recommended Posts

I'm updating a mod I wrote a while ago (1.10 I think) and I'm running into FileNotFoundExceptions after changing from the old method to using ModelRegistryEvents. I've also moved the mod to a new dev environment on a different computer, so that may have had an effect (messed up directory structure or something). Here's the full error (which occurs several times): https://pastebin.com/M6GNdrGx

 

This is my directory structure:

dirStructure.PNG.8cc743be566b882749a58de12d96b8f0.PNG

 

I have the following json in blockstates:

{
    "variants": {
        "normal": { "model": "ocmod:sphalerite" }
    }
}

in models/block:

{
    "parent": "block/cube_all",
    "textures": {
        "all": "ocmod:blocks/sphalerite"
    }
}

and in models/item:

{
    "parent":"ocmod:block/sphalerite",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

These are all in files named sphalerite.json.

 

The blocks, items, and models are registered here

 
@Mod.EventBusSubscriber
public class RegistryHandler {

    @SubscribeEvent
    public static void onItemRegister(RegistryEvent.Register<Item> event) {
        event.getRegistry().registerAll(ModItems.ITEMS.toArray(new Item[0]));
    }

    @SubscribeEvent
    public static void onBlockRegister(RegistryEvent.Register<Block> event) {
        event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
    }

    @SubscribeEvent
    public static void onModelRegister(ModelRegistryEvent event) {
        for(Item item : ModItems.ITEMS) {
            if(item instanceof IHasModel) {
                ((IHasModel)item).registerModels();
            }
        }
        for(Block block : ModBlocks.BLOCKS) {
            if(block instanceof IHasModel) {
                ((IHasModel)block).registerModels();
            }
        }
    }
}

where ITEMS is a list of all the items (including ItemBlocks) and BLOCKS is a list of all the blocks.

 

 

registerModels calls

Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");

Where registerItemRenderer is

@Override
public void registerItemRenderer(Item item, int meta, String id) {
	ModelResourceLocation rl = new ModelResourceLocation(item.getRegistryName(), id);
	System.out.println("Registering model: " + rl);
	ModelLoader.setCustomModelResourceLocation(item, meta, rl);
}

The print prints "Registering model: ocmod:sphalerite#inventory", which is (as far as I can tell) what is expected.

 

The same problems happen with items.

 

I can host all the code on github if needed, but most of it is unrelated.

Link to comment
Share on other sites

This:

4 hours ago, eowf said:

{ "variants": { "normal": { "model": "ocmod:sphalerite" } } }

variant -> normal

does not match this:

4 hours ago, eowf said:

Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");

variant -> inventory

4 hours ago, eowf said:

"display": { "thirdperson": { "rotation": [ 10, -45, 170 ], "translation": [ 0, 1.5, -2.75 ], "scale": [ 0.375, 0.375, 0.375 ] } }

Also, you don't need this unless you are intentionally wanting a different set of values (why?)

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

After restarting my computer this morning ALL the textures work, even though I've only applied the change you suggested to one of them (not sure why I didn't try restarting earlier...). Seeing as everything is working, would you still recommend making the change? Why does it work despite them not matching?

 

Just now, Draco18s said:

Also, you don't need this unless you are intentionally wanting a different set of values (why?)

Thanks, I must have seen it in an example somewhere and assumed it didn't default to anything if I left it out.

Link to comment
Share on other sites

14 minutes ago, eowf said:

Seeing as everything is working, would you still recommend making the change? Why does it work despite them not matching?

IMO if it isn't broke, don't fix it.

14 minutes ago, eowf said:

I must have seen it in an example somewhere and assumed it didn't default to anything if I left it out.

The values are specified in the parent (or somewhere in the parent hierarchy).

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.