Jump to content

[1.7.10] [Still needs help] Armor-Similar-to-Leather's Color isn't Changing


Schemex

Recommended Posts

Build: Recommended 1.7.10 (downloaded last week)

 

Background: I am attempting to develop a mod that has many different types of armor.  For convenience purposes, I am going to simply going to recolor one texture, similar to how leather works.

 

However, I have spent hours reading through tons of posts regarding this to no avail.  I have tried reading through the render class for player and I am fairly sure I've implemented it correctly, but, inevitably, it doesn't work.

 

I am able to change the items associated with the armor parts (helmet, chestplate, etc...), but when they are applied to the player, it is the default grey texture I stole from leather armor ( http://i.imgur.com/9r793b0.png ).

 

I am not attempting to use any overlay features.  I just want to recolor my textures.

 

My current code:

package com.betterToolsAndArmor.armor;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.ISpecialArmor;

public class ItemArmorLocalBase extends ItemArmor implements ISpecialArmor {

public ItemArmorLocalBase(ArmorMaterial p_i45325_1_, int p_i45325_2_, int p_i45325_3_) {
	super(p_i45325_1_, p_i45325_2_, p_i45325_3_);
}
@Override
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
	return new ArmorProperties(0, 0, 0);
}

@Override
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
	return 5;
}

@Override
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
	stack.damageItem(damage * 2, entity);		
}

@Override
public String getArmorTexture(ItemStack armor, Entity entity, int slot, String type) {
	if (((ItemArmor) (armor.getItem())).armorType == 2) {
		return modid + ":textures/armor/magic_2.png";
	}
	return modid + ":textures/armor/magic_1.png";
}

public CreativeTabs[] getCreativeTabs() {
	return new CreativeTabs[] {CreativeTabs.tabCombat};
}

public boolean getIsRepairable(ItemStack armor, ItemStack stack) {
	//return stack.getItem() == ModItems.craftableObsidian;
	return false;
}

//the part that actually applies

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

 @Override
 public int getColor(ItemStack item)
 {
	 return 9846527;
 }

 @Override
 @SideOnly(Side.CLIENT)
 public int getColorFromItemStack(ItemStack item, int unUsed)
 {
	 return getColor(item);
 }

 @Override
 public void registerIcons(IIconRegister r)
	{
		itemIcon = r.registerIcon(iconReg);
	}



 //I am fairly sure this is supurfulous
 @Override
	@SideOnly(Side.CLIENT)
	public boolean requiresMultipleRenderPasses()
	{
		return true;
	}

	@Override
	public int getRenderPasses(int metadata)
	{
		// TODO Auto-generated method stub
		return 1;
	}

	@Override
	public IIcon getIcon(ItemStack stack, int pass)
	{
		// TODO Auto-generated method stub
		return itemIcon;
		//return icons[pass];
	}
}

Link to comment
Share on other sites

@SubscribeEvent
public void setArmorModel(RenderPlayerEvent.SetArmorModel evt){
	if(/* is wearing you armor */){
		evt.result = -1;
	}
}

put this in your client event handler and try messing with the result.

I have no idea if this works or not but looking at the source code this is the only way i could find to manipulate the render passes.

Link to comment
Share on other sites

@SubscribeEvent
public void setArmorModel(RenderPlayerEvent.SetArmorModel evt){
	if(/* is wearing you armor */){
		evt.result = -1;
	}
}

put this in your client event handler and try messing with the result.

I have no idea if this works or not but looking at the source code this is the only way i could find to manipulate the render passes.

EDIT 2:

 

I have been playing around with it, trying to find a way to recolor from there, but I haven't found one yet.

 

@SubscribeEvent
public void setArmorModel(RenderPlayerEvent.SetArmorModel event) {
	int color = 9109504;
		float f1 = (float)(color >> 16 & 255) / 255.0F;
            float f2 = (float)(color >> 8 & 255) / 255.0F;
            float f3 = (float)(color & 255) / 255.0F;
            GL11.glColor3f(f1, f2, f3);

}

I wrote the method above just to see if I can use GL1 to recolor it; however, I think this method is called at the wrong time, I am not using GL1 correctly, or there is a better alternative.

 

EDIT 3:

