Jump to content

[1.7.2] Need help with custom glass!


DarkRattle

Recommended Posts

So first time using forge and the thing is my glass is working BUT in my hand it's not showing as it's texture. It's showing as a full black block. I don't know why. Here are some pics

 

http://gyazo.com/9ae6aac77fd9a4bdaa9f6c9623de98b2

 

here is my code:

 

public class BlockBallisticsGlass extends Block {

public BlockBallisticsGlass() {
	super(Material.glass);
	setBlockName("glass_ballistics");
	setBlockTextureName(DarkPack.MODID + ":" + getUnlocalizedName().substring(5));
	setCreativeTab(CreativeTabs.tabBlock);
	setStepSound(soundTypeGlass);
	setHardness(1.0F);
	setResistance(1000F);
}

public int getBlockTextureFromSideAndMetadata(int i, int j) {
	return 9;
}

public int quantityDropped(Random r) {  
	return 0;
}

@SideOnly(Side.CLIENT)
public int getRenderBlockPass() {
	return 1;
}

public boolean isOpaqueCube() {
	return false;
}

public boolean renderAsNormalBlock() {
	return false;
}

protected boolean canSilkHarvest() {
	return true;
}

}

Link to comment
Share on other sites

Hi

 

From memory, items in your hand are rendered with alpha blending turned off.  So the partially-transparent parts of your block are rendered as totally opaque.

 

You could get around this by implementing an ISimpleBlockRenderingHandler and drawing your icon with alpha blending enabled

eg

 

http://greyminecraftcoder.blogspot.com.au/2013/07/block-rendering.html

 

and

    try {
      GL11.glPushAttrib(GL11.GL_ENABLE_BIT);

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

     // do your rendering here
    } finally {
      GL11.glPopAttrib();
    }

 

-TGG

Link to comment
Share on other sites

Hi

 

From memory, items in your hand are rendered with alpha blending turned off.  So the partially-transparent parts of your block are rendered as totally opaque.

 

You could get around this by implementing an ISimpleBlockRenderingHandler and drawing your icon with alpha blending enabled

eg

 

http://greyminecraftcoder.blogspot.com.au/2013/07/block-rendering.html

 

and

    try {
      GL11.glPushAttrib(GL11.GL_ENABLE_BIT);

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

     // do your rendering here
    } finally {
      GL11.glPopAttrib();
    }

 

-TGG

 

This was the case pre-1.7. Look here: http://puu.sh/8Sq6V.png

Either there's something missing or the vanilla renderer has exceptions for specific blocks (like the stained glass)

 

EDIT: looking at it again, if the renderBlockPass is > 0, it uses blend (look at the doRender method, line 124 in class RenderItem)

 

 

BTW: Always add @Override to methods you intend to override! It shows you errors if you, for example, made a typo somewhere or the method signature changed.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.