Jump to content

Help with rendering a .obj file to use as an item model


The_Basset_Hound

Recommended Posts

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 by The_Basset_Hound
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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:

 

Thanks for the reply.

Edited by The_Basset_Hound
Link to comment
Share on other sites

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 by V0idWa1k3r
Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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).image.thumb.png.17e1b89b3a78cfa399bb9b4134454cc9.png

 

Also when it is in my inventory, the icon is enormous and covers my screen.

image.thumb.png.f5ad7b96ee814c9277ac2adf9cc6c080.png

 

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 by The_Basset_Hound
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by The_Basset_Hound
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

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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