Jump to content

[SOLVED] [1.10] ModelResourceLocation and model loading errors


Recommended Posts

Posted

Hi,

 

I'm currently updating a mod (Underground Biomes) from 1.8 to 1.10. I'm am having issues with itemblock models. I have several type and each of them have 8 variants that I register like this :

 

protected void registerModel() {
    for (int i = 0; i < NB_VARIANTS; i++) {
        ModelResourceLocation location = new ModelResourceLocation("MODID:name_variantname", "inventory");
        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, location);
        ModelLoader.setCustomModelResourceLocation(item, i, location);
    }
}

 

Forge keeps trying to register the item without variant (I think) but it shouldn't exist.

 

 

 

[16:18:59] [Client thread/ERROR] [FML]: Exception loading model for variant undergroundbiomes:igneous_stone#inventory for item "undergroundbiomes:igneous_stone", normal location exception:

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model undergroundbiomes:item/igneous_stone with loader VanillaLoader.INSTANCE, skipping

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]

at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:317) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:170) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:147) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]

...

Caused by: java.io.FileNotFoundException: undergroundbiomes:models/item/igneous_stone.json

...

[16:18:59] [Client thread/ERROR] [FML]: Exception loading model for variant undergroundbiomes:igneous_stone#inventory for item "undergroundbiomes:igneous_stone", blockstate location exception:

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model undergroundbiomes:igneous_stone#inventory with loader VariantLoader.INSTANCE, skipping

at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]

at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:325) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:170) ~[ModelBakery.class:?]

at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:147) ~[ModelLoader.class:?]

at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]

...

Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException

...

 

 

 

Maybe I don't use ModelResourceLocation correctly. Is there a specific syntax to follow for resource path ? Should I put the variant name like that :

 

new ModelResourceLocation("MODID:name", "variantname");

 

Any ideas ?

Thanks in advance !

Posted

Don't use

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, location);

At all.

It should be

new ModelResourceLocation("MODID:name", "inventory");

You do not need to register it with the variant.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

It's not working without that line. The block's items don't have texture now. And Forge is still looking for model like "undergroundbiomes:igneous_stone#inventory".

 

Also I don't understand why this is necessary at all, because all the needed information is in the blockstate json file :

 

 

{

        "variants":{

                "igneous_type=red_granite":{

                        "model":"undergroundbiomes:red_granite"

                },

                "igneous_type=black_granite":{

                        "model":"undergroundbiomes:black_granite"

                },

                "igneous_type=rhyolite":{

                        "model":"undergroundbiomes:rhyolite"

                },

                "igneous_type=andesite":{

                        "model":"undergroundbiomes:andesite"

                },

                "igneous_type=gabbro":{

                        "model":"undergroundbiomes:gabbro"

                },

                "igneous_type=basalt":{

                        "model":"undergroundbiomes:basalt"

                },

                "igneous_type=komatiite":{

                        "model":"undergroundbiomes:komatiite"

                },

                "igneous_type=dacite":{

                        "model":"undergroundbiomes:dacite"

                }

        }

}

 

 

 

Why do we have to specify the location of the itemblock model ?

Posted

Forge is looking for

"variants": {
     'inventory": {}
}

Which is required in a blockstate JSON file. What do you mean "why do we have to specify the location of the itemblock model"?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Ok thanks.

 

I mean forge (or minecraft) could just use the blockstate json file to find the model. It literally says : "for this block and this variants,  use this model". I don't see why we have to say it another time in the code, seems redundant ...

Posted

I have an explanation of the model loading process and how model locations are mapped to model files here.

 

If you want the item form to use the same models as the block form use

new ModelResourceLocation(item.getRegistryName(), "igneous_type=[type]")

as the location for each metadata value, where

[type]

is the value of the

igneous_type

property for that metadata value. This will load the models specified by the blockstates file with the item's registry name (which should be the same blockstates file used for the block models), using the

igneous_type=[type]

variant.

 

You can see how I do this for my coloured rotatable blocks here (

registerBlockItemModelForMeta

is just a wrapper around

ModelLoader.setCustomModelResourceLocation

). The blockstates files can be found here and here.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Without brackets ? And that's the only method I have to call to set the itemblock model ?

 

Without brackets, yes.

 

ModelLoader.setCustomModelResourceLocation

sets the model for a single

Item

and metadata value. This is the only method you need to call to set the model for an item.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Still not working ...

 

Here is the blockstate file :

 

 

{

"forge_marker": 1,

"defaults": {

"model": "cube_all",

"uvlock": true

},

"variants": {

"igneous_type": {

"red_granite": {

"textures": {

"all": "undergroundbiomes:blocks/red_granite"

}

},

"black_granite": {

"textures": {

"all": "undergroundbiomes:blocks/black_granite"

}

},

"rhyolite": {

"textures": {

"all": "undergroundbiomes:blocks/rhyolite"

}

},

"andesite": {

"textures": {

"all": "undergroundbiomes:blocks/andesite"

}

},

"gabbro": {

"textures": {

"all": "undergroundbiomes:blocks/gabbro"

}

},

"basalt": {

"textures": {

"all": "undergroundbiomes:blocks/basalt"

}

},

"komatiite": {

"textures": {

"all": "undergroundbiomes:blocks/komatiite"

}

},

"dacite": {

"textures": {

"all": "undergroundbiomes:blocks/dacite"

}

}

}

}

}

 

 

 

And the call :

 

for (int i = 0; i < NB_VARIANTS; i++) {
String variant = block.getVariantProperty().getName() + "=" + block.getVariantName(i);
ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(item.getRegistryName(), variant));
}

 

Posted

Are you definitely calling this in preInit?

 

Post the FML log, it should say what went wrong.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted
ModelLoader

methods have always needed to be called in preInit.

ItemModelMesher

methods have always needed to be called in init or later.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • 4 years later...
Posted
Quote

im trying to add a new sword to minecraft like this

ModelResourceLocation s = new ModelResourceLocation("sword:my_sword","inventory");
            ModelLoader.setCustomModelResourceLocation(sword, 0, s);
Quote

but i always get this problem and texture is purple-black

 

[10:21:03] [Client thread/ERROR] [FML]: Exception loading model for variant sword:my_sword#inventory for item "sword:my_sword", normal location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model sword:item/my_sword with loader VanillaLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:302) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:513) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:378) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
	at net.minecraftforge.legacydev.Main.start(Main.java:86) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
Caused by: java.io.FileNotFoundException: sword:models/item/my_sword.json
	at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?]
	at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]
	... 20 more
[10:21:03] [Client thread/ERROR] [FML]: Exception loading model for variant sword:my_sword#inventory for item "sword:my_sword", blockstate location exception: 
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model sword:my_sword#inventory with loader VariantLoader.INSTANCE, skipping
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:161) ~[ModelLoaderRegistry.class:?]
	at net.minecraftforge.client.model.ModelLoader.loadItemModels(ModelLoader.java:296) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelBakery.loadVariantItemModels(ModelBakery.java:175) ~[ModelBakery.class:?]
	at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:151) ~[ModelLoader.class:?]
	at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
	at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:121) [SimpleReloadableResourceManager.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:513) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:378) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_275]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_275]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_275]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_275]
	at net.minecraftforge.legacydev.Main.start(Main.java:86) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
	at net.minecraftforge.legacydev.MainClient.main(MainClient.java:29) [legacydev-0.2.3.1-fatjar.jar:0.2.3.1+4+372be23]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
	at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:83) ~[ModelBlockDefinition.class:?]
	at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1175) ~[ModelLoader$VariantLoader.class:?]
	at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]

 

 

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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