@Nonnull public static ItemStack tryRepairTool(NonNullList<ItemStack> stacks, ItemStack toolStack, boolean removeItems) { if(toolStack == null || !(toolStack.getItem() instanceof IRepairable)) { return ItemStack.EMPTY; } // obtain a working copy of the items if the originals shouldn't be modified if(!removeItems) { stacks = Util.deepCopyFixedNonNullList(stacks); } return ((IRepairable) toolStack.getItem()).repair(toolStack, stacks); }