Jump to content

[1.19.2] Render overlay effect on item


Recommended Posts

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.

Link to comment
Share on other sites

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.

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.


  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Tysm, dont know how I missed that. I saw no dependency info and got confused
    • I am trying to build a custom modpack and I was trying to find my mod's dependencies but it keeps crashing and i cant figure out what is causing it or what the dependencies are. below is the crash report https://pastebin.com/neqwRWeS
    • The version you are using is no longer supported on this forum. Please update to a modern version of Minecraft to receive support. Currently supported versions are 1.19.2 (Latest) and 1.18.2 (LTS).
    • [27Nov2022 00:00:56.274] [main/FATAL] [net.minecraftforge.fml.ModLoader/CORE]: Error during pre-loading phase 211net.minecraftforge.fml.ModLoadingException: Mod §epixelmon§r only supports §3byg§r §o1.3.4 or above§r 212§7Currently, §3byg§r§7 is §o1.1.6 213at net.minecraftforge.fml.ModLoadingException.lambda$fromEarlyException$0(ModLoadingException.java:64) ~[forge:?] 214at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_352] 215at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384) ~[?:1.8.0_352] 216at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_352] 217at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_352] 218at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:1.8.0_352] 219at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:1.8.0_352] 220at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_352] 221at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485) ~[?:1.8.0_352] 222at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:272) ~[?:1.8.0_352] 223at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384) ~[?:1.8.0_352] 224at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_352] 225at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_352] 226at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_352] 227at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_352] 228at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_352] 229at net.minecraftforge.fml.ModLoader.<init>(ModLoader.java:120) ~[forge:?] 230at net.minecraftforge.fml.ModLoader.get(ModLoader.java:154) ~[forge:?] 231at net.minecraftforge.fml.server.ServerModLoader.load(ServerModLoader.java:44) ~[forge:?] 232at net.minecraft.server.Main.main(Main.java:95) ~[?:?] 233at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_352] 234at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_352] 235at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_352] 236at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_352] 237at net.minecraftforge.fml.loading.FMLServerLaunchProvider.lambda$launchService$0(FMLServerLaunchProvider.java:51) ~[forge.jar:36.2] 238at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.1.3.jar:?] 239at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.1.3.jar:?] 240at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.1.3.jar:?] 241at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.1.3.jar:?] 242at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.1.3.jar:?] 243at net.minecraftforge.server.ServerMain$Runner.runLauncher(ServerMain.java:63) [forge.jar:?] 244at net.minecraftforge.server.ServerMain$Runner.access$100(ServerMain.java:60) [forge.jar:?] 245at net.minecraftforge.server.ServerMain.main(ServerMain.java:57) [forge.jar:?]
  • Topics

  • Create New...

Important Information

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