Jump to content

How to make colored armor


tattyseal

Recommended Posts

Hello, I am trying to make colored armor but I cant get it working, even though it renders the color in the item, it does not when you wear it.

 

 

 

 

package org.zaet.api.armor;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

import org.zaet.api.ZaetRegistry;

public class ColoredArmor extends ItemArmor
{
public static final int helm = 0, chest = 1, legs = 2, boots = 3;

public String folder;
public String armorName;
public int color;

public ColoredArmor(int color, String folder, String armorName, ArmorMaterial material, int render, int type, CreativeTabs tab)
{
	super(material, render, type);
	this.color = color;
	this.folder = folder;
	this.armorName = armorName;
	setTextureName(folder + ":" + armorName + "_" + type);
	setUnlocalizedName(folder + "_" + armorName + "_" + type + color);
	setCreativeTab(tab);
}

@Override
public void registerIcons(IIconRegister r)
{
	this.itemIcon = r.registerIcon(folder + ":" + armorName + "_" + armorType);
}

 @Override
 public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
 {
	switch(this.armorType)
	{
	case helm: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	case chest: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	case legs: return folder + ":" + "textures/armor/" + armorName + "_2" + ".png";
	case boots: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	default: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	}
}

 @Override
 public boolean hasColor(ItemStack item)
 {
	 return true;
 }

 @Override
 public int getColor(ItemStack item)
 {
	 return ZaetRegistry.getColorHexCode(color);
 }

 @Override
 public int getColorFromItemStack(ItemStack item, int unUsed)
 {
	 return getColor(null);
 }
}


 

 

 

 

Xm5yuaJ.png

 

Does anyone have any ideas?

Link to comment
Share on other sites

Hmm.

 

Looks like what you have is right....

 

I managed to get it working.  Not sure what I have that you don't.

 

https://github.com/Draco18s/Artifacts/blob/master/draco18s/artifacts/item/ItemArtifactArmor.java

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.

Link to comment
Share on other sites

Updated the OP with an image and updated code

 

 

 

 

package org.zaet.api.armor;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;

import org.zaet.api.ZaetRegistry;

public class ColoredArmor extends ItemArmor
{
public static final int helm = 0, chest = 1, legs = 2, boots = 3;

public String folder;
public String armorName;
public int color;

public ColoredArmor(int color, String folder, String armorName, ArmorMaterial material, int render, int type, CreativeTabs tab)
{
	super(material, render, type);
	this.color = color;
	this.folder = folder;
	this.armorName = armorName;
	setTextureName(folder + ":" + armorName + "_" + type);
	setUnlocalizedName(folder + "_" + armorName + "_" + type + color);
	setCreativeTab(tab);
}

@Override
public void registerIcons(IIconRegister r)
{
	this.itemIcon = r.registerIcon(folder + ":" + armorName + "_" + armorType);
}

 @Override
 public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
 {
	switch(this.armorType)
	{
	case helm: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	case chest: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	case legs: return folder + ":" + "textures/armor/" + armorName + "_2" + ".png";
	case boots: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	default: return folder + ":" + "textures/armor/" + armorName + "_1" + ".png";
	}
}

 @Override
 public boolean hasColor(ItemStack item)
 {
	 return true;
 }

 @Override
 public int getColor(ItemStack item)
 {
	 return ZaetRegistry.getColorHexCode(color);
 }

 @Override
 public int getColorFromItemStack(ItemStack item, int unUsed)
 {
	 return getColor(null);
 }
}


 

 

 

 

Xm5yuaJ.png

Link to comment
Share on other sites

ZaetRegistry.registerColoredArmor("zaet", "dyeArmor", ArmorMaterial.CLOTH, tabZaetMech);

 

public static void registerColoredArmor(String folder, String name, ArmorMaterial material, CreativeTabs creativeTabs)
{
	for(int i = 0; i < 16; i++)
	{
		for(int x = 0; x < 4; x++)
		{
			Item armor = new ColoredArmor(i, folder, name, material, 0, x, creativeTabs);
			GameRegistry.registerItem(armor, armor.getUnlocalizedName());
		}
	}

Link to comment
Share on other sites

ZaetRegistry.registerColoredArmor("zaet", "dyeArmor", ArmorMaterial.CLOTH, tabZaetMech);

 

public static void registerColoredArmor(String folder, String name, ArmorMaterial material, CreativeTabs creativeTabs)
{
	for(int i = 0; i < 16; i++)
	{
		for(int x = 0; x < 4; x++)
		{
			Item armor = new ColoredArmor(i, folder, name, material, 0, x, creativeTabs);
			GameRegistry.registerItem(armor, armor.getUnlocalizedName());
		}
	}

 

I assume CLOTH is leather

Link to comment
Share on other sites

I assume CLOTH is leather

 

It is.  Minecraft is weird like that sometimes.  Like diamond picks using ToolMaterial.EMERALD.

 

Anyway, I have no idea....

 

 

Actually wait.

 

I do.

 

Your PNGs.  Do you have a regular and an overlay texture?  I assume so.

 

The regular is the one that gets colorized.  The overlay is then rendered after with no color adjustment.  I think that might be your problem.

 

And yes, it's a total nuisance.  But that's how the armor renderer was written.

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.

Link to comment
Share on other sites

Yes.

 

But my point is that the "overlay" layer needs to be transparent.

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.

Link to comment
Share on other sites

Not easily.  You'd probably have to write your own renderer.  Just swap your pngs and it'll work.

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.

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.