Jump to content

[1.8] [UNSOLVED] Create/Modify texture location on model json files "on the go"


SackCastellon

Recommended Posts

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.

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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;
    }

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



×
×
  • Create New...

Important Information

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