Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

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.

  • 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:

dIQAIZT.png

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?

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.