sblectric Posted January 24, 2016 Share Posted January 24, 2016 Hi, I'm working on updating my my mod, Everything Blocks (http://minecraft.curseforge.com/projects/everything-blocks), from 1.7.10 to 1.8.9. One feature of the mod is that it takes the average color of an ItemStack's icon and tints the block to match. In 1.7, I could get the file names of these textures with registerIcons() and then load them into an image buffer and average the pixels. However, in 1.8, there is no such functionality. I've looked into the ItemModelGenerator class, and I see how vanilla accesses texture pixels to make a 3D model. However, I do not have access to any instance of ModelBlock to help me. Any ideas? EDIT: Solved thanks to diesieben07! Quote http://minecraft.curseforge.com/members/sblectric/projects Link to comment Share on other sites More sharing options...
RANKSHANK Posted January 24, 2016 Share Posted January 24, 2016 Just some thoughts on what I've seen in the rendering safari: pre blend the textures as custom TextureAtlasSprites during texture stitch eveny, keep track of their string keys. Then use those keys during model bake event to bake the textures into the appropriate models... How many models are you looking at? Quote I think its my java of the variables. Link to comment Share on other sites More sharing options...
sblectric Posted January 24, 2016 Author Share Posted January 24, 2016 I don't know why I'd need to bake, since I'm not rendering a texture on the block, just tinting it (I already have this part working). I just need to be able to access either the ItemStack's texture filepath or its corresponding TextureAtlasSprite. (btw, every non-block item, modded or vanilla is supported to be craftable to the block). Basically, I just need to get the average color of an item's icon dynamically. Quote http://minecraft.curseforge.com/members/sblectric/projects Link to comment Share on other sites More sharing options...
RANKSHANK Posted January 24, 2016 Share Posted January 24, 2016 Ahh that makes sense... It's going to be an excavation since AFAIK Items only have correlation to ModelResourceLocations which contain the texture references. It's worsened by the fact that every Item can have multiple TextureAtlasSprites associated with it in a single ModelResourceLocation for any given metadata/nbt. You could run through the texture map during TextureStitchEvent.Post and average out the loaded sprites there, but you'll probably have to parse through the loaded models to access their corresponding items... Most likely the end result would be a <ModelResourceLocation, IntColor> map that you feed the itemstack's cooresponding model through. Quote I think its my java of the variables. Link to comment Share on other sites More sharing options...
sblectric Posted January 24, 2016 Author Share Posted January 24, 2016 If I could get the ModelResourceLocation from an item stack, that would solve my problems. Unfortunately, it seems that items and models are not very well connected. Quote http://minecraft.curseforge.com/members/sblectric/projects Link to comment Share on other sites More sharing options...
sblectric Posted January 24, 2016 Author Share Posted January 24, 2016 I've tried that, IBakedModel is useless, since for normal items, getItemModel(<itemStack>) will return an instance of the built-in model, which implements IBakedModel. The built-in model returns null for pretty much all of the IBakedModel methods, and even if it didn't, IBakedModel does not reference any useful textures. Quote http://minecraft.curseforge.com/members/sblectric/projects Link to comment Share on other sites More sharing options...
sblectric Posted January 24, 2016 Author Share Posted January 24, 2016 Strange, I get an output like this: TextureAtlasSprite{name='missingno', frameCount=1, rotated=false, x=0, y=0, height=16, width=16, u0=6.25E-4, u1=0.999375, v0=6.25E-4, v1=0.999375} Could it be that I have to do this on a model bake event and not post-init? Quote http://minecraft.curseforge.com/members/sblectric/projects Link to comment Share on other sites More sharing options...
sblectric Posted January 24, 2016 Author Share Posted January 24, 2016 Ah, OK. Thank you so much! This was giving me a headache! Now I'm getting textures! TextureAtlasSprite{name='minecraft:items/seeds_wheat', frameCount=1, rotated=false, x=32, y=288, height=16, width=16, u0=0.06251953, u1=0.09373047, v0=0.56251955, v1=0.59373045} Quote http://minecraft.curseforge.com/members/sblectric/projects Link to comment Share on other sites More sharing options...
sblectric Posted January 24, 2016 Author Share Posted January 24, 2016 On a side-note, this is ending up being a lot less hacky than my 1.7 code was to get the textures... Quote http://minecraft.curseforge.com/members/sblectric/projects Link to comment Share on other sites More sharing options...
Recommended Posts
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.