<commit_before>package net.mcft.copy.betterstorage.addon.thaumcraft;

import java.util.List;

import net.mcft.copy.betterstorage.item.ItemBackpack;
import net.mcft.copy.betterstorage.misc.Constants;
import net.mcft.copy.betterstorage.utils.StackUtils;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
import thaumcraft.api.IRepairable;
import thaumcraft.api.IRepairableExtended;
import thaumcraft.api.IVisDiscountGear;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemThaumcraftBackpack extends ItemBackpack implements IRepairable, IVisDiscountGear {
	
	public ItemThaumcraftBackpack(int id) {
		super(id, ItemBackpack.material);
		setMaxDamage(288);
	}
	
	@Override
	public String getBackpackName() { return Constants.containerThaumcraftBackpack; }
	
	@Override
	public int getBackpackColumns() { return 13; }
	
	@Override
	protected int getDefaultColor() { return -1; }
	
	@Override
	public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
		return ThaumcraftResources.thaumcraftBackpackTexture.toString();
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public EnumRarity getRarity(ItemStack stack) { return EnumRarity.uncommon; }
	
	@Override
	@SideOnly(Side.CLIENT)
	public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advancedTooltips) {
		super.addInformation(stack, player, list, advancedTooltips);
		list.add(String.format("5%s: %s%%", StatCollector.translateToLocal("tc.visdiscount"), 2));
	}
	
	@Override
	public int getItemEnchantability() { return 25; }
	
	@Override
	public boolean getIsRepairable(ItemStack stack, ItemStack repairMaterial) {
		return StackUtils.matches(stack, ThaumcraftAddon.fabric, false);
	}
	
	@Override
	public void onEquippedUpdate(EntityLivingBase entity, ItemStack backpack) {
		super.onEquippedUpdate(entity, backpack);
		if (!entity.worldObj.isRemote && (entity instanceof EntityPlayer))
			repairItems(backpack, (EntityPlayer)entity);
	}
	
	/* TODO: Readd flux effects.
	
	private void createFlux(EntityPlayer player, ItemStack backpack) {
		
		// Every 5 seconds.
		if (player.ticksExisted % 100 != 0) return;
		
		// Count items over normal backpack capacity.
		IInventory inventory = ItemBackpack.getBackpackItems(player);
		int count = -(getRows() * 9);
		for (int i = 0; i < inventory.getSizeInventory(); i++)
			if (inventory.getStackInSlot(i) != null) count++;
		
		// When count <= 0, return.
		// When count = 1, chance is ~2%.
		// When count = 12, chance is 25%.
		if (RandomUtils.getInt(48) > count) return;
		
		int auraId = ThaumcraftApi.getClosestAuraWithinRange(player.worldObj, player.posX, player.posY, player.posZ, 640);
		if (auraId == -1) return;
		ThaumcraftApi.queueNodeChanges(auraId, 0, 0, false, (new ObjectTags()).add(EnumTag.VOID, 3), 0, 0, 0);
		
	}
	
	private void fluxEffects(EntityPlayer player, ItemStack backpack) {
		
		// Every 10 seconds.
		if (player.ticksExisted % 200 != 0) return;
		
		BackpackFluxEffect effect = (BackpackFluxEffect)FluxEffect.pick(
				BackpackFluxEffect.effects, player.worldObj, player.posX, player.posY, player.posZ);
		if (effect == null) return;
		effect.apply(player, backpack);
		
	}
	*/
	
	public void repairItems(ItemStack stack, EntityPlayer player) {
		
		int time = 30 * 20;
		IInventory backpackInventory = ItemBackpack.getBackpackItems(player);
		int backpackRepair = EnchantmentHelper.getEnchantmentLevel(ThaumcraftApi.enchantRepair, stack);
		if ((backpackRepair <= 0) || ((player.ticksExisted % time) > 0)) return;
		
		for (int i = 0; i < backpackInventory.getSizeInventory(); i++) {
			ItemStack itemStack = backpackInventory.getStackInSlot(i);
			if (itemStack == null) continue;
			Item item = itemStack.getItem();
			int repair = EnchantmentHelper.getEnchantmentLevel(ThaumcraftApi.enchantRepair, itemStack);
			if (!(item instanceof IRepairable) || (repair <= 0) ||
			    ((item instanceof IRepairableExtended) &&
			     !((IRepairableExtended)item).doRepair(itemStack, player, repair))) continue;
			itemStack.setItemDamage(Math.max(itemStack.getItemDamage() - repair, 0));
		}
		
	}
	
	// IVisDiscountGear implementation
	
	@Override
	public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect) { return 2; }
	
}
<commit_msg>Fix vis discout tooltip color<commit_after>package net.mcft.copy.betterstorage.addon.thaumcraft;

import java.util.List;

