<commit_before>package landmaster.plustic.traits;

import baubles.api.*;
import baubles.api.cap.*;
import java.util.*;
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.item.*;
import net.minecraft.world.*;
import slimeknights.tconstruct.library.traits.*;
import slimeknights.tconstruct.library.utils.*;
//import vazkii.botania.api.*;
import vazkii.botania.api.mana.*;

public class Mana extends AbstractTrait {
	public static final Mana mana = new Mana();
	
	public Mana() {
		super("mana", 0x54E5FF);
	}
	
	@Override
	public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {
		if (!world.isRemote && entity instanceof EntityPlayer && ToolHelper.getCurrentDurability(tool) < ToolHelper.getMaxDurability(tool)) {
			EntityPlayer ep = (EntityPlayer)entity;
			List<ItemStack[]> ivs = Arrays.asList(ep.inventory.mainInventory,ep.inventory.armorInventory,ep.inventory.offHandInventory);
			for (ItemStack[] iv: ivs) {
				for (int i=0; i<iv.length; ++i) {
					if (ManaItemHandler.requestManaExact(iv[i], ep, 100, true)) {
						ep.inventory.markDirty();
						ToolHelper.healTool(tool, 1, ep);
						return;
					}
				}
			}
			IBaublesItemHandler ib = BaublesApi.getBaublesHandler(ep);
			for (int i=0; i<ib.getSlots(); ++i) {
				ItemStack is = ib.getStackInSlot(i);
				if (is == null) continue;
				is = is.copy();
				if (ManaItemHandler.requestManaExact(is, ep, 100, true)) {
					ToolHelper.healTool(tool, 1, ep);
					ib.setStackInSlot(i, is);
					return;
				}
			}
		}
	}
	
	@Override
	public int onToolDamage(ItemStack tool, int damage, int newDamage, EntityLivingBase entity) {
		manadraw:
		if (entity instanceof EntityPlayer && newDamage > 0) {
			EntityPlayer ep = (EntityPlayer)entity;
			List<ItemStack[]> ivs = Arrays.asList(ep.inventory.mainInventory,ep.inventory.armorInventory,ep.inventory.offHandInventory);
			for (ItemStack[] iv: ivs) {
				for (int i=0; i<iv.length; ++i) {
					if (ManaItemHandler.requestManaExact(iv[i], ep, 100, true)) {
						ep.inventory.markDirty();
						if (--newDamage <= 0) break manadraw;
					}
				}
			}
			IBaublesItemHandler ib = BaublesApi.getBaublesHandler(ep);
			for (int i=0; i<ib.getSlots(); ++i) {
				ItemStack is = ib.getStackInSlot(i);
				if (is == null) continue;
				is = is.copy();
				if (ManaItemHandler.requestManaExact(is, ep, 100, true)) {
					ib.setStackInSlot(i, is);
					if (--newDamage <= 0) break manadraw;
				}
			}
		}
		return super.onToolDamage(tool, damage, newDamage, entity);
	}
}<commit_msg>Fix #7<commit_after>package landmaster.plustic.traits;

import baubles.api.*;
import baubles.api.cap.*;
import java.util.*;
import net.minecraft.entity.*;
import net.minecraft.entity.player.*;
import net.minecraft.item.*;
import net.minecraft.world.*;
import slimeknights.tconstruct.library.traits.*;
import slimeknights.tconstruct.library.utils.*;
//import vazkii.botania.api.*;
import vazkii.botania.api.mana.*;

public class Mana extends AbstractTrait {
	public static final Mana mana = new Mana();
	
	public Mana() {
		super("mana", 0x54E5FF);
	}
	
	@Override
	public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {
		if (!world.isRemote && entity instanceof EntityPlayer && ToolHelper.getCurrentDurability(tool) < ToolHelper.getMaxDurability(tool)) {
			EntityPlayer ep = (EntityPlayer)entity;
			List<ItemStack[]> ivs = Arrays.asList(ep.inventory.mainInventory,ep.inventory.armorInventory,ep.inventory.offHandInventory);
			for (ItemStack[] iv: ivs) {
				for (int i=0; i<iv.length; ++i) {
					if (ManaItemHandler.requestManaExactForTool(iv[i], ep, 100, true)) {
						ep.inventory.markDirty();
						ToolHelper.healTool(tool, 1, ep);
						return;
					}
				}
			}
			IBaublesItemHandler ib = BaublesApi.getBaublesHandler(ep);
			for (int i=0; i<ib.getSlots(); ++i) {
				ItemStack is = ib.getStackInSlot(i);
				if (is == null) continue;
				is = is.copy();
				if (ManaItemHandler.requestManaExactForTool(is, ep, 100, true)) {
					ToolHelper.healTool(tool, 1, ep);
					ib.setStackInSlot(i, is);
					return;
				}
			}
		}
	}
	
	@Override
	public int onToolDamage(ItemStack tool, int damage, int newDamage, EntityLivingBase entity) {
		manadraw:
		if (entity instanceof EntityPlayer && newDamage > 0) {
			EntityPlayer ep = (EntityPlayer)entity;
			List<ItemStack[]> ivs = Arrays.asList(ep.inventory.mainInventory,ep.inventory.armorInventory,ep.inventory.offHandInventory);
			for (ItemStack[] iv: ivs) {
				for (int i=0; i<iv.length; ++i) {
					if (ManaItemHandler.requestManaExactForTool(iv[i], ep, 100, true)) {
						ep.inventory.markDirty();
						if (--newDamage <= 0) break manadraw;
					}
				}
			}
			IBaublesItemHandler ib = BaublesApi.getBaublesHandler(ep);
			for (int i=0; i<ib.getSlots(); ++i) {
				ItemStack is = ib.getStackInSlot(i);
				if (is == null) continue;
				is = is.copy();
				if (ManaItemHandler.requestManaExactForTool(is, ep, 100, true)) {
					ib.setStackInSlot(i, is);
					if (--newDamage <= 0) break manadraw;
				}
			}
		}
		return super.onToolDamage(tool, damage, newDamage, entity);
	}
}
{'fraction_non_alphanumeric': 0.14213690129920498, 'fraction_numerical': 0.009889470622454915, 'mean_word_length': 3.8660377358490567, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 9, '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': '7385077', 'n_tokens_mistral': 2183, 'n_tokens_neox': 1851, 'n_words': 383}