Just a follow up, I tested if the functions are being called by creating a file with the word "test" in it, and, sure enough, when the entity is being rendered, the thread is run (but the color of the armor doesn't change).

 

EDIT 4:

Is there a forge event that is called that could simply change the color of the texture when the texture is first initialized?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Slot depo 5k merupakan situs slot depo 5k yang menyediakan slot minimal deposit 5rb atau 5k via dana yang super gacor, dimana para pemain hanya butuh modal depo sebesar 5k untuk bisa bermain di link slot gacor thailand terbaru tahun 2024 yang gampang menang ini.   DAFTAR & LOGIN AKUN PRO SLOT DEPO 5K ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit 3000 adalah situs slot deposit 3000 via dana yang super gacor dimana para pemain dijamin garansi wd hari ini juga hanya dengan modal receh berupa deposit sebesar 3000 baik via dana, ovo, gopay maupun linkaja untuk para pemain pengguna e-wallet di seluruh Indonesia.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT 3000 ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • OLXTOTO: Menikmati Sensasi Bermain Togel dan Slot dengan Aman dan Mengasyikkan Dunia perjudian daring terus berkembang dengan cepat, dan salah satu situs yang telah menonjol dalam pasar adalah OLXTOTO. Sebagai platform resmi untuk permainan togel dan slot, OLXTOTO telah memenangkan kepercayaan banyak pemain dengan menyediakan pengalaman bermain yang aman, adil, dan mengasyikkan. DAFTAR OLXTOTO DISINI <a href="https://imgbb.com/"><img src="https://i.ibb.co/GnjSVpx/daftar1-480x480.webp" alt="daftar1-480x480" border="0" /></a> Keamanan Sebagai Prioritas Utama Salah satu aspek utama yang membuat OLXTOTO begitu menonjol adalah komitmennya terhadap keamanan pemain. Dengan menggunakan teknologi enkripsi terkini, situs ini memastikan bahwa semua informasi pribadi dan keuangan para pemain tetap aman dan terlindungi dari akses yang tidak sah. Beragam Permainan yang Menarik Di OLXTOTO, pemain dapat menemukan beragam permainan yang menarik untuk dinikmati. Mulai dari permainan klasik seperti togel hingga slot modern dengan fitur-fitur inovatif, ada sesuatu untuk setiap selera dan preferensi. Grafik yang memukau dan efek suara yang mengagumkan menambah keseruan setiap putaran. Peluang Menang yang Tinggi Salah satu hal yang paling menarik bagi para pemain adalah peluang menang yang tinggi yang ditawarkan oleh OLXTOTO. Dengan pembayaran yang adil dan peluang yang setara bagi semua pemain, setiap taruhan memberikan kesempatan nyata untuk memenangkan hadiah besar. Layanan Pelanggan yang Responsif Tim layanan pelanggan OLXTOTO siap membantu para pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Dengan layanan yang ramah dan responsif, pemain dapat yakin bahwa mereka akan mendapatkan bantuan yang mereka butuhkan dengan cepat dan efisien. Kesimpulan OLXTOTO telah membuktikan dirinya sebagai salah satu situs terbaik untuk penggemar togel dan slot online. Dengan fokus pada keamanan, beragam permainan yang menarik, peluang menang yang tinggi, dan layanan pelanggan yang luar biasa, tidak mengherankan bahwa situs ini telah menjadi pilihan utama bagi banyak pemain. Jadi, jika Anda mencari pengalaman bermain yang aman, adil, dan mengasyikkan, jangan ragu untuk bergabung dengan OLXTOTO hari ini dan rasakan sensasi kemenangan!
    • Slot deposit dana adalah situs slot deposit dana yang juga menerima dari e-wallet lain seperti deposit via dana, ovo, gopay & linkaja terlengkap saat ini, sehingga para pemain yang tidak memiliki rekening bank lokal bisa tetap bermain slot dan terbantu dengan adanya fitur tersebut.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
    • Slot deposit dana adalah situs slot deposit dana minimal 5000 yang dijamin garansi super gacor dan gampang menang, dimana para pemain yang tidak memiliki rekening bank lokal tetap dalam bermain slot dengan melakukan deposit dana serta e-wallet lainnya seperti ovo, gopay maupun linkaja lengkap. Agar para pecinta slot di seluruh Indonesia tetap dapat menikmati permainan tanpa halangan apapun khususnya metode deposit, dimana ketersediaan cara deposit saat ini yang lebih beragam tentunya sangat membantu para pecinta slot.   DAFTAR & LOGIN AKUN PRO SLOT DEPOSIT DANA ⭐⭐⭐ KLIK DISINI ⭐⭐⭐  
  • Topics

×
×
  • Create New...

Important Information

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