I am trying to mod minecraft 1.11.2 in eclipse and I put all the texure files in the right place but they just won't load. I tried rewriting some of the java to see if I had made a mistake but nothing changed. This is my error code:
[11:22:57] [Client thread/INFO]: Created: 16x16 textures-atlas
[11:23:00] [Client thread/ERROR] [FML]: Exception loading model for variant wowkcraft:itemobsidianingot#inventory for item "wowkcraft:itemobsidianingot", normal location exception:
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model wowkcraft:item/itemobsidianingot 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:323) ~[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:153) ~[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:122) [SimpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
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_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.io.FileNotFoundException: wowkcraft:models/item/itemobsidianingot.json
at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:69) ~[FallbackResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:65) ~[SimpleReloadableResourceManager.class:?]
at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?]
at net.minecraftforge.client.model.ModelLoader.access$1600(ModelLoader.java:124) ~[ModelLoader.class:?]
at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:923) ~[ModelLoader$VanillaLoader.class:?]
at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
... 20 more
[11:23:00] [Client thread/ERROR] [FML]: Exception loading model for variant wowkcraft:itemobsidianingot#inventory for item "wowkcraft:itemobsidianingot", blockstate location exception:
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model wowkcraft:itemobsidianingot#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:331) ~[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:153) ~[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:122) [SimpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
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_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]
at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1239) ~[ModelLoader$VariantLoader.class:?]
at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
... 20 more
You're missing an Item Model json. The error is buried a little deeply, as there are several possible errors that lead to a model being unable to load, so the initial error ("failed to load model") is on top of the underlying error (in this case, "file not found").
Taken from the Documentation entries I wrote on the subject, with some minor alterations and updates:
As with blocks, items need models too.
{
"parent": "item/generated",
"textures": {
"layer0": "example:items/basic"
}
}
That's pretty much all that's needed for it to work once the item is registered. The only important thing is that the filename match the registry name used to register the block and should be in all lowercase (1.11+ file names are required to be lowercase, prior to that it is just case sensitive).
Name the model JSON file matching the registry name and save it at src\\main\\resources\\assets\\example\\models\\item\\
(where example
is the mod ID specified in the @Mod annotation of your main mod class).
Additionally create a texture for your item, name it basic.png
and save it to src\\main\\resources\\assets\\example\\textures\\items\\
(The file is referenced by the model via "layer0": "example:items/basic"
which says "find a .png file named 'basic' inside the items
folder of the resource location example
")
The item model here uses a parent of item/generated
, which means that the single supplied texture will be used (as with most non-block items) and will be held in the player's hand in a default orientation. There is also item/handheld
which specifies different display orientations (for tools). Items may also supply their own "display" attribute, overriding those from the parent, but is not needed in 99.9% of uses.
Registering the item:
Item item = new CustomItem();
string registryname = "my_item";
item.setRegistryName(registryname);
item.setUnlocalizedName(item.getRegistryName().toString());
GameRegistry.register(item);
There is an important reason to use item.setUnlocalizedName(item.getRegistryName().toString());
as well! It insures that your item's unlocalized name contains your mod ID to avoid language file conflicts between mods. It is unlikely, but entirely avoidable.
Registering the item model:
final ModelResourceLocation fullModelLocation = new ModelResourceLocation(item.getRegistryName().toString(), "inventory");
ModelBakery.registerItemVariants(item, fullModelLocation);
ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
{
public ModelResourceLocation getModelLocation(ItemStack stack)
{
return fullModelLocation;
}
});
Note that this section must be located client-side only (ie the client proxy) as many of the referenced classes do not exist on the dedicated server.
Registering items with variants eg Saplings, has to be done a different way, using ModelLoader.setCustomModelResourceLocation(item, metadata, resourceLocation)
although it lets us use a Blockstate file to specify our variants (which is much preferred to the alternative).
This also works in 1.11, but is required in 1.12 and forward
GameRegistry.register()
is now private
. Instead you must register things in the RegistryEvent.Register<T>
event through an event handler. Simply subscribe to the RegistryEvent.Register<Item>
or RegistryEvent.Register<Block>
event (as well as others: an event is fired for each registry type) in order to register items and blocks. Simply call event.getRegistry().add(...)
or event.getRegistry().addAll(...)
for every object that needs to be registered. addAll
will accept an array or list. You can see an example of this here .
For models, you do the same thing as above, but in the ModelRegistryEvent
instead. You can see an example of this here although heavily modified to allow for additional variations in models not discussed here (supporting custom MeshDefinitions and StateMappers).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.