Jump to content

1.9 AdvancedModelLoader Has Changed?


Bright_Steel

Recommended Posts

I'm trying to use a .obj file for my tile entity's model. I've been following a tutorial for 1.8, but I'm using forge for 1.9 and I think some things have changed. So...

 

What is now IModelCustom?

And has AdvancedModelLoader changed to something else?

Does renderAll(); still exist?

Link to comment
Share on other sites

AdvancedModelLoader

no longer exists, OBJ and B3D models are now part of the baked model system. This means that you can use them anywhere you'd use a JSON model and you don't need a

TileEntitySpecialRenderer

.

 

To use an OBJ/B3D model, tell the appropriate loader that it can load models from your resource domain (mod ID) by calling

ObjLoader#addDomain

or

B3DLoader#addDomain

in preInit from your client proxy (or a class called from it). You can then specify your model just like you would a JSON model, but include the .obj/.b3d file extension.

 

Forge itself has a test mod with some examples: code, assets

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.

Link to comment
Share on other sites

AdvancedModelLoader

no longer exists, OBJ and B3D models are now part of the baked model system. This means that you can use them anywhere you'd use a JSON model and you don't need a

TileEntitySpecialRenderer

.

 

To use an OBJ/B3D model, tell the appropriate loader that it can load models from your resource domain (mod ID) by calling

ObjLoader#addDomain

or

B3DLoader#addDomain

in preInit from your client proxy (or a class called from it). You can then specify your model just like you would a JSON model, but include the .obj/.b3d file extension.

 

Forge itself has a test mod with some examples: code, assets

 

I'm a little confused. So I have a class with this code to locate the .json files for each block:

public static void reg(Block block){
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
	.register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(modid + ":" + block.getUnlocalizedName().substring(5), "inventory"));
}

 

How exactly would I be able to include the .obj extension? (I already have called the ObJLoader add domain to the client proxy).

Link to comment
Share on other sites

Never use unlocalised names for anything other than translation/display, they're not unique and can change at any time. The default model loaded for every

Item

is the one with its registry name (

IForgeRegistryEntry#getRegistryName

, inherited by

Item

and

Block

), so use that as the default location for your models. Unlocalised names have nothing to do with models.

 

Don't use

ItemModelMesher#register

, use

ModelLoader.setCustomModelResourceLocation

/

setCustomMeshDefinition

in preInit.

 

If your item model is located at assets/<modid>/models/item/<name>.obj, use

new ModelResourceLocation("<modid>:<name>.obj", "inventory")

as the model location. Forge allows item models to be loaded from variants of blockstates files, so you could use

new ModelResourceLocation("<modid>:<name>", "<variant>")

to use the model from the

"<variant>"

variant of assets/<modid>/blockstates/<name>.json.

 

I have a more detailed description of the model loading process and how model locations are mapped to model files here.

 

Forge's blockstates format may also be useful 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.

Link to comment
Share on other sites

Never use unlocalised names for anything other than translation/display, they're not unique and can change at any time. The default model loaded for every

Item

is the one with its registry name (

IForgeRegistryEntry#getRegistryName

, inherited by

Item

and

Block

), so use that as the default location for your models. Unlocalised names have nothing to do with models.

 

Don't use

ItemModelMesher#register

, use

ModelLoader.setCustomModelResourceLocation

/

setCustomMeshDefinition

in preInit.

 

If your item model is located at assets/<modid>/models/item/<name>.obj, use

new ModelResourceLocation("<modid>:<name>.obj", "inventory")

as the model location. Forge allows item models to be loaded from variants of blockstates files, so you could use

new ModelResourceLocation("<modid>:<name>", "<variant>")

to use the model from the

"<variant>"

variant of assets/<modid>/blockstates/<name>.json.

 

I have a more detailed description of the model loading process and how model locations are mapped to model files here.

 

Forge's blockstates format may also be useful here.

 

Okay, I think I sort of follow you. I changed the class to this:

public final class BlockRenderRegister {

public static void registerBlockRenderer(){
ModelLoader.setCustomModelResourceLocation(TardisBlocks.ninthRoundel, 0, new ModelResourceLocation("doctorwhouniverse:ninth_roundel.obj", "inventory"));
}
}

 

But now I'm getting this error "The method setCustomModelResourceLocation(Item, int, ModelResourceLocation) in the type ModelLoader is not applicable for the arguments (Block, int, ModelResourceLocation)"

Link to comment
Share on other sites

But now I'm getting this error "The method setCustomModelResourceLocation(Item, int, ModelResourceLocation) in the type ModelLoader is not applicable for the arguments (Block, int, ModelResourceLocation)"

 

That's a basic Java error, the method expects an

Item

but you're passing it a

Block

.

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.

Link to comment
Share on other sites

But now I'm getting this error "The method setCustomModelResourceLocation(Item, int, ModelResourceLocation) in the type ModelLoader is not applicable for the arguments (Block, int, ModelResourceLocation)"

 

That's a basic Java error, the method expects an

Item

but you're passing it a

Block

.

 

Do you know why I'm getting this error when I start the client? And the block loads with the purple and black texture.

 

[17:14:48] [Client thread/ERROR] [FML]: Exception loading model for variant doctorwhouniverse:ninth_roundel.obj#normal for blockstate "doctorwhouniverse:ninth_roundel.obj"

net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model doctorwhouniverse:ninth_roundel.obj#normal with loader INSTANCE, skipping

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

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

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

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

at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:127) ~[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:120) [simpleReloadableResourceManager.class:?]

at net.minecraft.client.Minecraft.startGame(Minecraft.java:535) [Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:381) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]

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_91]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]

at GradleStart.main(GradleStart.java:26) [start/:?]

Caused by: java.io.FileNotFoundException: doctorwhouniverse:ninth_roundel.obj

at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:68) ~[FallbackResourceManager.class:?]

at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:64) ~[simpleReloadableResourceManager.class:?]

at net.minecraftforge.client.model.obj.OBJLoader.loadModel(OBJLoader.java:58) ~[OBJLoader.class:?]

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

... 21 more

 

Link to comment
Share on other sites

Caused by: java.io.FileNotFoundException: doctorwhouniverse:ninth_roundel.obj

 

My guess is you're not passing in the right model path. I would expect the obj file to be in the "models\block" or "models\item" folders.

Link to comment
Share on other sites

Caused by: java.io.FileNotFoundException: doctorwhouniverse:ninth_roundel.obj

 

My guess is you're not passing in the right model path. I would expect the obj file to be in the "models\block" or "models\item" folders.

 

I just tried redoing the block and a bunch of other stuff and pasting the obj in every resource folder but I keep getting errors. I've been trying to figure this out for days and nothing works. Could someone try and get an .obj to work in my project if I sent it to you? I'll pay money.. >.<

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

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