Jump to content

[1.8.9] How to render semi-transparent


MrRiegel

Recommended Posts

How can I render blocks and items semi-transparent?

 

I should look like this:

1DNnAxt.png

 

(the right one)

6IiBLfQ.png

 

this.bindTexture(TextureMap.locationBlocksTexture);
BlockRendererDispatcher blockrendererdispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
World world = te.getWorld();
BlockPos blockpos = te.getPos();
IBlockState iblockstate = te.getCover().getStateFromMeta(te.getCoverMeta());

GlStateManager.pushMatrix();
RenderHelper.disableStandardItemLighting();
GlStateManager.translate((float) x, (float) y, (float) z);

Tessellator tessellator = Tessellator.getInstance();
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

int i = blockpos.getX();
int j = blockpos.getY();
int k = blockpos.getZ();

worldrenderer.setTranslation(((-i)), (-j), ((-k)));
worldrenderer.color(1F, 1F, 1F, 1F);
IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(iblockstate, world, blockpos);
blockrendererdispatcher.getBlockModelRenderer().renderModel(world, ibakedmodel, iblockstate, blockpos, worldrenderer, true);

worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();

 

GlStateManager.pushMatrix();
GlStateManager.disableLighting();
GlStateManager.disableDepth();
int j1 = 150;
int k1 = 35;
GlStateManager.colorMask(true, true, true, false);
RenderHelper.enableGUIStandardItemLighting();
GlStateManager.color(1f, 1f, 1f, 1f);
ItemStack result = CraftingManager.getInstance().findMatchingRecipe(((ContainerCrafter) inventorySlots).crafter.getMatrix(), mc.theWorld);
mc.getRenderItem().renderItemAndEffectIntoGUI(result, j1, k1);
RenderHelper.disableStandardItemLighting();
GlStateManager.colorMask(true, true, true, true);
GlStateManager.enableLighting();
GlStateManager.enableDepth();
GlStateManager.popMatrix();

Link to comment
Share on other sites

First, your texture needs to have an alpha layer - you can add these via GIMP or PhotoShop pretty easily.

 

Then, when rendering, you need to enable the alpha layer:

// first push attributes, like pushing the matrix, so you don't mess up anything
// that renders after your block
GlStateManager.pushAttrib();

// enable alpha and blend so you can render your alpha layer
GlStateManager.enableAlpha();
GlStateManager.enableBlend();

// render your stuff here

// finally, pop to return the attributes back to their original state
GlStateManager.popAttrib();

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.

Announcements



×
×
  • Create New...

Important Information

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