Jump to content

Recommended Posts

Posted

I have created some glass like armor and would like to have the item and armor opaque when wearing it and when holding it.

Don't really know how to go about this. Any ideas? Thanks.

Posted

Hi

 

You mean transparent some of the time, and opaque the rest of the time?

 

Do you know how to use blending and alpha values?

 

Minecraft generally uses

 

            GL11.glEnable(GL11.GL_BLEND);

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

and

 

            GL11.glDisable(GL11.GL_BLEND);

 

If you're going to change these modes, it's a good idea to wrap it in

 

try {

      GL11.glPushAttrib(GL11.GL_ENABLE_BIT);  // save the current modes

 

  // change modes here, do your rendering

 

} finally {

      GL11.glPopAttrib();  // restore the previous modes

}

 

What does your armor rendering code currently look like?

 

-TGG

 

Posted

Best way to describe what I am wanting is like stained glass. How the item is opaque in your hand and when placed.

I am wanting the armor item to be opaque and armor when worn.

 

Just basic armor class

public class ooArmor extends ItemArmor 
{
public String texture;

public ooArmor(ArmorMaterial mat, String texture, String name, int index, int type) {
	super(mat, index, type);
	this.setUnlocalizedName(name);
	this.texture = texture;
	this.
	this.setCreativeTab(OreOverhaul.tabOreOverhaul);

	GameRegistry.registerItem(this, this.getUnlocalizedName().substring(5));
}

@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
	this.itemIcon = iconRegister.registerIcon(OreOverhaul.modid + ":" + this.getUnlocalizedName().substring(5));
}

@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
{
	if(this.armorType == 2)
	{
		return "oreoverhaul:textures/models/armor/" + this.texture + "2.png";
	}

	return "oreoverhaul:textures/models/armor/" + this.texture + "1.png";

}

}

Posted

OK, I get it now; yeah translucent or semi-opaque or partially transparent.

 

Anyway, I have to admit I'm not sure.

 

The armor rendering code is based in RendererLivingEntity.doRender, in this bit

            for (int i = 0; i < 4; ++i)
            {
                j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_);

                if (j > 0)
                {
                    this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
                    this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);

                    if ((j & 240) == 16)
                    {
                        this.func_82408_c(p_76986_1_, i, p_76986_9_);
                        this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);
                    }

                    if ((j & 15) == 15)
// etc

and in particular,

shouldRenderPass calls your getArmorTexture with type set to null, and then

func_82408_c calls your getArmorTexture with type set to "overlay"  i.e.

public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)

 

shouldRenderPass() is misleading name by the way.  It iterates through each piece of armour and returns flags for whether it's coloured, has an overlay, and whether it has a magical glint.

 

You could perhaps try turning on the blend function GL11.glEnable(GL11.GL_BLEND); in your getArmorTexture (null).  But that might make any other armor items look a bit odd, unless you turn if off again in getArmorTexture("overlay"), which means your armour type would have to be cloth (getColor returns -1).

 

It's a bit of a hack but it might work:

 

            for (int i = 0; i < 4; ++i)
            {
                j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_);  // calls getArmorTexture(null)  ... GL11.glEnable(GL11.GL_BLEND) in here
                                                                                                    // returns 16 or 31 because getColor returns -1  

                if (j > 0)
                {
                    this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
                    this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);               // render your translucent armour

                    if ((j & 240) == 16)
                    {
                        this.func_82408_c(p_76986_1_, i, p_76986_9_);                                       // calls getArmorTexture("overlay")  ... GL11.glDisable(GL11.GL_BLEND) in here
                                                                                                                                      // return a fully transparent texture so nothing is drawn
                        this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, f13, f5);         
                    }

                    if ((j & 15) == 15)
// etc

 

-TGG

 

 

 

 

 

Posted

Think I just got a really close buzz cut from all that flying over my head.. lol

Might be a little much for me at my current skill level..

Posted

Lol.. That armor is kinda just my place holder armor to see if I could get it translucent.

Trust me the 40ish other sets look 100x better than that. lol

 

Got another question. I made a set of redstone armor and thought it would be cool if it could have a particle effect and

dimmly light up the surrounding area when worn. Like when you hit/walkover a redstone ore. Got any pointers for that?

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.