package sourcecoded.quantum.item.armor; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import sourcecoded.quantum.Constants; import sourcecoded.quantum.api.translation.LocalizationUtils; import sourcecoded.quantum.inventory.QATabs; import java.util.ArrayList; import java.util.List; import static sourcecoded.core.util.LocalizationUtils.prefix; public class ItemArmorQuantum extends ItemArmor { public ItemArmorQuantum(ArmorMaterial mat, int renderPass, int type) { super(mat, renderPass, type); loreList = new ArrayList<String>(); this.setCreativeTab(QATabs.quantumTab); } public String customName; public List<String> loreList = new ArrayList<String>(); public Item setTextureName(String name) { return super.setTextureName(prefix(Constants.MODID, name)); } public Item setUnlocalizedName(String name) { customName = name; return super.setUnlocalizedName(prefix(Constants.MODID_SHORT, name)); } public String getUnlocalizedName(ItemStack item) { String base = "qa.items." + customName; return base; } public String getItemStackDisplayName(ItemStack item) { String translateString = getUnlocalizedName(item) + ".name"; if (hasSubtypes) translateString += "@" + item.getItemDamage(); String translate = LocalizationUtils.translateLocalWithColours(translateString, translateString); return translate; } public void tryLore(String unlocalizedBase, ItemStack stack) { loreList = new ArrayList<String>(); boolean search = true; int run = 0; while (search) { String formatted = unlocalizedBase + ".lore." + run; if (hasSubtypes) formatted += "@" + stack.getItemDamage(); if (StatCollector.canTranslate(formatted)) { loreList.add(LocalizationUtils.translateLocalWithColours(formatted, "You shouldn't be seeing this, report this please")); } else search = false; run++; } } @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean idk) { tryLore(itemStack.getUnlocalizedName(), itemStack); list.addAll(loreList); } }