Posted December 4, 20186 yr Hello, I'm pretty new to modding Minecraft and don't understand item models. Could someone walk me through using a .obj file as a model for an item? So far I have been using tutorials meant for using .obj files as models for blocks, and I've seen from a couple of places that all I have to do is add a .obj file extension somewhere, but I'm not sure where. I have also added the OBJLoader.INSTANCE.addDomain(SlimeRancher.MODID); to my mod during preinitialization. Right now I have my vacpack.obj file sitting in my models/item folder along with my vacpack.mtl file. When I test the mod, during loading, I get a slew of errors, the first being Exception loading model for variant slimerancher:vacpack#inventory for item "slimerancher:vacpack", normal location exception: net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model slimerancher:item/vacpack with loader VanillaLoader.INSTANCE, skipping If anyone could help me out I'd appreciate it. Also, if I'm missing important information from this post, please tell me and I'll add it asap. Thanks, Basset Edited December 4, 20186 yr by The_Basset_Hound
December 4, 20186 yr 5 hours ago, The_Basset_Hound said: Also, if I'm missing important information from this post, please tell me and I'll add it asap. We would need at the very least the whole error report, not just one line that tells "something is wrong" but doesn't tell what exactly is. And since there are multiple errors you should just post your debug.log. Please make sure it is not cluttered with unrelevant issues though. 5 hours ago, The_Basset_Hound said: I have also added the OBJLoader.INSTANCE.addDomain(SlimeRancher.MODID); to my mod during preinitialization. I hope it is not directly in your preinit method but is called through your proxy during preinit.
December 4, 20186 yr Author Here's a debuglog I generated when starting up the client. 5 hours ago, V0idWa1k3r said: I hope it is not directly in your preinit method but is called through your proxy during preinit. I don't know what a proxy is and haven't found a good explanation on it, but I'm not calling it straight from my mod's preinit method. Here are the relevant files in pastebin: Link to the main mod file Link to the vacpack item file Link to the mod item file Link to the file I'm using to register the items Thanks for the reply. Edited December 4, 20186 yr by The_Basset_Hound
December 4, 20186 yr 1 hour ago, The_Basset_Hound said: I don't know what a proxy is and haven't found a good explanation on it https://mcforge.readthedocs.io/en/latest/concepts/sides/#sidedproxy public static void init() { OBJLoader.INSTANCE.addDomain(SlimeRancher.MODID); indigonium = new SlimeRancherItem("indigonium", CreativeTabs.MATERIALS); vacpack = new ItemVacpack(); } Don't instantinate your stuff in pre-init. This is much, much better than using static initializers but you still should instantinate them in the appropriate registry event. Since ObjLoader is a client-only class this code will crash the client server. You must use a proxy. public void registerRender() { ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation(this.getRegistryName(), "inventory")); } IHasModel(yes, it is one even though there is technically no interface like that) is stupid. All items need models, no exceptions and nothing about model registration requires access to private/protected data in the item. Register your models directly in the ModelRegistryEvent. As for your actual issue: From what I can tell the game is looking for the item's json file. I don't know if you can trick it into looking for the obj file directly by manipulation the ModelResourceLocation but you can still use obj models for items if you use forge's blockstates since they can be used for items too. Edited December 4, 20186 yr by V0idWa1k3r
December 4, 20186 yr 4 minutes ago, V0idWa1k3r said: this code will crash the client crash the server* Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
December 4, 20186 yr 6 minutes ago, V0idWa1k3r said: this code will crash the client. 2 minutes ago, larsgerrits said: crash the server* ? 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.
December 4, 20186 yr 8 minutes ago, V0idWa1k3r said: manipulation the ModelResourceLocation What he means by this is, try to append .obj to the end of your path in the model resource location. 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.
December 5, 20186 yr Author 10 hours ago, V0idWa1k3r said: From what I can tell the game is looking for the item's json file. I don't know if you can trick it into looking for the obj file directly by manipulation the ModelResourceLocation but you can still use obj models for items if you use forge's blockstates since they can be used for items too. Thank you for this. I got it working using blockstates and the model is in the game. Now i'm running into the problem of scaling it down (it's absolutely massive). Also when it is in my inventory, the icon is enormous and covers my screen. Where in my json file do I put the "scale" tag? Do I need to make a json for it in my models/item folder as well to scale it down? Here's a link to my blockstate json. Edited December 5, 20186 yr by The_Basset_Hound
December 5, 20186 yr Scale down your model in your model editing software. This actually looks to me like your model editing software used the wrong metrics.
December 5, 20186 yr Author 6 hours ago, V0idWa1k3r said: Scale down your model in your model editing software. This actually looks to me like your model editing software used the wrong metrics. So there's no way to scale it down using forge? I used magicavoxel to create the model and I'm not sure I'm able to scale it down in that. I'd also like to know how to translate and rotate it, like I know you can do when not using blockstates.
December 5, 20186 yr From forge's code I can deduce that you should be able to use a propery by a key of "transform" in your variants. It's value can be 1. a string which is the pointer to a transform specified in code. The defaults are forge:default-block - the block transformation forge:default-item - the item transformation forge:default-tool - a handheld tool-like transformation I don't think you can have your own custom transforms like this though since the map is immutable. 2. a primitive that's not a string. I can't find out how it is deserialized in that case though. 3. a json object that contains keys that specify the transform type (like thirdperson for example) with the values of a TRSRTransformation. I assume those would look like your transforms that you use in json files.
December 5, 20186 yr Author 1 hour ago, V0idWa1k3r said: 3. a json object that contains keys that specify the transform type (like thirdperson for example) with the values of a TRSRTransformation. I assume those would look like your transforms that you use in json files. This looks like it's working thus far. Thank you so much for all of your help. Edited December 5, 20186 yr by The_Basset_Hound
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.