Posted June 4, 201510 yr This is what I am trying to accomplish: As you can see, the digits only show in the inventory view, which is what I want. I accomplish this by using a combination of .json item layers and an IPerspectiveAwareModel. Relevant .json / code: // layer_00 json: { "parent": "zeldaswordskills:item/bomb_bag", "textures": { // layer0 is same as parent "layer1": "zeldaswordskills:items/digits/0", // ones place - these are actual separate textures, obviously "layer2": "zeldaswordskills:items/digits/00" // tens place } } // Perspective-aware model which was constructed with the base model (no extra layers) and a dynamically // determined layer model based on the current bombs held, e.g. base_model_layer_00 @Override public Pair<IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { switch (cameraTransformType) { case FIRST_PERSON: RenderItem.applyVanillaTransform(baseModel.getItemCameraTransforms().firstPerson); return Pair.of(baseModel, null); case GUI: // only this one returns the layered model RenderItem.applyVanillaTransform(layeredModel.getItemCameraTransforms().gui); return Pair.of(layeredModel, null); case HEAD: RenderItem.applyVanillaTransform(baseModel.getItemCameraTransforms().head); return Pair.of(baseModel, null); case THIRD_PERSON: RenderItem.applyVanillaTransform(baseModel.getItemCameraTransforms().thirdPerson); return Pair.of(baseModel, null); default: break; } return Pair.of(baseModel, null); } That all works fine. My question is: how can I do this without having to create one .json model for every single possible number of items held, i.e. 00-99 ? I've looked at the various options available, and from what I can see none of them are aware of which layer is being rendered at any given point; if I had access to the current layer (and probably also the current camera transform), I could use that to directly render the digits during the second / third render pass, and leave the first pass as is. Is direct manipulation of the BakedQuads (as shown in TGG's chessboard item tutorial) the only way to do this? If I do it that way, should I still register each of the digit textures, or is it fine to use them directly? http://i.imgur.com/NdrFdld.png[/img]
June 4, 201510 yr In my opinion your best shot is to add 4 BakedQuads (or edit existing ones, explained in edit) like the chessboard does. 4 Quads as in: 1 and 2 digit on front and on back of item. As for textures - you have 2 options: Register 10 textures (atlas sprite) of every digit and use them to make BakedQuads OR use vanilla's Fonts - you can get number texture and draw it as Quad. Problem with layers is the fact that one item.json can have ONLY 5 layers (0-4). That is hardcoded. There might be possibility of editing it tho. "I've looked at the various options available, and from what I can see none of them are aware of which layer is being rendered at any given point" They kinda do. Every BakedQuad has tintIndex - that is your renderPass quad.getTintIndex() is the layerX used to bake quad from item.json. (I think this is what you are after) Sadly as mentioned before - you can only have 5 layers in item. EDIT I got lost in writing this. More clear answer - in getGeneralQuads() you can iterate through "baseItemModel.getGeneralQuads()" and check if BakedQuad has tint index of your layer (1st or 2nd digit). Then you can grab that Quad and change its texture. EDIT 2 Might be useful: front and back face of item is NORTH and SOUTH. (seems like always) 1.7.10 is no longer supported by forge, you are on your own.
June 4, 201510 yr Author Thanks, Ernio. I'll give that a shot later on and reply back with my results. http://i.imgur.com/NdrFdld.png[/img]
June 6, 201510 yr Author I ended up ignoring the layers altogether and going with TGG's wonderfully magical method. Only step I had to take was to subscribe to TextureStitchEvent.Pre and make sure my digit textures got added to the sprite sheet, then return a new model for the GUI view with the number of bombs held set during handleItemState. I was kind of lazy before and actually made 30 textures for the digits, one for each 0-9 for each of three place values, where the digit was offset internally within the texture. It was trivial using TGG's method to cut that down to one texture per digit and simply offset it by an amount based on its place, and now I can even trim the texture sizes down from 16x16 to their actual size (5x7). EDIT: Actually, Minecraft won't let me trim the textures down, complaining about a 'broken aspect ratio' <sigh>. Doesn't matter, though, as I still cut out 20 redundant textures. http://i.imgur.com/NdrFdld.png[/img]
June 6, 201510 yr Hey, this might be very lazy of me, but belive me I tried. Could you please share your repo/code of your TextureStitchEvent.Pre. I want to know how to add texture into sheet. Also - how to find it (the texture) later - talking ab out getting it. I'd really appreciate sharing (can be via priv msg if you want). I really don't know what is what in those atlases stuff and whatever else there it. Thanks. 1.7.10 is no longer supported by forge, you are on your own.
June 6, 201510 yr Author Sure, no problem @SubscribeEvent public void onStitchTexture(TextureStitchEvent.Pre event) { // My textures are in a sub-directory of the items textures directory // but you could do the same for blocks or any other directory within your resources/.../textures location String digit = "items/digits/"; for (int i = 0; i < 9; ++i) { event.map.registerSprite(new ResourceLocation(ModInfo.ID, digit + i)); } } // Then to retrieve the texture for "0": String location = ModInfo.ID + ":items/digits/0"; TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location); http://i.imgur.com/NdrFdld.png[/img]
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.