Posted September 23, 20223 yr I have an entity that uses ItemRenderer::renderStatic to render an item. Now, how would I render an overlay effect, like the mob damage or TNT flashing effects, onto said item? I've tried a lot of different things from the OverlayTexture class but nothing worked.
September 25, 20223 yr So, you're going to need to be more specific. When you say mob damage, are you referring to the durability bar? And flashing effects are only seen in the world.
September 25, 20223 yr Author 30 minutes ago, ChampionAsh5357 said: So, you're going to need to be more specific. When you say mob damage, are you referring to the durability bar? And flashing effects are only seen in the world. I simply mean this effect: This effect is achieved by using TntMinecartRenderer.renderWhiteSolidBlock(this.blockRenderer, this.tntBlock.defaultBlockState(), poseStack, bufferSource, packedLight, i / 5 % 2 == 0); which executes following code int i; if (p_234667_) { i = OverlayTexture.pack(OverlayTexture.u(1.0F), 10); } else { i = OverlayTexture.NO_OVERLAY; } p_234662_.renderSingleBlock(p_234663_, p_234664_, p_234665_, p_234666_, i); but using OverlayTexture.pack(OverlayTexture.u(1.0F), 10); in ItemRenderer::renderStatic like so this.itemRenderer.renderStatic(stack, ItemTransforms.TransformType.FIXED, packedLight, OverlayTexture.pack(OverlayTexture.u(1.0F), 10), poseStack, bufferSource, pos); does not add a white overlay to the rendererd item. Would you know, how to achieve this?
September 27, 20223 yr That's because the item renderer is handled different than the block renderer. The block renderer, for TNT, uses the rendertype_entity_cutout shader, which applies the overlay texture. The item renderer, on the other hand, for a standard item would use rendertype_item_entity_translucent_cull, which while having the field for the overlay texture (denoted as texCoord1), is never used in the fragment shader. You would need to implement part of the rendering code yourself to use a render type or shader with the overlay texture applied. However, if you are only doing this for one model, this could be simply achieved using item properties by having an all white texture.
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.