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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
    • All versions of Minecraft Forge suddenly black screen even without mods (tried reinstalling original Minecraft, Java, updating drivers doesn't work)
  • Topics

×
×
  • Create New...

Important Information

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