Jump to content

Recommended Posts

Posted (edited)

Hello kind Forge People,

 

a few days ago I decided i wanted to learn to create my own mods in Minecraft using Forge. Sadly, despite several helpful tutorials, I'm facing some problems rather early on. More precisely, I wanted to start with creating a simple Item with a given texture (as several tutorials do it). Somehow none of them seem to work in my case. My "test" Item is still without texture/model. And because different tutorials sometimes use different methods to i.e. register an Item-model, I'm don't know where the problem lies.

 

I'm not sure if this is the right place to ask, but after 2 days of internet searches and many failed trial&errors I dont know what else to do.

 

My First question would be:

I have seen two different methods to register item-textures in a mod:

1. calling ModelLoader.setCustomModelResourceLocation( <Item> , 0, new ModelResourceLocation( <ItemRegistryName ?or? LocationOfTheSavedModelJson?>, "inventory"))

2. calling Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( <Item>, 0, new ModelResourceLocation( ... , "inventory"))

What is the difference between those two? And which one should I use?

What exactlt do I have to give ModelResourceLocation(...) as arguments? The path of the model.json or the RegstryName of the Item? Or has there to be a connection between those two?

 

Is there some kind of Documentation where these things are explained?

 

My second Question (a little more direct):

I made a very tiny 'mod' in order to test a texture for an item. Maybe you could take a look at it and tell me why it doesn't work? I attached all relevant files including a picture of my folder structure to show that this is (hopefully) correct.

The Image of the copperIngot comes from "shadofacts"-tutorial at https://shadowfacts.net/tutorials/forge-modding-1102/json-item-models/

The Testitem appears to be registered correctly as it appears ingame in the Tools-Tab. Somehow the line that registeres the texture doesn't really seem to work.

All Tutorials I've seen stress the separation into Serverside & Clientside stuff. To keep this example as simple as possible I cut that out. It should still function without, right? Or is there some hidden secret that says that all rendering stuff only works if you drop keywords like "ClientProxy" oder "ClientSide" at the right places?

 

Finally I want to say that I'm also new to Java, which might be a little bit problematic for you guys, but I find that reading a few things about Java is far easier than finding anything about forge. Is there somewhere a larger documentation than the one at https://mcforge.readthedocs.io/en/latest/ ?

TestMod.class

ItemTest.class

itemtest.json

testtexturepic.png

folder_structure_pic.PNG

ingame_screenshot.PNG

Edited by hugin
Posted

Why have you uploaded the compiled class files in raw format rather than using any text pasting service like PasteBin or Gist?

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.

Posted
40 minutes ago, hugin said:

Hello kind Forge People,

 

a few days ago I decided i wanted to learn to create my own mods in Minecraft using Forge. Sadly, despite several helpful tutorials, I'm facing some problems rather early on. More precisely, I wanted to start with creating a simple Item with a given texture (as several tutorials do it). Somehow none of them seem to work in my case. My "test" Item is still without texture/model. And because different tutorials sometimes use different methods to i.e. register an Item-model, I'm don't know where the problem lies.

 

I'm not sure if this is the right place to ask, but after 2 days of internet searches and many failed trial&errors I dont know what else to do.

 

My First question would be:

I have seen two different methods to register item-textures in a mod:

1. calling ModelLoader.setCustomModelResourceLocation( <Item> , 0, new ModelResourceLocation( <ItemRegistryName ?or? LocationOfTheSavedModelJson?>, "inventory"))

2. calling Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( <Item>, 0, new ModelResourceLocation( ... , "inventory"))

What is the difference between those two? And which one should I use?

What exactlt do I have to give ModelResourceLocation(...) as arguments? The path of the model.json or the RegstryName of the Item? Or has there to be a connection between those two?

 

Is there some kind of Documentation where these things are explained?

ModelLoader.setCustomModelResourceLocation is the recommended way to register metadata-based item models. You need to call it in ModelRegistryEvent (if you're registering your Items in RegistryEvent.Register) or in preInit (if you're registering your Items in preInit).

 

ModelLoader.setCustomModelResourceLocation calls ModelBakery.registerItemVariants for you, which tells Minecraft to load the model. ItemModelMesher#register doesn't do this.

 

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

 

 

40 minutes ago, hugin said:

 

My second Question (a little more direct):

I made a very tiny 'mod' in order to test a texture for an item. Maybe you could take a look at it and tell me why it doesn't work? I attached all relevant files including a picture of my folder structure to show that this is (hopefully) correct.

The Image of the copperIngot comes from "shadofacts"-tutorial at https://shadowfacts.net/tutorials/forge-modding-1102/json-item-models/

The Testitem appears to be registered correctly as it appears ingame in the Tools-Tab. Somehow the line that registeres the texture doesn't really seem to work.

All Tutorials I've seen stress the separation into Serverside & Clientside stuff. To keep this example as simple as possible I cut that out. It should still function without, right? Or is there some hidden secret that says that all rendering stuff only works if you drop keywords like "ClientProxy" oder "ClientSide" at the right places?

 

