Jump to content

Custom Item JSON File Can't Be Found... D:


Jimmeh

Recommended Posts

Hey guys, so I'm learning how to create custom items, and for some reason, the JSON file can't be found even though I'm 99% sure my file structure is correct.

 

Here's the code where I register the models (from what I understand, this event is ran client-side once the ModelLoader is ready for models):

@SubscribeEvent
    public static void registerModels(ModelRegistryEvent event){
        for(Item item: ItemHandler.INSTANCE.itemList){
            ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(Test.MODID + ":" + item.getRegistryName(), "inventory"));
        }
    }

 

And here's a screenshot of my folder structure: https://gyazo.com/5833a05b1e69ec11647a312ea24dd5f6

 

As you can see, I have 'assets.test.models.item.ItemTrainingStaff.json'. The registry name for the item is "ItemTrainingStaff", however, it continues to spit out the error: "Caused by: java.io.FileNotFoundException: test:models/item/ItemTrainingStaff.json".

 

If you have any idea as to why this could be happening, I'm all ears! Thanks!

Link to comment
Share on other sites

Personally id just use this method

	
public static String modid = ModInfo.MODID;

public static void reg(Item item) {
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
    .register(item, 0, new net.minecraft.client.renderer.block.model.ModelResourceLocation(modid + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}		 

ModInfo.MODID is just where my modid is located,

and then have a second method like:

public static void registerItemRenders() {
}

then register that in the client proxy,

and just register the item in that method as such:

public static void registerItemRenders() {
	reg(ModItems.testItem);
}

this is just a suggestion, you dont have to do anything i have stated above

Link to comment
Share on other sites

Personally id just use this method

	
public static String modid = ModInfo.MODID;

public static void reg(Item item) {
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
    .register(item, 0, new net.minecraft.client.renderer.block.model.ModelResourceLocation(modid + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}		 

ModInfo.MODID is just where my modid is located,

and then have a second method like:

public static void registerItemRenders() {
}

then register that in the client proxy,

and just register the item in that method as such:

public static void registerItemRenders() {
	reg(ModItems.testItem);
}

this is just a suggestion, you dont have to do anything i have stated above

 

I appreciate the suggestion! I'll try that if I can't figure it out with 'ModelLoader.setCustomModelResourceLocation(...)'. In a previous thread earlier today, I was told to use that rather than getItemModelMesher(). I don't know if this is the "new" way or what, but if it continues to not work, I'll definitely be going back to that. haha

Link to comment
Share on other sites

Personally id just use this method

	
public static String modid = ModInfo.MODID;

public static void reg(Item item) {
    Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
    .register(item, 0, new net.minecraft.client.renderer.block.model.ModelResourceLocation(modid + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}		 

ModInfo.MODID is just where my modid is located,

and then have a second method like:

public static void registerItemRenders() {
}

then register that in the client proxy,

and just register the item in that method as such:

public static void registerItemRenders() {
	reg(ModItems.testItem);
}

this is just a suggestion, you dont have to do anything i have stated above

 

I appreciate the suggestion! I'll try that if I can't figure it out with 'ModelLoader.setCustomModelResourceLocation(...)'. In a previous thread earlier today, I was told to use that rather than getItemModelMesher(). I don't know if this is the "new" way or what, but if it continues to not work, I'll definitely be going back to that. haha

 

Its just the way i use to register my block and item renders and never had a problem with it ;p

Link to comment
Share on other sites

post your json code, item class, registry class,proxy class, and main class

 

Alrighty, a lot of code inbound.

 

Main:

@Mod(modid = Test.MODID, name = Test.MOD_NAME, version = Test.VERSION)
public class Test {
    public static final String VERSION = "1.0.0";
    public static final String MODID = "test";
    public static final String MOD_NAME = "Test Mod";

    @SidedProxy(serverSide = "com.github.jimmeh.server.ServerProxy", clientSide = "com.github.jimmeh.client.ClientProxy")
    public static ServerProxy PROXY;

    @Mod.Instance("test")
    public static Test INSTACE;

    @Mod.EventHandler
    public void onPreInit(FMLPreInitializationEvent event){
        Test.PROXY.onPreInit();
    }

    @Mod.EventHandler
    public void onInit(FMLInitializationEvent event){
        Test.PROXY.onInit();
    }

    @Mod.EventHandler
    public void onPostInit(FMLPostInitializationEvent event){
        Test.PROXY.onPostInit();
    }

}

 

ClientProxy:

public class ClientProxy extends ServerProxy {

    public static final Minecraft MINECRAFT = Minecraft.getMinecraft();

    @Override
    public void onPreInit(){
        super.onPreInit();

        MinecraftForge.EVENT_BUS.register(ClientEventHandler.INSTANCE);
    }

    @Override
    public void onInit(){super.onInit();}

    @Override
    public void onPostInit(){
        super.onPostInit();
    }

}

 

Server Proxy:

public class ServerProxy {

    public void onPreInit(){
        MinecraftForge.EVENT_BUS.register(ServerEventHandler.INSTANCE);
    }

    public void onInit(){
        //Items and blocks here
        ItemHandler.INSTANCE.onInit();
    }

    public void onPostInit(){

    }

}

 

ItemHandler:

public enum ItemHandler {

    INSTANCE;

    public List<Item> itemList = new ArrayList<Item>();

    public static ItemTrainingStaff staffTraining;

    public void onInit(){ //this.register your items
        staffTraining = new ItemTrainingStaff();
        this.registerItem(staffTraining);
    }

    private void registerItem(ItemBase item){
        //GameRegistry.register(item, new ResourceLocation(Test.MODID, item.getItemReference().getRegistryName()));
        GameRegistry.register(item);
        this.itemList.add(item);
    }

}

 

ItemBase:

public class ItemBase extends Item {

    private ItemReferences itemReference;

    public ItemBase(ItemReferences i){
        this.itemReference = i;
        setUnlocalizedName(i.getUnlocalizedName());
        setRegistryName(i.getRegistryName());
    }

    public ItemReferences getItemReference() {
        return itemReference;
    }
}

 

ItemReferences:

public enum ItemReferences {

    /*
     * For json models, the file name needs to match the registry name
     * For the lang, use the unlocalized name
     */

    ItemTrainingStaff("ItemTrainingStaff");

    private String unlocalizedName;
    private String registryName;

    ItemReferences(String u){unlocalizedName = this.registryName = u;}

    public String getUnlocalizedName() {
        return unlocalizedName;
    }

    public String getRegistryName() {
        return registryName;
    }
}

 

ItemTrainingStaff:

public class ItemTrainingStaff extends ItemBase {

    public ItemTrainingStaff(){
        super(ItemReferences.ItemTrainingStaff);
    }

}

 

ItemTrainingStaff.json:

{
  "parent": "builtin/generated",
  "textures": {
    "layer0": "test:items/ItemTrainingStaff"
  }
}

 

I know this is a lot, but thanks for, at the very least, taking a shot at this!

 

Link to comment
Share on other sites

That whole substring thing is so stupid.

 

I personally set UnlocalizedName and RegistryName to the same string then when I register my model I make my model resource loader load my item/block's registry name

 

Actual example 

 

my block

 

public static final Block ORE_COPPER = new BaseBlock( Material.ROCK, Material.ROCK.getMaterialMapColor(), "pickaxe", 1).setHardness(3.5F).setResistance(5.0F).setRegistryName("oreCopper").setUnlocalizedName("oreCopper").setCreativeTab(ModData.CREATIVE_TAB);

 

 

my model registry

 

ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.ORE_COPPER), 0, new ModelResourceLocation(ModBlocks.ORE_COPPER.getRegistryName(), "normal"));

 

 

This way my model name = localized string name = registry string name

Life is 3 times easier.

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

That whole substring thing is so stupid.

 

I personally set UnlocalizedName and RegistryName to the same string then when I register my model I make my model resource loader load my item/block's registry name

 

Actual example 

 

my block

 

public static final Block ORE_COPPER = new BaseBlock( Material.ROCK, Material.ROCK.getMaterialMapColor(), "pickaxe", 1).setHardness(3.5F).setResistance(5.0F).setRegistryName("oreCopper").setUnlocalizedName("oreCopper").setCreativeTab(ModData.CREATIVE_TAB);

 

 

my model registry

 

ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(ModBlocks.ORE_COPPER), 0, new ModelResourceLocation(ModBlocks.ORE_COPPER.getRegistryName(), "normal"));

 

 

I just set my unlocalized name = registry name as well. It made sense to me. haha. I notice you have "normal" in your ModelResourceLocation. All tutorials have "inventory" there. If you don't mind, could you explain what that's actually for, because none of them seem to do that

Link to comment
Share on other sites

Blocks are "variants" (blocks that have sub blocks based on condition ex rotated blocks) "multipart" (blocks made out of many pieces that are added or removed based on conditions ex fences) and "normal"  (regular blocks with only one look with no facing or anything special)

 

Items in your inventory use "inventory" when you register them.

 

 

oh and here is my mod I am working on.

https://github.com/trollworkout/technorcery

 

Make sure your folder structure is similar to mine. Is only one way to do it

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Blocks are "variants" (blocks that have sub blocks based on condition ex rotated blocks) "multipart" (blocks made out of many pieces that are added or removed based on conditions ex fences) and "normal"  (regular blocks with only one look with no facing or anything special)

 

Items in your inventory use "inventory" when you register them.

 

 

oh and here is my mod I am working on.

https://github.com/trollworkout/technorcery

 

Make sure your folder structure is similar to mine. Is only one way to do it

 

Ah, okay. So I'm trying to go through and pick out what could help me here. haha. I see in your ModItems class, you use

GameRegistry.register(item)

But you aren't setting the model or anything.

Could you explain to me in what order you do what?

 

I'm trying to use the (apparently) new events for registering things. RegistryEvent.Register<Item> to register all my items and ModelRegisteryEvent to set all the ModelResourceLocations. Apparently those fire before FMLPreInitializationEvent does

Link to comment
Share on other sites

remove Test.MODID + ":" +  from your model loader registry. when you do item.getRegistryName is automatically included

 

This is why is not working

 

The mod is looking for test:test:ItemTrainingStaff

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Blocks are "variants" (blocks that have sub blocks based on condition ex rotated blocks) "multipart" (blocks made out of many pieces that are added or removed based on conditions ex fences) and "normal"  (regular blocks with only one look with no facing or anything special)

 

Items in your inventory use "inventory" when you register them.

 

 

oh and here is my mod I am working on.

https://github.com/trollworkout/technorcery

 

Make sure your folder structure is similar to mine. Is only one way to do it

 

Ah, okay. So I'm trying to go through and pick out what could help me here. haha. I see in your ModItems class, you use

GameRegistry.register(item)

But you aren't setting the model or anything.

Could you explain to me in what order you do what?

 

I'm trying to use the (apparently) new events for registering things. RegistryEvent.Register<Item> to register all my items and ModelRegisteryEvent to set all the ModelResourceLocations. Apparently those fire before FMLPreInitializationEvent does

 

You don't have to do it like me. I set all my models in a separate client sided only class.

https://github.com/trollworkout/technorcery/blob/master/src/main/java/com/technorcery/client/ModelsHandler.java

which is called from the client proxy here https://github.com/trollworkout/technorcery/blob/master/src/main/java/com/technorcery/client/ProxyClient.java

 

and the whole proxy is here

https://github.com/trollworkout/technorcery/blob/master/src/main/java/com/technorcery/common/Proxy.java this is the main proxy

 

. I just split all my stuff in various pieces so they are all together.

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

set it up like I have it set up with proxy and use init and preInit events like I do and you'll be good.

 

and you use GameRegistry.register(block, item whatever..) everything

 

 

common/Technorcery is my main file look at that and you'll get it

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Also i strongly suggest using GitHub as if you do need help/ something isnt working correctly, someone can easily create a Pull Request and you can see what they changed/added, and learn greatly from it

 

True. I might scrap this and start fresh. If I do, then I'll use Github.

Link to comment
Share on other sites

set it up like I have it set up with proxy and use init and preInit events like I do and you'll be good.

 

and you use GameRegistry.register(block, item whatever..) everything

 

 

common/Technorcery is my main file look at that and you'll get it

 

I just arranged it your way and for some reason it's still not working. I have no idea what I've done wrong. My resources path is correct, so I still have no clue why it can't find the JSON file. But I do like the way you have your mod set up!

Link to comment
Share on other sites

set it up like I have it set up with proxy and use init and preInit events like I do and you'll be good.

 

and you use GameRegistry.register(block, item whatever..) everything

 

 

common/Technorcery is my main file look at that and you'll get it

 

I just arranged it your way and for some reason it's still not working. I have no idea what I've done wrong. My resources path is correct, so I still have no clue why it can't find the JSON file. But I do like the way you have your mod set up!

 

Did you remove the Mod.MODID + ":" part?

 

Try to run the game and read what the error says. It will tell you what's wrong. It will say can't be found and will tell you what can't be found like /test/test/test/something blah blah.json can't be found. This way you can kinda figure out what you did wrong. Lowercase, uppercase , misspelling, ..

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Did you remove the Mod.MODID + ":" part?

 

Try to run the game and read what the error says. It will tell you what's wrong. It will say can't be found and will tell you what can't be found like /test/test/test/something blah blah.json can't be found. This way you can kinda figure out what you did wrong. Lowercase, uppercase , misspelling, ..

 

Yeah, I removed that. Followed your example to a T. Usually error reports are my best friend, but this one doesn't seem to help since the path it's specifying is literally the same structure I have in my resources folder. Here's the error report: http://hastebin.com/muxeborinu.rb

And my folder structure: https://gyazo.com/ccb0bda2a43365ceff4e0beada180e98

Link to comment
Share on other sites

Based on what I read is looking for a blockstate. That means your item is actually a block.

 

For items make sure you use "inventory" on the model loader.

 

For blocks use "variants" "normal" or "multipart" + make sure you got a blockstate for each block in addition to models

Disclaimer:  I been told to keep my opinions to myself, to shut up and that I am spreading lies and misinformation or even that my methods are unorthodox and or too irregular. Here are my suggestions take it or leave it.

Link to comment
Share on other sites

Based on what I read is looking for a blockstate. That means your item is actually a block.

 

For items make sure you use "inventory" on the model loader.

 

For blocks use "variants" "normal" or "multipart" + make sure you got a blockstate for each block in addition to models

 

Okay, now that's realllly strange .-. The item I've created is ItemTrainingStaff, which extends (another custom class) ItemBase, which extends Item. Why would it be considering itself a block? O_o

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.