Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

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

  • Author

Thanks for your help, but i just got it to work the way i wanted it to :D looked at the code of pahimar's ee3 and sorted out that the int parameter passed to the getColor method is the renderPass.... so all done now

Thanks for helping me <3

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.