Jump to content

[SOLVED][1.10.2] Changing Item Texture at Runtime


Recommended Posts

Posted

Hello,

 

I'm working on a mod that dynamically creates armor from registered blocks and I'm running into a bit of a snag (again). Currently I am creating, registering, naming, etc. the armor pieces that I want for different blocks dynamically. I've been trying to have each armor piece's inventory icon change to a different texture (that I have) depending on the block that the armor is for, but I haven't made much progress. Normally, an item's inventory texture is assigned in its models/item json, but I don't have the textures until runtime (I think after texture stitching, to be exact), so I can't assign the textures that way.

 

Stuff I've tried:

 

  Reveal hidden contents

 

Of everything I've tried, using the TextureStitchEvent seems the most promising.

 

Does anyone have any idea how I can assign textures to my armor pieces at runtime?

 

Thanks in advance!

Posted

You'll probably need to generate textures and models at runtime like

ModelDynBucket

does.

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.

Posted
  On 12/4/2016 at 12:58 PM, Choonster said:

You'll probably need to generate textures and models at runtime like

ModelDynBucket

does.

 

After a long day of tracing code and trying to understand it, I finally managed to do it using a class similar to ModelDynBucket. Thank you!

 

For anyone else trying to do something similar, I can give you the highlights of how I did it (probably not the best way, but it works):

 

  Reveal hidden contents

 

Some of the code is specific to the mod I'm working on, but hopefully it still helps other people. If you want to see it in context, the mod (currently WIP) is on github: https://github.com/2piradians/Block-Armor

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.