Jump to content

[1.12.2] Cannot load .OBJ file [SOLVED]


mirk

Recommended Posts

I'm having some trouble getting my .OBJ file into Minecraft. I've got the OBJLoader.INSTANCE.addDomain() going. It fails to open the file, because for some reason, it keeps trying to load a .JSON file. I'm stepping through the code and it fails in ModelLoader.getModelLocation(), I think.

How do I successfully load a .OBJ file?

 

For reference, here's my block state file.

Spoiler

 


{
	 "forge_marker": 1,
		 "defaults": 
		 {
			 "textures": 
			 {
				"all": "momcraft:blocks/models/magic_node.obj"
			 }
		 },
		 "variants": 
		 {
			"normal":
			{
				"model": "momcraft:blocks/models/magic_node.obj"
			},
			 "inventory": 
			{
				"model": "momcraft:blocks/models/magic_node.obj"
			}
	 }
}

I hope I got these BBS tags right.

 

Any help is massively appreciated!

Edited by mirk
Link to comment
Share on other sites

12 hours ago, mirk said:

"textures": { "all": "momcraft:blocks/models/magic_node.obj" }

Why is your texture an .obj file?
 

1 hour ago, Naturix said:

and the model not obj should be json

No.

 

12 hours ago, mirk said:

"model": "momcraft:blocks/models/magic_node.obj"

When a model is looked up in the game the blocks/models/ path is added automatically. With your path the game tries to look for the model at momcraft:blocks/models/blocks/models/magic_node.obj which is incorrect. Just specify your path as momcraft:magic_node.obj similar to how I do here.

Link to comment
Share on other sites

Okay, I've changed the texture path.

 

So to load an .OBJ file, I change it to a .JSON?

What should be in this new .JSON?

 

Quote

When a model is looked up in the game the blocks/models/ path is added automatically. With your path the game tries to look for the model at momcraft:blocks/models/blocks/models/magic_node.obj which is incorrect. Just specify your path as momcraft:magic_node.obj similar to how I do here.

Alright, so I've done this, fixed an error that I got, and it's now throwing an exception when loading the model. Looks like I've got the right path, now, at least.

Edited by mirk
Link to comment
Share on other sites

1 hour ago, mirk said:

Alright, so I've done this, fixed an error that I got, and it's now throwing an exception when loading the model. Looks like I've got the right path, now, at least.

Do still need help if so post the exception.

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.

Link to comment
Share on other sites

28 minutes ago, mirk said:

Alrighty, so I've done some more investigation, and I think it's failing because it's trying to open magic_node.obj.json.

 

I'm not sure why this is happening.

We can't help without actual information. Post your blockstate and your log that has the exception.

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.

Link to comment
Share on other sites

Ah, of course. Sorry about that.

 

Log with the exception:

Spoiler

[20:27:02] [main/ERROR] [FML]: Exception loading model for variant momcraft:magic_node#normal for blockstate "momcraft:magic_node"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model momcraft:magic_node#normal with loader VariantLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) ~[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:559) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
    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_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model momcraft:block/magic_node.obj with loader VanillaLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:667) ~[ModelLoader$WeightedRandomModel.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1183) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 21 more
Caused by: java.io.FileNotFoundException: momcraft:models/block/magic_node.obj.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:117) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:870) ~[ModelLoader$VanillaLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:667) ~[ModelLoader$WeightedRandomModel.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1183) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 21 more

 

Block state:

Spoiler

{
     "forge_marker": 1,
         "defaults": 
         {
             "textures": 
             {
                "all": "momcraft:magic_node.png"
             }
         },
         "variants": 
         {
            "normal":
            {
                "model": "momcraft:magic_node.obj"
            },
             "inventory": 
            {
                "model": "momcraft:magic_node.obj"
            }
     }
}

 

Link to comment
Share on other sites

26 minutes ago, mirk said:

Block state:

Your model path should not have ".obj at the end of it"

And your texture path should not have the ".png" at the end of it.

These will be automatically appended.

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.

Link to comment
Share on other sites

Okay, so I took those out, but it's still not very happy about these model files.

Did I perhaps do something wrong exporting them from Blender?

Is there a guide to doing this?

 

Here's the console log:

Spoiler

[21:05:14] [main/ERROR] [FML]: Exception loading model for variant momcraft:magic_node#normal for blockstate "momcraft:magic_node"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model momcraft:magic_node#normal with loader VariantLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:237) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:225) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:152) ~[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:559) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
    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_171]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:25) [start/:?]
