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.

[1.11.2] Rendering an Item based on NBT

Featured Replies

Posted

I'm trying to make an Item that looks like a block (Has the model of a block with 6 same sides).

The Item should have a NBT tag where the block name and meta is stored (like minecraft:log, 2). It then gets the texture of that block that it is in NBT and applies it to its model.

So in the end I will have a Item that looks like any block and changes its texture based on NBT.

 

How would I go about creating something like this?

The only way I could think of is using block states, but someone will probably reply with a better way.

Edited by Awesome_Spider

I just realized that wasn't what you were asking. Ignore that.

  • Author
22 hours ago, diesieben07 said:

You will need to write a custom model implementation (using ICustomModelLoader, IModel, IBakedModel and ItemOverrideList) and then bake new models on the fly based on contained block's model.

Oh dear, that sounds really complicated... I don't know why, but all model and rendering stuff seems to be the hardest thing about modding to me. Can you maybe try to explain what each of these elements do, or where I can find a tutorial or sample code? I didn't find any.

Edited by Tschipp

  • Author
2 hours ago, diesieben07 said:
  • ICustomModelLoader: Basically what it says on the tin, this is something that knows how to take a model file (from the assets) and read/parse it. For example the OBJ loader knows how to read OBJ files.
  • IModel: A representation of a model's data in code. An IModel cannot be rendered, it merely "knows all the data" about the model, but still allows modification (e.g. retexturing or transformation). This is what's produced from ICustomModelLoader when it loads a model file.
  • IBakedModel: A compact model representation that can be rendered. You obtain this from the IModel and basically it just contains a list of BakedQuads. Every IBakedModel also has an ItemOverrideList associated with it, which allows the model to substitute a different model right before an Item is rendered based on that Item (this is what you need).

As for example, there are quite a few in the Forge codebase.

Thanks, just two more things: How and where do I register all this stuff and can you give me the link to the Forge codebase? I couldn't find it.

  • Author
2 minutes ago, diesieben07 said:

You register your ICustomModelLoader in ModelRegistryEvent using ModelLoaderRegistry.registerLoader.

 

When you set up a MDK workspace you will have Forge as a library available to you. Alternatively you can find the code on Github.

Whoops, I thought you meant acutal examples. 

EDIT: Also, congrats on 5000 rep!

Edited by Tschipp

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.