Posted August 17, 20169 yr So I want to make custom dyeable armor i.e leather armor but whenever I try to set the color with Item#onCreated the armor stays white with seemingly no overlay. Here is my code package com.ashindigo.alloycraft.items; import java.awt.Color; import java.util.List; import com.ashindigo.alloycraft.AlloycraftMain; import com.ashindigo.utils.UtilsArmor; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; // TODO Add wearing color public class AlloyArmor extends ItemArmor { public AlloyArmor(String name, ArmorMaterial material, EntityEquipmentSlot type, String modid) { super(ItemArmor.ArmorMaterial.LEATHER, 0, type); setCreativeTab(AlloycraftMain.alloycrafttab); GameRegistry.register(this, new ResourceLocation(modid, name)); maxStackSize = 1; this.setUnlocalizedName(modid + "_" + name); } @Override public void onCreated(ItemStack stack, World world, EntityPlayer player) { // stack.getTagCompound().getInteger("Strength"), stack.getTagCompound().getInteger("Durability"), stack.getTagCompound().getInteger("Enchantability") ((ItemArmor) stack.getItem()).setColor(stack, new Color( stack.getTagCompound().getInteger("Strength"), stack.getTagCompound().getInteger("Durability"), stack.getTagCompound().getInteger("Enchantability")).getRGB()); if ( ((ItemArmor) stack.getItem()).hasOverlay(stack)) // Allow this for anything, not only cloth { int i = ((ItemArmor) stack.getItem()).getColor(stack); float f = (float)(i >> 16 & 255) / 255.0F; float f1 = (float)(i >> 8 & 255) / 255.0F; float f2 = (float)(i & 255) / 255.0F; System.out.println("Has Overlay!"); System.out.println(f); System.out.println(f1); System.out.println(f2); } System.out.println(this.getColor(stack)); if (stack.getTagCompound() == null) { stack.setTagCompound(new NBTTagCompound()); stack.getTagCompound().setInteger("Durability", 0); stack.getTagCompound().setInteger("Enchantability", 0); stack.getTagCompound().setInteger("Strength", 0); } } public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if (itemStack.getTagCompound() != null) { par3List.add("§4Strength: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Strength"))); par3List.add("§2Durability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Durability"))); par3List.add("§1Enchantability: §7" + Integer.toString(itemStack.getTagCompound().getInteger("Enchantability"))); } } @Override public String getArmorTexture(ItemStack stack, Entity entity, EntityEquipmentSlot slot, String type) { return "textures/models/armor/" + "leather_layer" + "_" + (armorType.getSlotIndex() == 2 ? "2" : "1") + ".png"; } /* @Override public boolean hasOverlay(ItemStack stack) { return true; } */ }
August 17, 20169 yr Where do you actually set the Color Tag? You also need to override hasColor VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 17, 20169 yr Author I'm using ItemArmor#setColor in the onCreated method, and I just overrode hasColor and made it return true. But the armor stays the same with no color. Should I just be creating the display and color tag myself instead of using vanilla methods to do it?
August 17, 20169 yr Unrelated, don't use "§4" use the EnumChatFormatting constants. 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.
August 17, 20169 yr Author Just learned that EnumChatFormatting doesnt exist anymore after trying to find it, it's now called TextFormatting.
August 17, 20169 yr You are trying to set the color before you even have any color set. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 17, 20169 yr Author You are trying to set the color before you even have any color set. I'm probably missing something here but I've been calling setColor in onCreated. Should I b calling it on the client only? ((ItemArmor) stack.getItem()).setColor(stack, new Color(stack.getTagCompound().getInteger("Strength"), stack.getTagCompound().getInteger("Durability"), stack.getTagCompound().getInteger("Enchantability")).getRGB());
August 17, 20169 yr No what I'm saying is onCreated when it is called won't have any color because the NBT doesn't have any color to give it. Have you added crafting recipes yet? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 17, 20169 yr Author I do have recipes in my IRecipe class which will set the tag for the three integers.
August 17, 20169 yr If it is handled in your IRecipe class why do you need onCreated? Post your IRecipe class. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 17, 20169 yr Author My IRecipe class also contains code for the recipes for other items which aren't relevant to the armor so I just posted the main part where the NBT is set. if (invCraft.getStackInSlot(0).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(1).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(2).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(3).getItem() == AlloycraftItems.alloy) { if (invCraft.getStackInSlot(5).getItem() == AlloycraftItems.alloy) { ItemStack alloy1 = invCraft.getStackInSlot(0); ItemStack alloy2 = invCraft.getStackInSlot(1); ItemStack alloy3 = invCraft.getStackInSlot(2); ItemStack alloy4 = invCraft.getStackInSlot(3); ItemStack alloy5 = invCraft.getStackInSlot(5); int prop1 = (int) Math.sqrt(alloy1.getTagCompound().getInteger("Strength") + alloy2.getTagCompound().getInteger("Strength") + alloy3.getTagCompound().getInteger("Strength") + alloy4.getTagCompound().getInteger("Strength") + alloy5.getTagCompound().getInteger("Strength")); int prop2 = (int) Math.sqrt(alloy1.getTagCompound().getInteger("Durability") + alloy2.getTagCompound().getInteger("Durability") + alloy3.getTagCompound().getInteger("Durability") + alloy4.getTagCompound().getInteger("Durability") + alloy5.getTagCompound().getInteger("Durability")); int prop3 = (int) Math.sqrt(alloy1.getTagCompound().getInteger("Enchantability") + alloy2.getTagCompound().getInteger("Enchantability") + alloy3.getTagCompound().getInteger("Enchantability") + alloy4.getTagCompound().getInteger("Enchantability") + alloy5.getTagCompound().getInteger("Enchantability")); result = new ItemStack(AlloycraftItems.alloyhelmet, 1); ((ItemArmor) result.getItem()).setColor(result, 25555555); result.setTagCompound(new NBTTagCompound()); result.getTagCompound().setInteger("Strength", prop1); result.getTagCompound().setInteger("Durability", prop2); result.getTagCompound().setInteger("Enchantability", prop3); ((ItemArmor) result.getItem()).setColor(result, new Color(result.getTagCompound().getInteger("Strength"), result.getTagCompound().getInteger("Durability"), result.getTagCompound().getInteger("Enchantability")).getRGB()); return result; } } } } }
August 17, 20169 yr Ok first off always post all code. Secondly why is this here if you set the color 5-6 lines down and also set the NBT to a new Tag. ((ItemArmor) result.getItem()).setColor(result, 25555555); Are you sure that your Alloy's have those tags? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 17, 20169 yr Alsod you need to override setColor because it checks the armorMaterial after looking at the super method. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 17, 20169 yr Author ((ItemArmor) result.getItem()).setColor(result, 25555555); I completely forgot that existed. And for setColor I'm just setting the material to ItemArmor.ArmorMaterial.LEATHER for now. I'll override right now.
August 18, 20169 yr Author I managed to get it working while I didn't have internet so I'll just mark it as solved.
August 19, 20169 yr Post the solution so other that have this problem can fix it as well. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 22, 20169 yr Author Kind of late but I have some form of internet now so I'll just leave this here. First of all update to the latest forge otherwise this may not work at all. 1st step: Set your color somewhere using ItemArmor#setColor 2nd step: Override hasOverlay, hasColor, setColor, and getColor to remove the ArmorMaterial.LEATHER check which will let you supply your own stats. 3rd step: Override getArmorTexture but you have to supply a different texture based on the type string. (I wont be supplying direct code but if something is confusing let me know)
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.