juliand665 Posted May 5, 2013 Posted May 5, 2013 This problem has been fixed. You need to enable the alpha drawing like this: GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); model.renderModelPart(); GL11.glDisable(GL11.GL_BLEND); then it will work. Make sure to render the Transparent part after Everything else! Hi there, in my mod I have a wine barrel, and I'd like the wine in the barrel to be transparent but still render the (then visible) parts of the block behind it. Here, have some screenshots of what happens with render pass 1: And with render pass 0: As you can see, it isn't rendering the parts of the block behind the wine, and on render pass 0, it just looks plain ugly. Is there a way to do this, and if so, how? Have my code: BlockWineBarrel: package jcraft.common; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class BlockWineBarrel extends Block { private int index; public int color = 0xffffff; protected BlockWineBarrel(int i) { super(i, Material.wood); setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean renderAsNormalBlock() { return false; } public int getRenderBlockPass() { return 1; } /** * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity */ public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.3125F, 1.0F); super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); float f = 0.125F; this.setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F); super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f); super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); this.setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); this.setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F); super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity); this.setBlockBoundsForItemRender(); } public void setBlockBoundsForItemRender() { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public int getRenderType() { return JCraft.renderIdBarrel; } public boolean isOpaqueCube() { return false; } @Override public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int ll, float m, float n, float o) { if(world.isRemote) return true; ItemStack itemstack = entityplayer.inventory.getCurrentItem(); if (itemstack != null && itemstack.itemID == JCraft.grape.itemID && itemstack.stackSize >= 4) { itemstack.stackSize -= 4; if (itemstack.stackSize <= 0) { entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null); } int l = world.getBlockMetadata(i, j, k); if (l < 6) { world.setBlock(i, j, k, blockID, l + 1, 3); } else { entityplayer.addChatMessage("\2475This Wine Barrel is full!"); entityplayer.addChatMessage("\2476Use a Wine Glass to empty."); } } else if (itemstack != null && itemstack.itemID == JCraft.wineGlass.itemID) { int i1 = world.getBlockMetadata(i, j, k); if (i1 > 0) { itemstack.itemID = JCraft.wineGlassFull.itemID; world.setBlock(i, j, k, world.getBlockId(i, j, k), i1 - 1, 3); } else { entityplayer.addChatMessage("\2475The Wine Barrel is empty!"); entityplayer.addChatMessage("\2476Use at least 4 Grapes to fill it up."); } } else { entityplayer.addChatMessage("\2471You have to use a stack of 4 or more Grapes to fill the Barrel"); } return true; } public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5) { return true; } } RenderHandlerBarrel: package jcraft.client; import jcraft.common.JCraft; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderEngine; import net.minecraft.client.renderer.Tessellator; import net.minecraft.src.ModLoader; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderHandlerBarrel implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int i, int modelID, RenderBlocks renderblocks) { renderblocks.setOverrideBlockTexture(Block.blocksList[5].getBlockTextureFromSide(0)); for (int k = 0; k < 5; k++) { if (k == 0) { renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); } if (k == 1) { renderblocks.setRenderBounds(0.0F, 0.25F, 0.0F, 0.125F, 1.0F, 1.0F); } if (k == 2) { renderblocks.setRenderBounds(0.875F, 0.25F, 0.0F, 1.0F, 1.0F, 1.0F); } if (k == 3) { renderblocks.setRenderBounds(0.125F, 0.25F, 0.0F, 0.875F, 1.0F, 0.125F); } if (k == 4) { renderblocks.setRenderBounds(0.125F, 0.25F, 0.875F, 0.875F, 1.0F, 1.0F); } Tessellator tessellator = Tessellator.instance; GL11.glTranslatef(-0.5F, -0.5F, -0.5F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, -1F, 0.0F); renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, i)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, i)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, -1F); renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, i)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 0.0F, 1.0F); renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, i)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(-1F, 0.0F, 0.0F); renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, i)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 0.0F, 0.0F); renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, i)); tessellator.draw(); GL11.glTranslatef(0.5F, 0.5F, 0.5F); } renderblocks.clearOverrideBlockTexture(); } @Override public boolean renderWorldBlock(IBlockAccess iblockaccess, int i, int j, int k, Block block, int l, RenderBlocks renderblocks) { int m = iblockaccess.getBlockMetadata(i, j, k); RenderEngine renderengine = ModLoader.getMinecraftInstance().renderEngine; Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); float f = iblockaccess.getBlockMetadata(i, j, k); renderblocks.setOverrideBlockTexture(Block.blocksList[5].getBlockTextureFromSide(0)); renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F); renderblocks.renderStandardBlock(block, i, j, k); renderblocks.setRenderBounds(0.0F, 0.25F, 0.0F, 0.125F, 1.0F, 1.0F); renderblocks.renderStandardBlock(block, i, j, k); renderblocks.setRenderBounds(0.875F, 0.25F, 0.0F, 1.0F, 1.0F, 1.0F); renderblocks.renderStandardBlock(block, i, j, k); renderblocks.setRenderBounds(0.125F, 0.25F, 0.0F, 0.875F, 1.0F, 0.125F); renderblocks.renderStandardBlock(block, i, j, k); renderblocks.setRenderBounds(0.125F, 0.25F, 0.875F, 0.875F, 1.0F, 1.0F); renderblocks.renderStandardBlock(block, i, j, k); renderblocks.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); renderblocks.setOverrideBlockTexture(block.getIcon(0, i)); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); renderblocks.setRenderBounds(0.125F, 0.24F, 0.125F, 0.875F, 0.24F + 0.125F * f, 0.875F); renderblocks.renderStandardBlock(block, i, j, k); renderblocks.clearOverrideBlockTexture(); return true; } @Override public boolean shouldRender3DInInventory() { return true; } @Override public int getRenderId() { return JCraft.renderIdBarrel; } } And I also have another problem, which is that the specially rendered blocks have been rendering without lighting effects in the GUI since 1.5.2: (Too lazy to open up a new thread) Quote
LordFokas Posted May 6, 2013 Posted May 6, 2013 I don't know if you've ever made wine in real life (I have) but with render pass 1 the wine looks really thin, like water. In my country you can barely see through a cup of wine, if you can even see at all. I think render pass 0 looks accurate, especially for a small barrel. on a technical point of view, that's an engine issue, there's no fixing it. Quote Did I help? Hitting 'Thank You' would be appreciated. Soon, the lost city will rise from the bottom of the ocean, and spread it's technology across Minecraft.
Busti Posted May 6, 2013 Posted May 6, 2013 You need to enable the alpha drawing like this: GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); model.renderModelPart(); GL11.glDisable(GL11.GL_BLEND); then it will work. Make sure to render the Transparent part after Everything else! Quote PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.
juliand665 Posted May 8, 2013 Author Posted May 8, 2013 I don't know if you've ever made wine in real life (I have) but with render pass 1 the wine looks really thin, like water. In my country you can barely see through a cup of wine, if you can even see at all. I think render pass 0 looks accurate, especially for a small barrel. on a technical point of view, that's an engine issue, there's no fixing it. Well yeah, It would be a lot thicker. But it just looks fabulous when it's transparent! Quote
Draco18s Posted May 8, 2013 Posted May 8, 2013 Your problem is that you only have 1 "bottom" quad, which you're drawing your wine texture on. Right now your barrels inside faces get shorter as you add wine, which is why you can't see the inside walls when you render as transparent. What you need is to draw using render pass 1, but add another quad that is the surface of your wine. That quad will change based on your metadata, but the rest of your barrel won't. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
juliand665 Posted May 8, 2013 Author Posted May 8, 2013 You need to enable the alpha drawing like this: GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); model.renderModelPart(); GL11.glDisable(GL11.GL_BLEND); then it will work. Make sure to render the Transparent part after Everything else! Wow, thanks! adding to post Quote
juliand665 Posted May 8, 2013 Author Posted May 8, 2013 Your problem is that you only have 1 "bottom" quad, which you're drawing your wine texture on. Right now your barrels inside faces get shorter as you add wine, which is why you can't see the inside walls when you render as transparent. What you need is to draw using render pass 1, but add another quad that is the surface of your wine. That quad will change based on your metadata, but the rest of your barrel won't. That's actually exactly the way it is. It worked with Busti's solution and the bottom of the barrel (wood) is still visible Quote
Draco18s Posted May 8, 2013 Posted May 8, 2013 That's actually exactly the way it is. It worked with Busti's solution and the bottom of the barrel (wood) is still visible Wasn't able to tell. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Recommended Posts
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.