Jump to content

[SOLVED][1.7.2] Problems with multilayered item textures and coded coloring


Kant0sh

Recommended Posts

I want to create an item that has a very specific part colored by code, a bit like dyed leather armor, using a greyscale texture for coloring in, and an overlay with permanent colors. I got the basic multilayering done using two render passes, but the coloring is off when the item is held in the players hand, 3rd and 1st person... it's basically the wrong way around :( any advice would be much appreciated! Thanks

Screenshot : http://i.imgur.com/sYUfUsB.png

Item class :

package mod3DPrinter.item;

import mod3DPrinter.mod.Mod3DPrinter;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class FilamentItem extends DefaultItem {

private IIcon[] icons;
private String regname;

private int color;

private int c;

public FilamentItem(String regname) {
	super(Mod3DPrinter.printerTab);
	this.regname = regname;

	this.color = 0xffffff;
	this.c = 0;

}

@SideOnly(Side.CLIENT)
public int getColorFromItemStack(ItemStack par1ItemStack, int par2)
{
	return color;
}

@Override
@SideOnly(Side.CLIENT)
public boolean requiresMultipleRenderPasses()
{
	return true;
}

@Override
public int getRenderPasses(int meta){
	return 2;
}

@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister iconRegister)
{
	icons = new IIcon[2];

	icons[0] = iconRegister.registerIcon(Mod3DPrinter.MODID + ":" + regname);
	icons[1] = iconRegister.registerIcon(Mod3DPrinter.MODID + ":" + regname + "_overlay");
}

@Override
public IIcon getIcon(ItemStack itemStack, int renderPass)
{
	if(renderPass == 0){
		color = 0xff0000;
	}else{
		color = 0xffffff;
	}
	return icons[renderPass];
}

}

Thanks for helping me <3

Link to comment
Share on other sites

Hi

 

I don't know why your rendering is swapping the colours around in different views.  I'd suggest that you can fix it by using an IItemRenderer.  It's a bit more effort but gives you a lot more control over rendering in different views.  A quick google should show up several tutorials on it.

 

-TGG

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.