import net.mcft.copy.betterstorage.item.ItemBackpack;
import net.mcft.copy.betterstorage.misc.Constants;
import net.mcft.copy.betterstorage.utils.StackUtils;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import thaumcraft.api.IRepairable;
import thaumcraft.api.IRepairableExtended;
import thaumcraft.api.IVisDiscountGear;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.aspects.Aspect;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ItemThaumcraftBackpack extends ItemBackpack implements IRepairable, IVisDiscountGear {
	
	public ItemThaumcraftBackpack(int id) {
		super(id, ItemBackpack.material);
		setMaxDamage(288);
	}
	
	@Override
	public String getBackpackName() { return Constants.containerThaumcraftBackpack; }
	
	@Override
	public int getBackpackColumns() { return 13; }
	
	@Override
	protected int getDefaultColor() { return -1; }
	
	@Override
	public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
		return ThaumcraftResources.thaumcraftBackpackTexture.toString();
	}
	
	@Override
	@SideOnly(Side.CLIENT)
	public EnumRarity getRarity(ItemStack stack) { return EnumRarity.uncommon; }
	
	@Override
	@SideOnly(Side.CLIENT)
	public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advancedTooltips) {
		super.addInformation(stack, player, list, advancedTooltips);
		list.add(String.format("%s%s: %s%%", EnumChatFormatting.DARK_PURPLE,
		                       StatCollector.translateToLocal("tc.visdiscount"), 2));
	}
	
	@Override
	public int getItemEnchantability() { return 25; }
	
	@Override
	public boolean getIsRepairable(ItemStack stack, ItemStack repairMaterial) {
		return StackUtils.matches(stack, ThaumcraftAddon.fabric, false);
	}
	
	@Override
	public void onEquippedUpdate(EntityLivingBase entity, ItemStack backpack) {
		super.onEquippedUpdate(entity, backpack);
		if (!entity.worldObj.isRemote && (entity instanceof EntityPlayer))
			repairItems(backpack, (EntityPlayer)entity);
	}
	
	/* TODO: Readd flux effects.
	
	private void createFlux(EntityPlayer player, ItemStack backpack) {
		
		// Every 5 seconds.
		if (player.ticksExisted % 100 != 0) return;
		
		// Count items over normal backpack capacity.
		IInventory inventory = ItemBackpack.getBackpackItems(player);
		int count = -(getRows() * 9);
		for (int i = 0; i < inventory.getSizeInventory(); i++)
			if (inventory.getStackInSlot(i) != null) count++;
		
		// When count <= 0, return.
		// When count = 1, chance is ~2%.
		// When count = 12, chance is 25%.
		if (RandomUtils.getInt(48) > count) return;
		
		int auraId = ThaumcraftApi.getClosestAuraWithinRange(player.worldObj, player.posX, player.posY, player.posZ, 640);
		if (auraId == -1) return;
		ThaumcraftApi.queueNodeChanges(auraId, 0, 0, false, (new ObjectTags()).add(EnumTag.VOID, 3), 0, 0, 0);
		
	}
	
	private void fluxEffects(EntityPlayer player, ItemStack backpack) {
		
		// Every 10 seconds.
		if (player.ticksExisted % 200 != 0) return;
		
		BackpackFluxEffect effect = (BackpackFluxEffect)FluxEffect.pick(
				BackpackFluxEffect.effects, player.worldObj, player.posX, player.posY, player.posZ);
		if (effect == null) return;
		effect.apply(player, backpack);
		
	}
	*/
	
	public void repairItems(ItemStack stack, EntityPlayer player) {
		
		int time = 30 * 20;
		IInventory backpackInventory = ItemBackpack.getBackpackItems(player);
		int backpackRepair = EnchantmentHelper.getEnchantmentLevel(ThaumcraftApi.enchantRepair, stack);
		if ((backpackRepair <= 0) || ((player.ticksExisted % time) > 0)) return;
		
		for (int i = 0; i < backpackInventory.getSizeInventory(); i++) {
			ItemStack itemStack = backpackInventory.getStackInSlot(i);
			if (itemStack == null) continue;
			Item item = itemStack.getItem();
			int repair = EnchantmentHelper.getEnchantmentLevel(ThaumcraftApi.enchantRepair, itemStack);
			if (!(item instanceof IRepairable) || (repair <= 0) ||
			    ((item instanceof IRepairableExtended) &&
			     !((IRepairableExtended)item).doRepair(itemStack, player, repair))) continue;
			itemStack.setItemDamage(Math.max(itemStack.getItemDamage() - repair, 0));
		}
		
	}
	
	// IVisDiscountGear implementation
	
	@Override
	public int getVisDiscount(ItemStack stack, EntityPlayer player, Aspect aspect) { return 2; }
	
}

{'fraction_non_alphanumeric': 0.11156850327211315, 'fraction_numerical': 0.01087185982689466, 'mean_word_length': 4.98547062539482, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5400169', 'n_tokens_mistral': 3376, 'n_tokens_neox': 3030, 'n_words': 673}