Jump to content

[1.19.2] Render overlay effect on item


Recommended Posts

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?

Link to comment
Share on other sites

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.

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.

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.

  • Create New...

Important Information

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