Caused by: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model momcraft:block/magic_node with loader VanillaLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:667) ~[ModelLoader$WeightedRandomModel.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1183) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 21 more
Caused by: java.io.FileNotFoundException: momcraft:models/block/magic_node.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:117) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:870) ~[ModelLoader$VanillaLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.<init>(ModelLoader.java:667) ~[ModelLoader$WeightedRandomModel.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1183) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 21 more

 

Link to comment
Share on other sites

2 minutes ago, mirk said:

Is there a guide to doing this?

There is a forge docs page for models and it includes .obj files.

 

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.

Link to comment
Share on other sites

2 minutes ago, Animefan8888 said:

There is a forge docs page for models and it includes .obj files.

 

I've given that a read, but I was hoping for something a little more in-depth and Blender-related.

Do I triangulate the model?

My model has several meshes: does this affect the import process?

Do I use the "Objects as OBJ groups" option in Blender's .OBJ exporter?

 

Sorry for all of the questions, I'm mostly just venting my frustrations at this point.

Link to comment
Share on other sites

1 minute ago, mirk said:

I've given that a read, but I was hoping for something a little more in-depth and Blender-related.

Do I triangulate the model?

My model has several meshes: does this affect the import process?

Do I use the "Objects as OBJ groups" option in Blender's .OBJ exporter?

 

Sorry for all of the questions, I'm mostly just venting my frustrations at this point.

I am unsure as to the process of exporting and making the model myself. But I believe that if it was finding your file it would be throwing a different exception our way, than the one that specifies a json file. Could you post the file path to your .obj and .mtl file and show the code where you call OBJLoader.addDomain also add the .obj extension back to your blockstate file according to the docs that is the correct way to do that.

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.

Link to comment
Share on other sites

26 minutes ago, Animefan8888 said:

I am unsure as to the process of exporting and making the model myself. But I believe that if it was finding your file it would be throwing a different exception our way, than the one that specifies a json file. Could you post the file path to your .obj and .mtl file and show the code where you call OBJLoader.addDomain also add the .obj extension back to your blockstate file according to the docs that is the correct way to do that.

Alright, so I've put the .obj back into the blockstates file.

 

This is in my MoMCraft.java file, my main mod file. I'm not sure if this is the right place to do it or not.

Spoiler

@EventHandler
public void init(FMLInitializationEvent event)
{
	OBJLoader.INSTANCE.addDomain(MODID);
}

 

And the path to my model and material is simply:

assets/momcraft/models/block/magic_node.obj
assets/momcraft/models/block/magic_node.mtl

 

Edited by mirk
Added material path
Link to comment
Share on other sites

3 minutes ago, mirk said:

This is in my MoMCraft.java file, my main mod file. I'm not sure if this is the right place to do it or not.

Do this in FMLPreInitializationEvent instead.

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.

Link to comment
Share on other sites

2 minutes ago, mirk said:

Thank you so much for your help, Animefan8888.

No problem, glad I could help. Also it will look weird if you model protrudes outside of a 1 block space into another blocks, so you may wanna shrink it a little.

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.

Link to comment
Share on other sites

And change the block type to not be a full, opaque cube so it doesn't create holes in the world.

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.

Link to comment
Share on other sites

16 minutes ago, Animefan8888 said:

No problem, glad I could help. Also it will look weird if you model protrudes outside of a 1 block space into another blocks, so you may wanna shrink it a little.

Yeah, I'm going to scale it down a bit, it's a bit extra at the moment. I think the missing texture is actually a problem in Blender, because I have no idea how to use it properly.

 

8 minutes ago, Draco18s said:

And change the block type to not be a full, opaque cube so it doesn't create holes in the world.

Yes, that too! I was following a tutorial that was teaching about opaque cubes and stuff, so I just left it in like a dingus.

Edited by mirk
Replying to Draco18s
Link to comment
Share on other sites

6 minutes ago, mirk said:

Blender

I have no idea how to use it properly.

No one does.

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.

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I'm using Modrinth as a launcher for a forge modpack on 1.20.1, and can't diagnose the issue on the crash log myself. Have tried repairing the Minecraft instillation as well as removing a few mods that have been problematic for me in the past to no avail. Crash log is below, if any further information is necessary let me know. Thank you! https://paste.ee/p/k6xnS
    • Hey folks. I am working on a custom "Mecha" entity (extended from LivingEntity) that the player builds up from blocks that should get modular stats depending on the used blocks. e.g. depending on what will be used for the legs, the entity will have a different jump strength. However, something unexpected is happening when trying to override a few of LivingEntity's functions and using my new own "Mecha" specific fields: instead of their actual instance-specific value, the default value is used (0f for a float, null for an object...) This is especially strange as when executing with the same entity from a point in the code specific to the mecha entity, the correct value is used. Here are some code snippets to better illustrate what I mean: /* The main Mecha class, cut down for brevity */ public class Mecha extends LivingEntity { protected float jumpMultiplier; //somewhere later during the code when spawning the entity, jumpMultiplier is set to something like 1.5f //changing the access to public didn't help @Override //Overridden from LivingEntity, this function is only used in the jumpFromGround() function, used in the aiStep() function, used in the LivingEntity tick() function protected float getJumpPower() { //something is wrong with this function //for some reason I can't correctly access the fields and methods from the instanciated entity when I am in one of those overridden protected functions. this is very annoying LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 0f return this.jumpMultiplier * super.getJumpPower(); } //The code above does not operate properly. Written as is, the entity will not jump, and adding debug logs shows that when executing the code, the value of this.jumpMultiplier is 0f //in contrast, it will be the correct value when done here: @Override public void tick() { super.tick(); //inherited LivingEntity logic //Custom logic LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 1.5f } } My actual code is slightly different, as the jumpMuliplier is stored in another object (so I am calling "this.legModule.getJumpPower()" instead of the float), but even using a simple float exactly like in the code above didn't help. When running my usual code, the object I try to use is found to be null instead, leading to a crash from a nullPointerException. Here is the stacktrace of said crash: The full code can be viewed here. I have found a workaround in the case of jump strength, but have already found the same problem for another parameter I want to do, and I do not understand why the code is behaving as such, and I would very much like to be able to override those methods as intended - they seemed to work just fine like that for vanilla mobs... Any clues as to what may be happening here?
    • Please delete post. Had not noticed the newest edition for 1.20.6 which resolves the issue.
    • https://paste.ee/p/GTgAV Here's my debug log, I'm on 1.18.2 with forge 40.2.4 and I just want to get it to work!! I cant find any mod names in the error part and I would like some help from the pros!! I have 203 mods at the moment.
  • Topics

×
×
  • Create New...

Important Information

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