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

Hi, i have a bunch of item variables based on NBT Tags, so the same item has got more than 100 variables, and its not cool to create 100 json files, which are completely identical with the difference of the texture location, so i was wondering if is there any way to set dynamically the location of the texture.

 

Something like:

public ResourceLocation getTextureLocation(ItemStack stack, int layer)
{
// You stuff
return new ResourceLocation("modid:itemVariable");
}

 

I hope I explained correctly ;D

 

Thanks in advance for helping.

How exactly are your 100 variants stored? In metadata?

 

Yeah, JSON method can make algorithmic model/texture settings a bit complicated.

 

I think you can override the Item#getModel() method to algorithmically reference different models, but I think that still requires a JSON per variant.

 

Note that you can probably make a script (heck probably even just use EXCEL) to create the JSON content for you. Definitely a pain, but as you can see in the default Minecraft asset item JSON models, they went ahead and make a hundred of them.

 

Maybe someone knows a better way though.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

  • Author

How exactly are your 100 variants stored? In metadata?

 

Yeah, JSON method can make algorithmic model/texture settings a bit complicated.

 

I think you can override the Item#getModel() method to algorithmically reference different models, but I think that still requires a JSON per variant.

 

Note that you can probably make a script (heck probably even just use EXCEL) to create the JSON content for you. Definitely a pain, but as you can see in the default Minecraft asset item JSON models, they went ahead and make a hundred of them.

 

Maybe someone knows a better way though.

 

No, they are stored in NBT Tags.

 

Ok, i'll try to find some way to do it.

Hi

 

I suggest - stitch your 100 textures into the block texture sheet, then use ISmartItemModel to modify the baked quads it returns to give the correct [u,v] coordinates for the desired texture.

 

Never tried it.  Should work, but will take a fair bit of experimentation I think.

 

-TGG

  • Author

Hi

 

I suggest - stitch your 100 textures into the block texture sheet, then use ISmartItemModel to modify the baked quads it returns to give the correct [u,v] coordinates for the desired texture.

 

Never tried it.  Should work, but will take a fair bit of experimentation I think.

 

-TGG

 

Ok... excuse me if i'm very ignorant but, how do I get an

ISmartItemModel

as the

ibakedmodel

variable to use the

handleItemState(stack)

later?? Because all the

ibakedmodel

are

IFlexibleBakedModel

(I hope you understood me)

 

<<net.minecraft.client.renderer.ItemModelMesher>>

    public IBakedModel getItemModel(ItemStack stack)
    {
        Item item = stack.getItem();
        IBakedModel ibakedmodel = this.getItemModel(item, this.getMetadata(stack));

        if (ibakedmodel == null)
        {
            ItemMeshDefinition itemmeshdefinition = (ItemMeshDefinition)this.shapers.get(item);

            if (itemmeshdefinition != null)
            {
                ibakedmodel = this.modelManager.getModel(itemmeshdefinition.getModelLocation(stack));
            }
        }

        if(ibakedmodel instanceof net.minecraftforge.client.model.ISmartItemModel)
        {
            ibakedmodel = ((net.minecraftforge.client.model.ISmartItemModel)ibakedmodel).handleItemState(stack);
        }

        if (ibakedmodel == null)
        {
            ibakedmodel = this.modelManager.getMissingModel();
        }

        return ibakedmodel;
    }

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.