package sourcecoded.quantum.item; 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.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 abstract class ItemQuantum extends Item { public String customName; public List<String> loreList; public ItemQuantum() { loreList = new ArrayList<String>(); this.setCreativeTab(QATabs.quantumTab); } 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) { return "qa.items." + customName; } public String getItemStackDisplayName(ItemStack item) { String translateString = getUnlocalizedName(item) + ".name"; if (hasSubtypes) translateString += "@" + item.getItemDamage(); return LocalizationUtils.translateLocalWithColours(translateString, translateString); } 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++; } } @SuppressWarnings("unchecked") @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean idk) { tryLore(itemStack.getUnlocalizedName(), itemStack); list.addAll(loreList); } }