Jump to content

Rendering Items as Partially Transparent in BlockEntityRenderer


Recommended Posts

I am trying to make some animations for my mod, and one of the steps is rolling out a ball of dough for a pizza. I want to have the rolled out dough slowly fade in, but trying to use RenderSystem#setShaderColor to set the alpha channel does not work how I would expect it to

Spoiler

Trying to set the shader for rendering just the rolled dough (in BlockEntityRenderer#render) 

// dough ball
pPoseStack.pushPose();
itemRenderer.renderStatic(item, ItemDisplayContext.GROUND, getLightLevel(pBlockEntity.getLevel(), pBlockEntity.getBlockPos()), OverlayTexture.NO_OVERLAY, ball.getPizzaBoardPoseStack(pBlockEntity, pPoseStack), pBufferSource, pBlockEntity.getLevel(), 1);
pPoseStack.popPose();

// rolled dough
pPoseStack.pushPose();
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f);
itemRenderer.renderStatic(FoodPart.PIZZA_ROLLED.createItem(), ItemDisplayContext.GROUND, getLightLevel(pBlockEntity.getLevel(), pBlockEntity.getBlockPos()), OverlayTexture.NO_OVERLAY, PizzaBase.getPizzaCounterPoseStack(pBlockEntity, pPoseStack), pBufferSource, pBlockEntity.getLevel(), 1);
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
pPoseStack.popPose();

spacer.png

Spoiler

Not resetting the shader causes all items to render with transparency on every block

// dough ball
pPoseStack.pushPose();
itemRenderer.renderStatic(item, ItemDisplayContext.GROUND, getLightLevel(pBlockEntity.getLevel(), pBlockEntity.getBlockPos()), OverlayTexture.NO_OVERLAY, ball.getPizzaBoardPoseStack(pBlockEntity, pPoseStack), pBufferSource, pBlockEntity.getLevel(), 1);
pPoseStack.popPose();

// rolled dough
pPoseStack.pushPose();
RenderSystem.setShaderColor(1f, 1f, 1f, 0.5f);
itemRenderer.renderStatic(FoodPart.PIZZA_ROLLED.createItem(), ItemDisplayContext.GROUND, getLightLevel(pBlockEntity.getLevel(), pBlockEntity.getBlockPos()), OverlayTexture.NO_OVERLAY, PizzaBase.getPizzaCounterPoseStack(pBlockEntity, pPoseStack), pBufferSource, pBlockEntity.getLevel(), 1);
pPoseStack.popPose();

spacer.png

Is there another way that I am missing to be able to render items on block entities with some transparency?

Edited by Growling_Grizzly
version
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.

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

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