The client should work in single player even if you register the models from common code (i.e. not server-only or client-only), but this will crash the dedicated server.

 

The FML log (logs/fml-client-latest.log) should tell you exactly what went wrong when loading your item models, post it.

 

 

40 minutes ago, hugin said:

Finally I want to say that I'm also new to Java, which might be a little bit problematic for you guys, but I find that reading a few things about Java is far easier than finding anything about forge. Is there somewhere a larger documentation than the one at https://mcforge.readthedocs.io/en/latest/ ?

 

That's the only official documentation, but there's various bits of unofficial documentation floating around (e.g. my model loading process document or williewillus' primers, both on Gist).

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

The fml-client-latest.log that I get with the code as posted before is this: http://pastebin.com/4SQYGzMd

At [16:30:46] you'll find an Error message that says forge couldn't load the model due to (Line 431) the missing json file: test1:models/item/testitem_regname.json

Now I wasn't aware that the name of the json needed to coincide with the RegistryName of my Item but apparently this caused a problem.

When creating an additional json file (called "testitem_regname.json") at the required location (with the same content as the previously posted "itemtest.json"), I still don't have my texture in-game :(

The new fml-client-latest.log that I now get is: http://pastebin.com/ekTkNtan

At [16:50:43] you'll again find an error message (caused by something at line 479 ?)

 

Can you explain what these error-messages mean? / Why my example doesn't work?

Posted

Your models don't have to use the item's registry name as their file name, that's just the default model that's loaded when you don't specify anything else.

 

 

8 minutes ago, hugin said:

[16:50:43] [Client thread/ERROR] [FML/]: Exception loading model for variant test1:testitem_regname#inventory for item "test1:testitem_regname", normal location exception:
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model test1:item/testitem_regname with loader VanillaLoader.INSTANCE, skipping
...
Caused by: com.google.gson.JsonSyntaxException: java.io.EOFException: End of input at line 5 column 3
...
Caused by: java.io.EOFException: End of input at line 5 column 3

 

The closing brace on line 5 of your model file closes the "textures" object, but the top-level object is never closed.

  • Like 1

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

Thanks! I fixed the braces in my json file. One error less.

Sadly though, the texture of my model still wont be displayed :( And now there isn't even an "ERROR" message in the fml.log (see http://pastebin.com/kqHqBPbc).

Any more suggestions what I might be missing?

 

And as additional (slight off-topic) question: In this tutorial: http://couchdoescode.blogspot.de/2017/02/items.html?view=flipcard , Alex (the author) mentions unmodded minecraft model files (in a folder at "Referenced Libraries > forgesrc.jar > assets > minecraft > models > item" (particularly the diamond.json ) ), but I can't find this folder like i.e. the forgsrc.jar. Is it supposed to be in the unpacked forge folder? Or somewhere else?

Posted
4 hours ago, hugin said:

Thanks! I fixed the braces in my json file. One error less.

Sadly though, the texture of my model still wont be displayed :( And now there isn't even an "ERROR" message in the fml.log (see http://pastebin.com/kqHqBPbc).

Any more suggestions what I might be missing?

 

I'm not too sure. Try setting a breakpoint in the first loop in ModelLoader#loadItemModels (for(Item item : items), line 325 in my workspace) with the condition item == <your Item instance> and stepping through the code to see what's going on.

 

If that fails, post your whole mod as a Git repository. Look at my mod and its .gitignore file for an example of the files to include.

 

 

4 hours ago, hugin said:

And as additional (slight off-topic) question: In this tutorial: http://couchdoescode.blogspot.de/2017/02/items.html?view=flipcard , Alex (the author) mentions unmodded minecraft model files (in a folder at "Referenced Libraries > forgesrc.jar > assets > minecraft > models > item" (particularly the diamond.json ) ), but I can't find this folder like i.e. the forgsrc.jar. Is it supposed to be in the unpacked forge folder? Or somewhere else?

 

In the Referenced Libraries (Eclipse) or External Libraries (IDEA) section of the project window, there should be a library called forgeSrc-<forgeVersion>.jar that contains the code and assets from Forge and Minecraft.

 

Eclipse can't actually open most files in JARs by default, you need to associate JSON files with the internal text editor (in Window > Preferences > General > Editors > File Associations) or install a plugin. You also need to install a plugin to view PNG files in JARs.

 

IDEA can open JSON and PNG files in JARs by default and allows you to navigate to a file (including those in JARS) with Ctrl-Shift-N.

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

Thank you so much!

The problem seems to appear because I called " new  ItemTest() " twice and created two different testitems on the heap (one for register and the other for the Modelregistration). I will need to take a closer look at the setCustomModelResourceLocation method to find out where exactly this causes a problem, but I can do so on my own now. When creating a single testitem via "ItemTest()" and use it as argument for register(...) AND setCustomModelResourceLocation(...) it works!

 

Thanks again for the quick help! Really nice.

The topic can be closed now I guess.

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.

Announcements



×
×
  • Create New...

Important Information

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