Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Let's say I have a block with a .obj model that has 3 materials. Each material can be one of 10 textures, giving a total of 1000 different combinations. I can easily instantiate all these blocks with a for loop, but it would be impractical to have separate json files for each version. For the block model, I can pass information to the blockstates json file using the block's IBlockState, but how would I do this for the ItemBlock model?

Edited by theDataSmith

  • Author

If anyone knows how to register the ItemBlock to use [mod]/models/items/[name].json instead of [mod]/blockstates/[name].json I could probably figure it out from there.

1 hour ago, theDataSmith said:

If anyone knows how to register the ItemBlock to use [mod]/models/items/[name].json instead of [mod]/blockstates/[name].json I could probably figure it out from there.

Same way you register any other item model.

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.

  • Author

When I use ModelLoader.setCustomModelResourceLocation to register the model for the ItemBlock, it uses the blockstates json, not the models/item json. How to I make it use the models/item json?

4 hours ago, theDataSmith said:

When I use ModelLoader.setCustomModelResourceLocation to register the model for the ItemBlock, it uses the blockstates json, not the models/item json. How to I make it use the models/item json?

 

Forge tries to load the item model first and only tries to load the model from the blockstates file if that fails. I have a more detailed explanation of the model loading process here.

 

If it's not loading your item models, the FML log should have an error message explaining why.

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.

  • Author

Thank you! That link helped me out a lot. I was thinking I could pass data to the item model json, similarly to a blockstate json, but that appears to be impossible. Does anyone know if there's any way to load models/textures programmatically, rather than using a json?

You can make an ICustomModelLoader.

Point the ResourceLocation to a custom IModel, that points to a custom IBakedModel.

In the IBakedModel's getQuads method, provide the list of BakedQuad's to render for the given side.

Do note, only calculate the BakedQuad's once, and store them somewhere. It's quite expensive to re-calculate every frame.

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

  • Author

After several hours going through source code, I finally figured out how to do it. I had to create an ICustomModelLoader and register it using ModelLoaderRegistry#registerLoader. I then used ModelLoaderRegistry#getModel and cast that IModel to an OBJModel so I could use OBJModel#retexture and OBJModel#process to swap out the textures and add the custom data "flip-v" = "true". That would have been enough, but I also needed different transformations for different item perspectives (GUI, GROUND, FIRST_PERSON_RIGHT_HAND, etc). I had to create my own IModel and IPerspectiveAwareModel classes so I could override IModel#bake and IPerspectiveAwareModel#handlePerective. handlePerspective should always be

 

return MapWrapper.handlePerspective(this, [Your IModelState], cameraTransformType);

 

but you can pass in your own IModelState class to handle the different transform types.

 

Anyway, I wrote this hoping someone would find it helpful. Thanks to Matryoshika for pointing me in the right direction.

Edited by theDataSmith

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.