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

This code works perfectly:

 

 

private static void load_texture(ItemCA item)

    {

        Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getUnlocalizedName().substring(5), "inventory"));

        LogHelper.info("Loading model in '"+item.getUnlocalizedName().substring(5)+"'");

    }

 

 

 

However when I overload this method to handle items with metadata they're rendered as cubes (json model file not loading)

 

 

private static void load_texture(ItemCA item, int metastart, int metaend)

    {

        for(int i=metastart;i<=metaend;i++)

        {

            Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, new ModelResourceLocation(item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5), "inventory"));

            LogHelper.info("Loading model in '" + item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5) + "' for metadata "+i);

        }

    }

 

 

 

Since the first one is working, assets is loading properly etc.

 

The part of log with all the "Loading model..."

 

 

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:coal_piece'

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_white' for metadata 0

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_orange' for metadata 1

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_magenta' for metadata 2

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_lightblue' for metadata 3

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_yellow' for metadata 4

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_lime' for metadata 5

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_pink' for metadata 6

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_gray' for metadata 7

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_lightgray' for metadata 8

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_cyan' for metadata 9

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_purple' for metadata 10

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_blue' for metadata 11

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_brown' for metadata 12

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_green' for metadata 13

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_red' for metadata 14

[17:09:49] [Client thread/INFO] [Coal Age]: Loading model in 'coalage:colored_coal_black' for metadata 15

 

 

 

I'd think that if "coalage:coal_piece" is OK, then "coalage:colored_coal_black" hould work, but it doesn't.

And getUnlocalizedName method is overloaded and works as I want it to. That's proved by the log

  • Author

The ModelBakery.addVariants works great

 

However to load the models I had to use this method:

 

 

for(int i=metastart;i<=metaend;i++)

        {

            Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, new ModelResourceLocation(item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5), "inventory"));

        }

 

 

 

Because the one I fount to be said correct:

 

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item,

                    new ItemMeshDefinition()

                    {

                        public ModelResourceLocation getModelLocation(ItemStack stack)

                        {

                            return new ModelResourceLocation(item.getUnlocalizedName(stack).substring(5), "inventory");

                        }

                    });

 

 

was being called all the time and made a giant mess in the log

The ModelBakery.addVariants works great

 

However to load the models I had to use this method:

 

 

for(int i=metastart;i<=metaend;i++)

        {

            Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, i, new ModelResourceLocation(item.getUnlocalizedName(new ItemStack(item, 1, i)).substring(5), "inventory"));

        }

 

 

 

Because the one I fount to be said correct:

 

 

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item,

                    new ItemMeshDefinition()

                    {

                        public ModelResourceLocation getModelLocation(ItemStack stack)

                        {

                            return new ModelResourceLocation(item.getUnlocalizedName(stack).substring(5), "inventory");

                        }

                    });

 

 

was being called all the time and made a giant mess in the log

yeah, that's how it is supposed to work, it's a technique called a 'function object'.  Every time minecraft wants to know what ModelResourceLocation to use for your itemstack, it calls the getModelLocation() you have given it.  So if you put a println in there, it will print every time it's called, which is a lot.  The solution is not to put a println in there.  Or, adding every single variant (like you have done) works too, since there aren't very many.

 

-TGG

 

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.